diff --git a/artiq/compiler/testbench/jit.py b/artiq/compiler/testbench/jit.py index 7d7d85227..1275b23e9 100644 --- a/artiq/compiler/testbench/jit.py +++ b/artiq/compiler/testbench/jit.py @@ -18,7 +18,9 @@ def main(): engine = diagnostic.Engine() engine.process = process_diagnostic - llmod = Module.from_string("".join(fileinput.input()).expandtabs(), engine=engine).llvm_ir + source = "".join(fileinput.input()) + source = source.replace("#ARTIQ#", "") + llmod = Module.from_string(source.expandtabs(), engine=engine).llvm_ir lltarget = llvm.Target.from_default_triple() llmachine = lltarget.create_target_machine() diff --git a/lit-test/compiler/integration/arithmetics.py b/lit-test/compiler/integration/arithmetics.py index 8a278aff6..b59d03c91 100644 --- a/lit-test/compiler/integration/arithmetics.py +++ b/lit-test/compiler/integration/arithmetics.py @@ -1,4 +1,5 @@ # RUN: %python -m artiq.compiler.testbench.jit %s +# RUN: %python %s assert -(-1) == 1 assert -(-1.0) == 1.0 @@ -28,7 +29,7 @@ assert 9.0 ** 0.5 == 3.0 assert 1 << 1 == 2 assert 2 >> 1 == 1 assert -2 >> 1 == -1 -assert 1 << 32 == 0 +#ARTIQ#assert 1 << 32 == 0 assert -1 >> 32 == -1 assert 0x18 & 0x0f == 0x08 assert 0x18 | 0x0f == 0x1f diff --git a/lit-test/compiler/integration/attribute.py b/lit-test/compiler/integration/attribute.py index 672d02ef3..301243b54 100644 --- a/lit-test/compiler/integration/attribute.py +++ b/lit-test/compiler/integration/attribute.py @@ -1,4 +1,5 @@ # RUN: %python -m artiq.compiler.testbench.jit %s +# RUN: %python %s r = range(10) assert r.start == 0 diff --git a/lit-test/compiler/integration/bool.py b/lit-test/compiler/integration/bool.py index 9df8b97c2..1a68ebd1c 100644 --- a/lit-test/compiler/integration/bool.py +++ b/lit-test/compiler/integration/bool.py @@ -1,4 +1,5 @@ # RUN: %python -m artiq.compiler.testbench.jit %s +# RUN: %python %s assert (not 0) == True assert (not 1) == False diff --git a/lit-test/compiler/integration/builtin.py b/lit-test/compiler/integration/builtin.py index 20296fc8a..256abe76e 100644 --- a/lit-test/compiler/integration/builtin.py +++ b/lit-test/compiler/integration/builtin.py @@ -1,24 +1,25 @@ # RUN: %python -m artiq.compiler.testbench.jit %s +# RUN: %python %s assert bool() is False # bool(x) is tested in bool.py assert int() is 0 assert int(1.0) is 1 -assert int(1, width=64) << 40 is 1099511627776 +#ARTIQ#assert int(1, width=64) << 40 is 1099511627776 -assert float() is 0.0 -assert float(1) is 1.0 +#ARTIQ#assert float() is 0.0 +#ARTIQ#assert float(1) is 1.0 x = list() if False: x = [1] assert x == [] -assert range(10) is range(0, 10, 1) -assert range(1, 10) is range(1, 10, 1) +#ARTIQ#assert range(10) is range(0, 10, 1) +#ARTIQ#assert range(1, 10) is range(1, 10, 1) assert len([1, 2, 3]) is 3 assert len(range(10)) is 10 assert len(range(0, 10, 2)) is 5 -assert round(1.4) is 1 and round(1.6) is 2 +#ARTIQ#assert round(1.4) is 1 and round(1.6) is 2 diff --git a/lit-test/compiler/integration/compare.py b/lit-test/compiler/integration/compare.py index 000c9d8bf..48a33cc09 100644 --- a/lit-test/compiler/integration/compare.py +++ b/lit-test/compiler/integration/compare.py @@ -1,4 +1,5 @@ # RUN: %python -m artiq.compiler.testbench.jit %s +# RUN: %python %s assert 1 < 2 and not (2 < 1) assert 2 > 1 and not (1 > 2) @@ -11,7 +12,7 @@ assert 1 is not 2 and not (1 is not 1) x, y = [1], [1] assert x is x and x is not y -assert range(10) is range(10) and range(10) is not range(11) +#ARTIQ#assert range(10) is range(10) and range(10) is not range(11) lst = [1, 2, 3] assert 1 in lst and 0 not in lst diff --git a/lit-test/compiler/integration/for.py b/lit-test/compiler/integration/for.py index 9597c4de6..9c305f5da 100644 --- a/lit-test/compiler/integration/for.py +++ b/lit-test/compiler/integration/for.py @@ -1,4 +1,5 @@ # RUN: %python -m artiq.compiler.testbench.jit %s +# RUN: %python %s count = 0 for x in range(10): diff --git a/lit-test/compiler/integration/function.py b/lit-test/compiler/integration/function.py index e1ae25fd9..bbaca2083 100644 --- a/lit-test/compiler/integration/function.py +++ b/lit-test/compiler/integration/function.py @@ -1,4 +1,5 @@ # RUN: %python -m artiq.compiler.testbench.jit %s +# RUN: %python %s def fib(x): if x == 1: diff --git a/lit-test/compiler/integration/if.py b/lit-test/compiler/integration/if.py index 8a282a594..fab6c3df0 100644 --- a/lit-test/compiler/integration/if.py +++ b/lit-test/compiler/integration/if.py @@ -1,4 +1,5 @@ # RUN: %python -m artiq.compiler.testbench.jit %s +# RUN: %python %s if True: assert True diff --git a/lit-test/compiler/integration/lambda.py b/lit-test/compiler/integration/lambda.py index 7bbe8824f..a1f08763a 100644 --- a/lit-test/compiler/integration/lambda.py +++ b/lit-test/compiler/integration/lambda.py @@ -1,4 +1,5 @@ # RUN: %python -m artiq.compiler.testbench.jit %s +# RUN: %python %s assert (lambda: 1)() == 1 assert (lambda x: x)(1) == 1 diff --git a/lit-test/compiler/integration/list.py b/lit-test/compiler/integration/list.py index d843b93ae..660293db7 100644 --- a/lit-test/compiler/integration/list.py +++ b/lit-test/compiler/integration/list.py @@ -1,4 +1,5 @@ # RUN: %python -m artiq.compiler.testbench.jit %s +# RUN: %python %s [x, y] = [1, 2] assert (x, y) == (1, 2) diff --git a/lit-test/compiler/integration/locals.py b/lit-test/compiler/integration/locals.py index cc2c1f1be..6ad9b0763 100644 --- a/lit-test/compiler/integration/locals.py +++ b/lit-test/compiler/integration/locals.py @@ -1,4 +1,5 @@ # RUN: %python -m artiq.compiler.testbench.jit %s +# RUN: %python %s x = 1 assert x == 1 diff --git a/lit-test/compiler/integration/subscript.py b/lit-test/compiler/integration/subscript.py index 14cbd7529..15b3651e8 100644 --- a/lit-test/compiler/integration/subscript.py +++ b/lit-test/compiler/integration/subscript.py @@ -1,4 +1,5 @@ # RUN: %python -m artiq.compiler.testbench.jit %s +# RUN: %python %s lst = list(range(10)) assert lst[0] == 0 diff --git a/lit-test/compiler/integration/tuple.py b/lit-test/compiler/integration/tuple.py index 862154c9f..5d6c153dd 100644 --- a/lit-test/compiler/integration/tuple.py +++ b/lit-test/compiler/integration/tuple.py @@ -1,4 +1,5 @@ # RUN: %python -m artiq.compiler.testbench.jit %s +# RUN: %python %s x, y = 2, 1 x, y = y, x diff --git a/lit-test/compiler/integration/while.py b/lit-test/compiler/integration/while.py index fea81fadc..7cd2ac626 100644 --- a/lit-test/compiler/integration/while.py +++ b/lit-test/compiler/integration/while.py @@ -1,4 +1,5 @@ # RUN: %python -m artiq.compiler.testbench.jit %s +# RUN: %python %s cond, count = True, 0 while cond: diff --git a/lit-test/harness.py b/lit-test/harness.py index 9821ae61f..955394c3b 100644 --- a/lit-test/harness.py +++ b/lit-test/harness.py @@ -12,7 +12,7 @@ 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, required=True, +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:]') @@ -21,5 +21,11 @@ args = parser.parse_args(sys.argv[1:]) artiq_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) sys.path.insert(1, artiq_path) -sys.argv[1:] = args.args -importlib.import_module(args.m).main() +if args.m: + sys.argv[1:] = args.args + importlib.import_module(args.m).main() +else: + sys.argv[1:] = args.args[1:] + with open(args.args[0]) as f: + code = compile(f.read(), args.args[0], 'exec') + exec(code)