From f2aacab4d53c3c876e063c8c921f70502f3b629a Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Sat, 23 May 2020 20:54:36 +0200 Subject: [PATCH] Fix withing of external dependencies (#421) * Fix addition of external dependencies * Test for withing an unavailable external --- src/alr/alr-commands-withing.adb | 3 ++- testsuite/tests/with/external/test.py | 31 +++++++++++++++++++++++++ testsuite/tests/with/external/test.yaml | 3 +++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 testsuite/tests/with/external/test.py create mode 100644 testsuite/tests/with/external/test.yaml diff --git a/src/alr/alr-commands-withing.adb b/src/alr/alr-commands-withing.adb index a9406b58..803d791f 100644 --- a/src/alr/alr-commands-withing.adb +++ b/src/alr/alr-commands-withing.adb @@ -5,6 +5,7 @@ with Ada.Text_IO; with Alire.Conditional; with Alire.Dependencies.Diffs; +with Alire.Index; with Alire.Milestones; with Alire.Releases; with Alire.Roots; @@ -41,7 +42,7 @@ package body Alr.Commands.Withing is -- Check that the requested dependency exists - if not Query.Exists (Requested.Crate) then + if not Alire.Index.Exists (Requested.Crate) then Reportaise_Command_Failed ("The requested crate was not found in the catalog: " & (+Requested.Crate)); diff --git a/testsuite/tests/with/external/test.py b/testsuite/tests/with/external/test.py new file mode 100644 index 00000000..86a945fc --- /dev/null +++ b/testsuite/tests/with/external/test.py @@ -0,0 +1,31 @@ +""" +Verify that withing a dependency on a crate with only unavailable externals +works +""" + +from glob import glob +import os +import re + +from drivers.alr import run_alr +from drivers.asserts import assert_eq, assert_match + + +# Initialize a new project +run_alr('init', '--bin', 'xxx') +os.chdir('xxx') + +# Add a dependency on 'make', defined in the index as only a hint +run_alr('with', 'make') + +# Verify that it appears in the solution as unavailable external +p = run_alr('with', '--solve') +assert_match('Dependencies \(direct\):\n' + ' make\*\n' + 'Dependencies \(external\):\n' + ' make\*\n' + '.*', # Skip graph + p.out, flags=re.S) + + +print('SUCCESS') diff --git a/testsuite/tests/with/external/test.yaml b/testsuite/tests/with/external/test.yaml new file mode 100644 index 00000000..872fc127 --- /dev/null +++ b/testsuite/tests/with/external/test.yaml @@ -0,0 +1,3 @@ +driver: python-script +indexes: + basic_index: {} -- 2.39.5