From 586f1fb61d3b3e1c85b7669f5c18390bd29322c0 Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Tue, 12 May 2020 12:50:12 +0200 Subject: [PATCH] Fix: use local dependencies in `alr show --solve` (#400) When the command was run for the local workspace (without explicit crate name), the dependencies were being taken from the index instead of the local release. This also manifested as not solvable dependencies for local releases without a counterpart in the index. --- src/alire/alire-solver.adb | 1 + src/alr/alr-commands-show.adb | 8 ++++++ testsuite/tests/show/solve-local/test.py | 30 ++++++++++++++++++++++ testsuite/tests/show/solve-local/test.yaml | 4 +++ 4 files changed, 43 insertions(+) create mode 100644 testsuite/tests/show/solve-local/test.py create mode 100644 testsuite/tests/show/solve-local/test.yaml diff --git a/src/alire/alire-solver.adb b/src/alire/alire-solver.adb index f0fbe26e..f57a26a1 100644 --- a/src/alire/alire-solver.adb +++ b/src/alire/alire-solver.adb @@ -650,6 +650,7 @@ package body Alire.Solver is begin if Deps.Is_Empty then + Trace.Debug ("Returning trivial solution for empty dependencies"); return Solution'(Valid => True, Releases => Empty_Map, Hints => Empty_Deps); diff --git a/src/alr/alr-commands-show.adb b/src/alr/alr-commands-show.adb index e86f9ff2..29d1360b 100644 --- a/src/alr/alr-commands-show.adb +++ b/src/alr/alr-commands-show.adb @@ -45,7 +45,15 @@ package body Alr.Commands.Show is Cmd : Command) is begin + if Current then + Trace.Debug ("Showing workspace definitions"); + else + Trace.Debug ("Showing definitions from index releases"); + end if; + declare + -- Nested so a failure in Query.Find is caught below + Rel : constant Types.Release := (if Current then Root.Current.Release diff --git a/testsuite/tests/show/solve-local/test.py b/testsuite/tests/show/solve-local/test.py new file mode 100644 index 00000000..b8e30d7a --- /dev/null +++ b/testsuite/tests/show/solve-local/test.py @@ -0,0 +1,30 @@ +""" +Test that the dependencies in a local crate are properly solved +""" + +import os.path +import re + +from drivers.alr import run_alr +from drivers.asserts import assert_match + +# Initialize a new workspace + +run_alr('init', '--bin', 'xxx') +os.chdir('xxx') + +# Add a dependency + +run_alr('with', 'libhello') + +# Verify that it is properly solved and shown + +p = run_alr('show', '--solve') +assert_match('.*\n' + 'Dependencies \(solution\):\n' + ' libhello=1\.0\.0\n' + '.*\n', + p.out, flags=re.S) + + +print('SUCCESS') diff --git a/testsuite/tests/show/solve-local/test.yaml b/testsuite/tests/show/solve-local/test.yaml new file mode 100644 index 00000000..8929d590 --- /dev/null +++ b/testsuite/tests/show/solve-local/test.yaml @@ -0,0 +1,4 @@ +driver: python-script +indexes: + basic_index: + in_fixtures: true -- 2.39.5