forked from M-Labs/artiq
1
0
Fork 0

Add lit-based tests for diagnostics.

This commit is contained in:
whitequark 2015-06-06 17:15:06 +03:00
parent 7f77632f1a
commit 98fe152159
3 changed files with 19 additions and 3 deletions

View File

@ -358,6 +358,10 @@ class Printer(algorithm.Visitor):
def main():
import sys, fileinput, os
if sys.argv[1] == '+diag':
del sys.argv[1]
inference_mode = False
else:
inference_mode = True
engine = diagnostic.Engine(all_errors_are_fatal=True)
@ -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()

View File

@ -12,8 +12,10 @@ emulate the same behavior when invoked under lit.
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__), '..'))

View File

@ -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