From 1dedad9573fdf0f6677d3118f1e844e7aca35f9e Mon Sep 17 00:00:00 2001 From: James Lamb Date: Tue, 23 Jul 2024 09:12:11 -0500 Subject: [PATCH 1/2] test: add tests on handling of duplicate matrix selectors --- tests/test_cli.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_cli.py b/tests/test_cli.py index f41091de..a5c2944a 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -11,6 +11,16 @@ def test_generate_matrix(): assert matrix is None +def test_generate_matrix_allows_duplicates_and_chooses_the_final_value(): + # duplicate keys + matrix = generate_matrix("thing=abc;other_thing=true;thing=def;thing=ghi") + assert matrix == {"other_thing": ["true"], "thing": ["ghi"]} + + # duplicate keys and values + matrix = generate_matrix("thing=abc;thing=abc") + assert matrix == {"thing": ["abc"]} + + def test_validate_args(): # Missing output with pytest.raises(Exception): @@ -106,3 +116,17 @@ def test_validate_args(): "my_other_channel", ] ) + + # Valid, with duplicates in --matrix + validate_args( + [ + "-c", + "dependencies2.yaml", + "--output", + "pyproject", + "--matrix", + "cuda_suffixed=true;arch=x86_64;cuda_suffixed=false", + "--file-key", + "all", + ] + ) From cfe81b417f572e1f7d3870c4ac64b35e034804b6 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Tue, 23 Jul 2024 09:53:20 -0500 Subject: [PATCH 2/2] add a line to docs --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 4ecaf4d1..0c024dfa 100644 --- a/README.md +++ b/README.md @@ -333,6 +333,8 @@ The `--file-key` argument is passed the `test` key name from the `files` configu The `--file-key`, `--output`, and `--matrix` flags must be used together. `--matrix` may be an empty string if the file that should be generated does not depend on any specific matrix variations. +Where multiple values for the same key are passed to `--matrix`, e.g. `cuda_suffixed=true;cuda_suffixed=false`, only the last value will be used. + The `--prepend-channel` argument accepts additional channels to use, like `rapids-dependency-file-generator --prepend-channel my_channel --prepend-channel my_other_channel`. If both `--output` and `--prepend-channel` are provided, the output format must be conda. Prepending channels can be useful for adding local channels with packages to be tested in CI workflows.