Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add tests on handling of duplicate matrix selectors #102

Merged
merged 2 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
]
)
Loading