Skip to content

Commit

Permalink
Ensure test.py --use flag fully overrides USE_* envvars (#524)
Browse files Browse the repository at this point in the history
* Ensure test.py --use flag fully overrides USE_* envvars

* Update a test-tools unit test

Co-authored-by: Manolis Papadakis <[email protected]>
  • Loading branch information
manopapad and manopapad authored Aug 15, 2022
1 parent 04430a8 commit b4fbde3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions tests/_utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,14 @@ def legate_path(self) -> Path:
return self.legate_dir / "bin" / "legate"

def _compute_features(self, args: Namespace) -> tuple[FeatureType, ...]:
args_features = args.features or []
computed = []
for feature in FEATURES:
if feature in args_features:
computed.append(feature)
elif os.environ.get(f"USE_{feature.upper()}", None) == "1":
computed.append(feature)
if args.features is not None:
computed = args.features
else:
computed = [
feature
for feature in FEATURES
if os.environ.get(f"USE_{feature.upper()}", None) == "1"
]

# if nothing is specified any other way, at least run CPU stage
if len(computed) == 0:
Expand Down
2 changes: 1 addition & 1 deletion tests/_utils/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_env_features(

# also test with a --use value provided
c = m.Config(["test.py", "--use", "cuda"])
assert set(c.features) == {"cuda", feature}
assert set(c.features) == {"cuda"}

@pytest.mark.parametrize("feature", FEATURES)
def test_cmd_features(self, feature: str) -> None:
Expand Down

0 comments on commit b4fbde3

Please sign in to comment.