-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for test config overrides
It can be useful to override the config for certain tests. The main use case for this is to override environment variables which control test assertions (e.g. NO_DANGLING_FILESYSTEM, ERRNO_MODE_WINDOWS). When running the tests in CI, it would be nicer to support this without manually modifying the JSON test config files.
- Loading branch information
Showing
8 changed files
with
118 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"WASI C tests": { | ||
"stat-dev-ino": { | ||
"dirs": [ | ||
"fs-tests.dir" | ||
], | ||
"env": { | ||
"TEST_VAR": "test" | ||
}, | ||
"args": [ | ||
"fs-tests.dir", | ||
"test_arg" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import json | ||
|
||
from abc import ABC, abstractmethod | ||
from typing import Any, Dict, Optional | ||
from .test_case import ( | ||
Config, | ||
) | ||
|
||
|
||
class ConfigOverride(ABC): | ||
@abstractmethod | ||
def get_test_override( | ||
self, test_suite_name: str, test_name: str | ||
) -> Optional[Config]: | ||
pass | ||
|
||
|
||
class JSONConfigOverride(ConfigOverride): | ||
overrides_dict: Dict[str, Dict[str, Dict[str, Any]]] | ||
|
||
def __init__(self, overrides_path: str) -> None: | ||
with open(overrides_path, encoding="utf-8") as file: | ||
self.overrides_dict = json.load(file) | ||
|
||
def get_test_override( | ||
self, test_suite_name: str, test_name: str | ||
) -> Optional[Config]: | ||
test_suite_overrides = self.overrides_dict.get(test_suite_name) | ||
|
||
if test_suite_overrides is None: | ||
return None | ||
|
||
test_override = test_suite_overrides.get(test_name) | ||
|
||
if test_override is None: | ||
return None | ||
|
||
return Config.from_dict(test_override) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters