-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from automaticp/parser-tests-with-pytest
Parser tests: replace shell scripts with pytest scripts
- Loading branch information
Showing
5 changed files
with
58 additions
and
95 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,42 @@ | ||
import subprocess | ||
from pathlib import Path | ||
|
||
import pytest | ||
import pytest_subtests | ||
|
||
|
||
base_directory = Path(__file__).parent.resolve() | ||
|
||
glsl_extensions = ( | ||
".glsl", ".vert", ".frag", ".geom", | ||
".comp", ".tesc", ".tese", ".rgen", | ||
".rint", ".rahit", ".rchit", ".rmiss", | ||
".rcall", ".mesh", ".task" | ||
) | ||
|
||
|
||
@pytest.fixture( | ||
params=("glsl-samples/well-formed/glslang/",) | ||
) | ||
def dir_with_test_files(request) -> Path: | ||
return base_directory / Path(request.param) | ||
|
||
|
||
def test_parser_in_directory( | ||
subtests: pytest_subtests.SubTests, | ||
dir_with_test_files: Path | ||
): | ||
|
||
for file in dir_with_test_files.iterdir(): | ||
if file.suffix not in glsl_extensions: | ||
continue | ||
|
||
with subtests.test(msg=str(file)): | ||
output = subprocess.run( | ||
args=("glsl_analyzer", "--parse-file", str(file)), | ||
capture_output=True, | ||
text=True | ||
) | ||
|
||
assert output.returncode == 0 and len(output.stderr) == 0, \ | ||
output.stderr |