-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add testing for xdsl_opt_main
- Loading branch information
Showing
4 changed files
with
26 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This folder contains the infrastructure to test `xdsl_opt_main` through pytest. | ||
The main driver sits in `test_xdsl_opt.py`, which needs the other files to read | ||
and reprint them. |
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 @@ | ||
builtin.module() {} |
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,18 @@ | ||
from xdsl.xdsl_opt_main import xDSLOptMain | ||
from contextlib import redirect_stdout | ||
from io import StringIO | ||
|
||
|
||
def test_opt(): | ||
filename = 'tests/xdsl_opt/substitute_ops.xdsl' | ||
opt = xDSLOptMain(args=[filename]) | ||
assert list(opt.available_frontends.keys()) == ['xdsl', 'mlir'] | ||
assert list(opt.available_targets.keys()) == ['xdsl', 'irdl', 'mlir'] | ||
assert list(opt.available_passes.keys()) == [] | ||
|
||
f = StringIO("") | ||
with redirect_stdout(f): | ||
opt.run() | ||
|
||
expected = open(filename, 'r').read() | ||
assert f.getvalue().strip() == expected.strip() |
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