mirror of https://github.com/m-labs/artiq.git
artiq/test/{not,harness}.py: usual CLI handling
This commit is contained in:
parent
d7e4783cae
commit
a1201252e2
|
@ -11,21 +11,25 @@ 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,
|
||||
def main():
|
||||
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='+',
|
||||
parser.add_argument('args', type=str, nargs='+',
|
||||
help='arguments passed to program in sys.argv[1:]')
|
||||
args = parser.parse_args(sys.argv[1:])
|
||||
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)
|
||||
artiq_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
||||
sys.path.insert(1, artiq_path)
|
||||
|
||||
if args.m:
|
||||
if args.m:
|
||||
sys.argv[1:] = args.args
|
||||
importlib.import_module(args.m).main()
|
||||
else:
|
||||
else:
|
||||
sys.argv[1:] = args.args[1:]
|
||||
with open(args.args[0]) as f:
|
||||
code = compile(f.read(), args.args[0], 'exec')
|
||||
exec(code)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -1,2 +1,7 @@
|
|||
import sys, subprocess
|
||||
exit(not subprocess.call(sys.argv[1:]))
|
||||
|
||||
def main():
|
||||
exit(not subprocess.call(sys.argv[1:]))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Reference in New Issue