diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-02-01 18:29:00 -0500 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-02-02 17:48:43 -0500 |
commit | 18b815e33627865b8f4d13f29e2e6e4dc7670f1d (patch) | |
tree | 7ee1b9af60fa161ef4356ae28ecf7e2c94a5cb0e /tools/fmt_test.py | |
parent | f84da880bb5bd8fadd7c884ecfeb48aa5b7b9c08 (diff) |
Support --fmt
Diffstat (limited to 'tools/fmt_test.py')
-rwxr-xr-x | tools/fmt_test.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tools/fmt_test.py b/tools/fmt_test.py new file mode 100755 index 000000000..95733dc20 --- /dev/null +++ b/tools/fmt_test.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. +import os +import sys +from util import mkdtemp, root_path, tests_path, run, green_ok +import shutil + + +def fmt_test(deno_exe): + sys.stdout.write("fmt_test...") + sys.stdout.flush() + d = mkdtemp() + try: + fixed_filename = os.path.join(tests_path, "badly_formatted_fixed.js") + src = os.path.join(tests_path, "badly_formatted.js") + dst = os.path.join(d, "badly_formatted.js") + shutil.copyfile(src, dst) + # Set DENO_DIR to //js/ so we don't have to rely on an intenet + # connection to download https://deno.land/x/std/prettier/main.ts + deno_dir = os.path.join(root_path, "js") + run([deno_exe, dst, "--fmt"], merge_env={"DENO_DIR": deno_dir}) + with open(fixed_filename) as f: + expected = f.read() + with open(dst) as f: + actual = f.read() + assert expected == actual + finally: + shutil.rmtree(d) + print green_ok() + + +if __name__ == "__main__": + fmt_test(sys.argv[1]) + |