Skip to content

Commit

Permalink
test: add tests on handling of duplicate matrix selectors (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb authored Jul 23, 2024
1 parent 3c7348a commit 535f0a9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
24 changes: 24 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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",
]
)

0 comments on commit 535f0a9

Please sign in to comment.