Skip to content

Commit

Permalink
Add lit-based tests for diagnostics.
Browse files Browse the repository at this point in the history
whitequark committed Jun 6, 2015
1 parent 7f77632 commit 98fe152
Showing 3 changed files with 19 additions and 3 deletions.
8 changes: 7 additions & 1 deletion artiq/py2llvm/typing.py
Original file line number Diff line number Diff line change
@@ -358,7 +358,11 @@ def generic_visit(self, node):
def main():
import sys, fileinput, os

inference_mode = True
if sys.argv[1] == '+diag':
del sys.argv[1]
inference_mode = False
else:
inference_mode = True

engine = diagnostic.Engine(all_errors_are_fatal=True)
try:
@@ -375,6 +379,8 @@ def main():
if inference_mode:
print("\n".join(e.diagnostic.render()), file=sys.stderr)
exit(1)
else:
print("\n".join(e.diagnostic.render(only_line=True)))

if __name__ == "__main__":
main()
6 changes: 4 additions & 2 deletions lit-test/harness.py
Original file line number Diff line number Diff line change
@@ -12,8 +12,10 @@
import sys, os, argparse, importlib

parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('-m', metavar='mod', type=str, help='run library module as a script')
parser.add_argument('args', type=str, nargs='+', help='arguments passed to program in sys.argv[1:]')
parser.add_argument('-m', metavar='mod', type=str, required=True,
help='run library module as a script')
parser.add_argument('args', type=str, nargs='+',
help='arguments passed to program in sys.argv[1:]')
args = parser.parse_args(sys.argv[1:])

artiq_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
8 changes: 8 additions & 0 deletions lit-test/py2llvm/typing/error_unify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# RUN: %python -m artiq.py2llvm.typing +diag %s >%t
# RUN: OutputCheck %s --file-to-check=%t

a = 1
b = []

# CHECK-L: ${LINE:+1}: fatal: cannot unify int(width='a) with list(elt='b)
a = b

0 comments on commit 98fe152

Please sign in to comment.