Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

housekeeping: developer cli #166

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions scripts/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import argparse
from os import system

def compile_one(file, trace):
trace = "RUST_LOG=trace " if trace else ""
system(f"{trace}env UPDATE_EXPECT=1 cargo test --package cranelift-filetests --lib -- test_zkasm::tests::{file} --exact --nocapture")

def compile_all(trace):
trace = "RUST_LOG=trace " if trace else ""
system(f"{trace}env UPDATE_EXPECT=1 cargo test --package cranelift-filetests --lib -- test_zkasm::tests --nocapture")

def compile(file=None):
if file:
compile_one(file, trace=False)
else:
compile_all(trace=False)

def trace(file=None):
if file:
compile_one(file, trace=True)
else:
compile_all(trace=True)

def run(path):
system(f"npm test --prefix tests/zkasm \"../../{path}\"")

def diff():
system("./ci/test-all-zkasm.sh")

def update():
system("./ci/test-all-zkasm.sh --update")

def main():
parser = argparse.ArgumentParser(description="Developer Tool CLI")

parser.add_argument("-c", "--compile", nargs="?", const=True, help="Compile given test or all files")
parser.add_argument("-t", "--trace", nargs="?", const=True, help="Same as compile, but print trace of compilation")
parser.add_argument("-r", "--run", help="Run files in a folder with verbose errors")
parser.add_argument("-d", "--diff", action="store_true", help="Print diff of current state and state in csv's")
parser.add_argument("-u", "--update", action="store_true", help="Update csv's")

parser.epilog = "Path for run shoud be provided assuming you are in wasmtime directory. For example cranelift/zkasm_data/spectest/i64/generated. For compile/trace you should provide name of test in test_zkasm.rs"

args = parser.parse_args()

if args.compile is not None:
if args.compile is True:
compile()
else:
compile(args.compile)
elif args.run:
run(args.run)
elif args.diff:
diff()
elif args.update:
update()
elif args.trace:
trace()
else:
parser.print_help()

if __name__ == "__main__":
main()