forked from xdslproject/xdsl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Add main and filecheck tests for Toy (xdslproject#867)
I'm having trouble getting filecheck to cooperate. It refuses to run tests outside `tests/filecheck`, as far as I can tell, do you know what might be causing this? ``` (venv) (base) sasha@SL-MBP-16 ~/D/x/xdsl> lit -v docs/Toy/examples/ast.toy sasha/toy/filecheck! lit: /Users/sasha/Developer/xdslproject/xdsl/venv/lib/python3.11/site-packages/lit/discovery.py:132: warning: unable to find test suite for 'docs/Toy/examples/ast.toy' lit: /Users/sasha/Developer/xdslproject/xdsl/venv/lib/python3.11/site-packages/lit/discovery.py:281: warning: input 'docs/Toy/examples/ast.toy' contained no tests error: did not discover any tests for provided path(s) ``` Running the copy in `filecheck/frontend` works fine
- Loading branch information
1 parent
87a78e1
commit 3bff937
Showing
11 changed files
with
147 additions
and
45 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 |
---|---|---|
|
@@ -44,3 +44,4 @@ jobs: | |
run: | | ||
export PYTHONPATH=$(pwd) | ||
lit -v tests/filecheck/ | ||
lit -v docs/Toy/examples/ |
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
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,9 @@ | ||
import lit.formats | ||
import os | ||
|
||
config.test_source_root = os.path.dirname(__file__) | ||
toy_src = os.path.dirname(config.test_source_root) | ||
|
||
config.name = "Toy" | ||
config.test_format = lit.formats.ShTest(preamble_commands=[f"cd {toy_src}"]) | ||
config.suffixes = ['.mlir', '.toy'] |
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,45 @@ | ||
import argparse | ||
from pathlib import Path | ||
|
||
from xdsl.printer import Printer | ||
|
||
from .frontend.ir_gen import IRGen | ||
from .frontend.parser import Parser | ||
|
||
|
||
parser = argparse.ArgumentParser(description="Process Toy file") | ||
parser.add_argument("source", type=Path, help="toy source file") | ||
parser.add_argument( | ||
"--emit", | ||
dest="emit", | ||
choices=["ast", "ir"], | ||
default="ast", | ||
help="Action to perform on source file (default: interpret file)", | ||
) | ||
|
||
|
||
def main(path: Path, emit: str): | ||
path = args.source | ||
|
||
with open(path, "r") as f: | ||
parser = Parser(path, f.read()) | ||
ast = parser.parseModule() | ||
|
||
if emit == "ast": | ||
print(ast.dump()) | ||
return | ||
|
||
ir_gen = IRGen() | ||
|
||
module_op = ir_gen.ir_gen_module(ast) | ||
|
||
if emit == "ir": | ||
printer = Printer() | ||
printer.print_op(module_op) | ||
|
||
print(f"Unknown option {emit}") | ||
|
||
|
||
if __name__ == "__main__": | ||
args = parser.parse_args() | ||
main(args.source, args.emit) |
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