From 9a271f89f27c5b5869522a629df800c247dce8c3 Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Fri, 19 Jun 2020 20:23:57 +0200 Subject: [PATCH] Fix: Load index prior to pinning to folder (#449) While this has no implications for the crate being pinned, any regularly solved crates will be missing afterwards unless the index is loaded pre-pinning. --- src/alr/alr-commands-pin.adb | 2 ++ .../crates/libhello_1.0.0/libhello.gpr | 24 +++++++++++++ .../crates/libhello_1.0.0/src/libhello.ads | 3 ++ .../my_index/index/index.toml | 1 + .../my_index/index/li/libhello.toml | 8 +++++ .../tests/pin/pin-dir-with-regular/test.py | 35 +++++++++++++++++++ .../tests/pin/pin-dir-with-regular/test.yaml | 4 +++ 7 files changed, 77 insertions(+) create mode 100644 testsuite/tests/pin/pin-dir-with-regular/my_index/crates/libhello_1.0.0/libhello.gpr create mode 100644 testsuite/tests/pin/pin-dir-with-regular/my_index/crates/libhello_1.0.0/src/libhello.ads create mode 100644 testsuite/tests/pin/pin-dir-with-regular/my_index/index/index.toml create mode 100644 testsuite/tests/pin/pin-dir-with-regular/my_index/index/li/libhello.toml create mode 100644 testsuite/tests/pin/pin-dir-with-regular/test.py create mode 100644 testsuite/tests/pin/pin-dir-with-regular/test.yaml diff --git a/src/alr/alr-commands-pin.adb b/src/alr/alr-commands-pin.adb index c02ecd16..bed9c55c 100644 --- a/src/alr/alr-commands-pin.adb +++ b/src/alr/alr-commands-pin.adb @@ -182,6 +182,8 @@ package body Alr.Commands.Pin is -- Pin to dir + Requires_Full_Index; -- Next statement recomputes a solution + New_Sol := Alire.Pinning.Pin_To (+Argument (1), Cmd.URL.all, diff --git a/testsuite/tests/pin/pin-dir-with-regular/my_index/crates/libhello_1.0.0/libhello.gpr b/testsuite/tests/pin/pin-dir-with-regular/my_index/crates/libhello_1.0.0/libhello.gpr new file mode 100644 index 00000000..3fe673f3 --- /dev/null +++ b/testsuite/tests/pin/pin-dir-with-regular/my_index/crates/libhello_1.0.0/libhello.gpr @@ -0,0 +1,24 @@ +project Libhello is + + for Library_Name use "Libhello"; + for Library_Version use "0.0.0"; + + for Source_Dirs use ("src"); + for Object_Dir use "obj"; + for Library_Dir use "lib"; + + package Builder is + for Switches ("ada") use ("-j0", "-g"); + end Builder; + + package Compiler is + for Switches ("ada") use + ("-gnatVa", "-gnatwa", "-g", "-O2", + "-gnata", "-gnato", "-fstack-check"); + end Compiler; + + package Binder is + for Switches ("ada") use ("-Es"); + end Binder; + +end Libhello; diff --git a/testsuite/tests/pin/pin-dir-with-regular/my_index/crates/libhello_1.0.0/src/libhello.ads b/testsuite/tests/pin/pin-dir-with-regular/my_index/crates/libhello_1.0.0/src/libhello.ads new file mode 100644 index 00000000..d4879364 --- /dev/null +++ b/testsuite/tests/pin/pin-dir-with-regular/my_index/crates/libhello_1.0.0/src/libhello.ads @@ -0,0 +1,3 @@ +package Libhello is + +end Libhello; diff --git a/testsuite/tests/pin/pin-dir-with-regular/my_index/index/index.toml b/testsuite/tests/pin/pin-dir-with-regular/my_index/index/index.toml new file mode 100644 index 00000000..7c969026 --- /dev/null +++ b/testsuite/tests/pin/pin-dir-with-regular/my_index/index/index.toml @@ -0,0 +1 @@ +version = "0.2" diff --git a/testsuite/tests/pin/pin-dir-with-regular/my_index/index/li/libhello.toml b/testsuite/tests/pin/pin-dir-with-regular/my_index/index/li/libhello.toml new file mode 100644 index 00000000..460334ba --- /dev/null +++ b/testsuite/tests/pin/pin-dir-with-regular/my_index/index/li/libhello.toml @@ -0,0 +1,8 @@ +[general] +description = "libhello" +licenses = [] +maintainers = ["some@one.com"] +maintainers-logins = ["mylogin"] + +['1.0'] +origin = "file://../../crates/libhello_1.0.0" diff --git a/testsuite/tests/pin/pin-dir-with-regular/test.py b/testsuite/tests/pin/pin-dir-with-regular/test.py new file mode 100644 index 00000000..9839ff14 --- /dev/null +++ b/testsuite/tests/pin/pin-dir-with-regular/test.py @@ -0,0 +1,35 @@ +""" +Test that pinning another crate doesn't affect a regularly solved one +""" + +import os +import re + +from drivers.alr import run_alr +from drivers.asserts import assert_match +from drivers.helpers import path_separator, with_project + +# Initialize a workspace, enter, and add a regular dependency +run_alr('init', '--bin', 'xxx') +os.chdir('xxx') + +# Add a regular solvable dependency +run_alr('with', 'libhello') + +# Add a missing crate +run_alr('with', 'unobtanium', '--force') + +# Pin the missing crate +run_alr('pin', 'unobtanium', '--use', '/') + +# Check the solution shows both pinned dir and regular dependency +p = run_alr('with', '--solve') +# For this match we don't know where the test is temporarily put, so we skip +# over some parts of the output +assert_match('.*Dependencies \(solution\):.*' + 'libhello=1\.0\.0.*' + 'Dependencies \(external\):.*' + 'unobtanium\* \(direct,linked,.*', + p.out, flags=re.S) + +print('SUCCESS') diff --git a/testsuite/tests/pin/pin-dir-with-regular/test.yaml b/testsuite/tests/pin/pin-dir-with-regular/test.yaml new file mode 100644 index 00000000..0a859639 --- /dev/null +++ b/testsuite/tests/pin/pin-dir-with-regular/test.yaml @@ -0,0 +1,4 @@ +driver: python-script +indexes: + my_index: + in_fixtures: false -- 2.39.5