diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index db27c59b1..0b94b7272 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -15,7 +15,7 @@ jobs: build: name: CI on macOS - runs-on: macos-latest + runs-on: macos-10.15 steps: - name: Check out repository diff --git a/.github/workflows/ci-toolchain.yml b/.github/workflows/ci-toolchain.yml index 013916396..c5f65e6f7 100644 --- a/.github/workflows/ci-toolchain.yml +++ b/.github/workflows/ci-toolchain.yml @@ -21,7 +21,7 @@ jobs: strategy: matrix: os: - - macos-latest + - macos-10.15 - ubuntu-latest - windows-latest diff --git a/src/alire/alire-crate_configuration.adb b/src/alire/alire-crate_configuration.adb index bd7ac85bd..1c633d1e9 100644 --- a/src/alire/alire-crate_configuration.adb +++ b/src/alire/alire-crate_configuration.adb @@ -185,7 +185,8 @@ package body Alire.Crate_Configuration is (Profile_Maps.Key (Cursor), (Name => +Builtin_Build_Profile.Name, Value => TOML.Create_String - (To_Lower_Case (Profile_Maps.Element (Cursor)'Img)))); + (To_Lower_Case (Profile_Maps.Element (Cursor)'Img))), + Set_By => "Build profile map"); end loop; end Make_Build_Profile_Map; @@ -656,15 +657,15 @@ package body Alire.Crate_Configuration is -- Set_Value -- --------------- - procedure Set_Value (This : in out Global_Config; - Crate : Crate_Name; - Val : Assignment) + procedure Set_Value (This : in out Global_Config; + Crate : Crate_Name; + Val : Assignment; + Set_By : String) is Val_Name_Lower : constant String := To_Lower_Case (+Val.Name); Crate_Str : constant String := +Crate; Name : constant Unbounded_String := (+Crate_Str) & "." & Val_Name_Lower; begin - -- TODO check if setting configuration of a dependency if not This.Map.Contains (Name) then @@ -683,14 +684,16 @@ package body Alire.Crate_Configuration is "'" & " for type " & Image (Ref.Type_Def.Element)); end if; - if Ref.Value /= No_TOML_Value and then Ref.Value /= Val.Value then + if Ref.Value.Is_Present and then not Ref.Value.Equals (Val.Value) + then Raise_Checked_Error ("Conflicting value for configuration variable '" & - (+Name) & "' from '" & (+Ref.Set_By) & "' and '" - & (+Crate) & "'."); + (+Name) & "' from '" & (+Ref.Set_By) & "' (" & + Image (Ref.Value) & ") and '" + & Set_By & "' (" & Image (Val.Value) & ")."); else - Ref.Value := Val.Value; - Ref.Set_By := +(+Crate); + Ref.Value := Val.Value; + Ref.Set_By := +(Set_By); end if; end; end Set_Value; @@ -716,7 +719,8 @@ package body Alire.Crate_Configuration is Config_Value_Assignment (Prop); begin for Elt of List.List loop - This.Set_Value (To_Name (+List.Crate), Elt); + This.Set_Value (To_Name (+List.Crate), Elt, + Set_By => As_String (Crate)); end loop; end; end loop; diff --git a/src/alire/alire-crate_configuration.ads b/src/alire/alire-crate_configuration.ads index 0302ddf0d..921dad252 100644 --- a/src/alire/alire-crate_configuration.ads +++ b/src/alire/alire-crate_configuration.ads @@ -84,9 +84,10 @@ private Root : in out Roots.Root; Crate : Crate_Name); - procedure Set_Value (This : in out Global_Config; - Crate : Crate_Name; - Val : Assignment); + procedure Set_Value (This : in out Global_Config; + Crate : Crate_Name; + Val : Assignment; + Set_By : String); procedure Load_Settings (This : in out Global_Config; Root : in out Roots.Root; diff --git a/src/alire/alire-properties-configurations.adb b/src/alire/alire-properties-configurations.adb index ce24ad62f..bb38a1417 100644 --- a/src/alire/alire-properties-configurations.adb +++ b/src/alire/alire-properties-configurations.adb @@ -129,7 +129,7 @@ package body Alire.Properties.Configurations is when TOML_String => return Val.As_String; when TOML_Boolean => - return Val.As_Boolean'Img; + return To_Lower_Case (Val.As_Boolean'Img); when TOML_Float => return Image (Val.As_Float); when TOML_Integer => diff --git a/src/alire/alire-properties-configurations.ads b/src/alire/alire-properties-configurations.ads index 6564a795b..2c643bb51 100644 --- a/src/alire/alire-properties-configurations.ads +++ b/src/alire/alire-properties-configurations.ads @@ -101,6 +101,9 @@ package Alire.Properties.Configurations with Preelaborate is function Typedef_From_Enum return Config_Type_Definition; function String_Typedef (Name : String) return Config_Type_Definition; + + function Image (Val : TOML.TOML_Value) return String; + private type Config_Entry is new Properties.Property with record diff --git a/testsuite/tests/crate_config/value_conflict/my_index/index/he/hello_world/hello_world-0.1.0.toml b/testsuite/tests/crate_config/value_conflict/my_index/index/he/hello_world/hello_world-0.1.0.toml new file mode 100644 index 000000000..4ba0c9350 --- /dev/null +++ b/testsuite/tests/crate_config/value_conflict/my_index/index/he/hello_world/hello_world-0.1.0.toml @@ -0,0 +1,14 @@ +description = "\"Hello, world!\" demonstration project" +name = "hello_world" +version = "0.1.0" +licenses = "GPL-3.0-only" +maintainers = ["example@example.com"] +maintainers-logins = ["mylogin"] +executables=['main'] + +[origin] +url = "file:." + +[[depends-on]] +libcrate_config_b = "*" +libcrate_config_c = "*" diff --git a/testsuite/tests/crate_config/value_conflict/my_index/index/index.toml b/testsuite/tests/crate_config/value_conflict/my_index/index/index.toml new file mode 100644 index 000000000..bad265e4f --- /dev/null +++ b/testsuite/tests/crate_config/value_conflict/my_index/index/index.toml @@ -0,0 +1 @@ +version = "1.1" diff --git a/testsuite/tests/crate_config/value_conflict/my_index/index/li/libcrate_config_a/libcrate_config_a-1.0.0.toml b/testsuite/tests/crate_config/value_conflict/my_index/index/li/libcrate_config_a/libcrate_config_a-1.0.0.toml new file mode 100644 index 000000000..39d58201a --- /dev/null +++ b/testsuite/tests/crate_config/value_conflict/my_index/index/li/libcrate_config_a/libcrate_config_a-1.0.0.toml @@ -0,0 +1,12 @@ +description = "crate config demonstration project" +name = "libcrate_config_a" +version = "1.0.0" +licenses = "GPL-3.0-only" +maintainers = ["example@example.com"] +maintainers-logins = ["mylogin"] + +[origin] +url = "file:." + +[configuration.variables] +Var_Bool = {type="Boolean"} diff --git a/testsuite/tests/crate_config/value_conflict/my_index/index/li/libcrate_config_b/libcrate_config_b-1.0.0.toml b/testsuite/tests/crate_config/value_conflict/my_index/index/li/libcrate_config_b/libcrate_config_b-1.0.0.toml new file mode 100644 index 000000000..1277e7db8 --- /dev/null +++ b/testsuite/tests/crate_config/value_conflict/my_index/index/li/libcrate_config_b/libcrate_config_b-1.0.0.toml @@ -0,0 +1,15 @@ +description = "crate config demonstration project" +name = "libcrate_config_b" +version = "1.0.0" +licenses = "GPL-3.0-only" +maintainers = ["example@example.com"] +maintainers-logins = ["mylogin"] + +[[depends-on]] +libcrate_config_a = "*" + +[origin] +url = "file:." + +[configuration.values] +libcrate_config_a.Var_Bool = true diff --git a/testsuite/tests/crate_config/value_conflict/my_index/index/li/libcrate_config_c/libcrate_config_c-1.0.0.toml b/testsuite/tests/crate_config/value_conflict/my_index/index/li/libcrate_config_c/libcrate_config_c-1.0.0.toml new file mode 100644 index 000000000..10cfb3601 --- /dev/null +++ b/testsuite/tests/crate_config/value_conflict/my_index/index/li/libcrate_config_c/libcrate_config_c-1.0.0.toml @@ -0,0 +1,15 @@ +description = "crate config demonstration project" +name = "libcrate_config_c" +version = "1.0.0" +licenses = "GPL-3.0-only" +maintainers = ["example@example.com"] +maintainers-logins = ["mylogin"] + +[[depends-on]] +libcrate_config_a = "*" + +[origin] +url = "file:." + +[configuration.values] +libcrate_config_a.Var_Bool = false diff --git a/testsuite/tests/crate_config/value_conflict/test.py b/testsuite/tests/crate_config/value_conflict/test.py new file mode 100644 index 000000000..69ad4cc11 --- /dev/null +++ b/testsuite/tests/crate_config/value_conflict/test.py @@ -0,0 +1,24 @@ +""" +Test that two crates setting the same config var to the different values is not +ok. +""" + +from drivers.alr import run_alr +from drivers.asserts import assert_match + +import os +import platform + +p = run_alr('get', 'hello_world', complain_on_error=False) +assert p.status != 0, "alr should have errored" + +print(p.out) +assert_match(".*\n" + "ERROR: Conflicting value for configuration variable" + " 'libcrate_config_a.var_bool'" + " from 'libcrate_config_b' \(true\)" + " and 'libcrate_config_c' \(false\).*" + , + p.out) + +print('SUCCESS') diff --git a/testsuite/tests/crate_config/value_conflict/test.yaml b/testsuite/tests/crate_config/value_conflict/test.yaml new file mode 100644 index 000000000..0a859639c --- /dev/null +++ b/testsuite/tests/crate_config/value_conflict/test.yaml @@ -0,0 +1,4 @@ +driver: python-script +indexes: + my_index: + in_fixtures: false diff --git a/testsuite/tests/crate_config/value_match/my_index/index/he/hello_world/hello_world-0.1.0.toml b/testsuite/tests/crate_config/value_match/my_index/index/he/hello_world/hello_world-0.1.0.toml new file mode 100644 index 000000000..4ba0c9350 --- /dev/null +++ b/testsuite/tests/crate_config/value_match/my_index/index/he/hello_world/hello_world-0.1.0.toml @@ -0,0 +1,14 @@ +description = "\"Hello, world!\" demonstration project" +name = "hello_world" +version = "0.1.0" +licenses = "GPL-3.0-only" +maintainers = ["example@example.com"] +maintainers-logins = ["mylogin"] +executables=['main'] + +[origin] +url = "file:." + +[[depends-on]] +libcrate_config_b = "*" +libcrate_config_c = "*" diff --git a/testsuite/tests/crate_config/value_match/my_index/index/index.toml b/testsuite/tests/crate_config/value_match/my_index/index/index.toml new file mode 100644 index 000000000..bad265e4f --- /dev/null +++ b/testsuite/tests/crate_config/value_match/my_index/index/index.toml @@ -0,0 +1 @@ +version = "1.1" diff --git a/testsuite/tests/crate_config/value_match/my_index/index/li/libcrate_config_a/libcrate_config_a-1.0.0.toml b/testsuite/tests/crate_config/value_match/my_index/index/li/libcrate_config_a/libcrate_config_a-1.0.0.toml new file mode 100644 index 000000000..f55a82d75 --- /dev/null +++ b/testsuite/tests/crate_config/value_match/my_index/index/li/libcrate_config_a/libcrate_config_a-1.0.0.toml @@ -0,0 +1,12 @@ +description = "crate config demonstration project" +name = "libcrate_config_a" +version = "1.0.0" +licenses = "GPL-3.0-only" +maintainers = ["example@example.com"] +maintainers-logins = ["mylogin"] + +[origin] +url = "file:." + +[configuration.variables] +Var_Bool = {type="Boolean", default=true} diff --git a/testsuite/tests/crate_config/value_match/my_index/index/li/libcrate_config_b/libcrate_config_b-1.0.0.toml b/testsuite/tests/crate_config/value_match/my_index/index/li/libcrate_config_b/libcrate_config_b-1.0.0.toml new file mode 100644 index 000000000..feea80502 --- /dev/null +++ b/testsuite/tests/crate_config/value_match/my_index/index/li/libcrate_config_b/libcrate_config_b-1.0.0.toml @@ -0,0 +1,15 @@ +description = "crate config demonstration project" +name = "libcrate_config_b" +version = "1.0.0" +licenses = "GPL-3.0-only" +maintainers = ["example@example.com"] +maintainers-logins = ["mylogin"] + +[[depends-on]] +libcrate_config_a = "*" + +[origin] +url = "file:." + +[configuration.values] +libcrate_config_a.Var_Bool = false diff --git a/testsuite/tests/crate_config/value_match/my_index/index/li/libcrate_config_c/libcrate_config_c-1.0.0.toml b/testsuite/tests/crate_config/value_match/my_index/index/li/libcrate_config_c/libcrate_config_c-1.0.0.toml new file mode 100644 index 000000000..10cfb3601 --- /dev/null +++ b/testsuite/tests/crate_config/value_match/my_index/index/li/libcrate_config_c/libcrate_config_c-1.0.0.toml @@ -0,0 +1,15 @@ +description = "crate config demonstration project" +name = "libcrate_config_c" +version = "1.0.0" +licenses = "GPL-3.0-only" +maintainers = ["example@example.com"] +maintainers-logins = ["mylogin"] + +[[depends-on]] +libcrate_config_a = "*" + +[origin] +url = "file:." + +[configuration.values] +libcrate_config_a.Var_Bool = false diff --git a/testsuite/tests/crate_config/value_match/test.py b/testsuite/tests/crate_config/value_match/test.py new file mode 100644 index 000000000..8c1631142 --- /dev/null +++ b/testsuite/tests/crate_config/value_match/test.py @@ -0,0 +1,13 @@ +""" +Test that two crates setting the same config var to the same value is ok. +""" + +from drivers.alr import run_alr +from drivers.asserts import assert_match + +import os +import platform + +p = run_alr('get', 'hello_world') + +print('SUCCESS') diff --git a/testsuite/tests/crate_config/value_match/test.yaml b/testsuite/tests/crate_config/value_match/test.yaml new file mode 100644 index 000000000..0a859639c --- /dev/null +++ b/testsuite/tests/crate_config/value_match/test.yaml @@ -0,0 +1,4 @@ +driver: python-script +indexes: + my_index: + in_fixtures: false diff --git a/testsuite/tests/show/jekyll/test.py b/testsuite/tests/show/jekyll/test.py index cee9485f6..0f0aa78c6 100644 --- a/testsuite/tests/show/jekyll/test.py +++ b/testsuite/tests/show/jekyll/test.py @@ -29,8 +29,8 @@ '{name: \'Var5\', type: \'Integer range -1 .. 1\', default: "0"},\n' '{name: \'Var6\', type: \'Real range -1.00000000000000E+00 .. 1.00000000000000E+00\', default: "0.00000000000000E+00"},\n' '{name: \'Var7\', type: \'Real range -inf .. +inf\', default: "0.00000000000000E+00"}]\n' - 'configuration_values: [{crate: \'hello\', settings: [{name: \'Var1\', value: "TRUE"}]},\n' - '{crate: \'libhello\', settings: [{name: \'Var1\', value: "FALSE"}]}]\n' + 'configuration_values: [{crate: \'hello\', settings: [{name: \'Var1\', value: "true"}]},\n' + '{crate: \'libhello\', settings: [{name: \'Var1\', value: "false"}]}]\n' '\n' '---\n' 'This is an example of long description in a multi-line string.\n'