forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tools/test.py test runner. (denoland#384)
- Loading branch information
Showing
9 changed files
with
90 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello World |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello World |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python | ||
# Given a deno executable, this script execute several integration tests | ||
# with it. The tests are stored in //tests/ and each script has a corresponding | ||
# .out file which specifies what the stdout should be. | ||
# | ||
# Usage: check_output_test.py [path to deno executable] | ||
import os | ||
import sys | ||
import subprocess | ||
|
||
root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) | ||
tests_path = os.path.join(root_path, "tests") | ||
|
||
|
||
def check_output_test(deno_exe_filename): | ||
assert os.path.isfile(deno_exe_filename) | ||
outs = [ | ||
filename for filename in os.listdir(tests_path) | ||
if filename.endswith(".out") | ||
] | ||
assert len(outs) > 1 | ||
tests = [(os.path.splitext(filename)[0], filename) for filename in outs] | ||
for (script, out_filename) in tests: | ||
script_abs = os.path.join(tests_path, script) | ||
out_abs = os.path.join(tests_path, out_filename) | ||
with open(out_abs, 'r') as f: | ||
expected_out = f.read() | ||
cmd = [deno_exe_filename, script_abs] | ||
print " ".join(cmd) | ||
actual_out = subprocess.check_output(cmd) | ||
if expected_out != actual_out: | ||
print "Expected output does not match actual." | ||
sys.exit(1) | ||
|
||
|
||
def main(argv): | ||
check_output_test(argv[1]) | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main(sys.argv)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python | ||
# Runs the full test suite. | ||
# Usage: ./tools/test.py out/Debug | ||
import os | ||
import sys | ||
from check_output_test import check_output_test | ||
from util import executable_suffix, run | ||
|
||
|
||
def check_exists(filename): | ||
if not os.path.exists(filename): | ||
print "Required target doesn't exist:", filename | ||
print "Build target :all" | ||
sys.exit(1) | ||
|
||
|
||
def main(argv): | ||
if len(argv) != 2: | ||
print "Usage: tools/test.py [build dir]" | ||
sys.exit(1) | ||
build_dir = argv[1] | ||
|
||
test_cc = os.path.join(build_dir, "test_cc" + executable_suffix) | ||
check_exists(test_cc) | ||
run([test_cc]) | ||
|
||
handlers_test = os.path.join(build_dir, "handlers_test" + executable_suffix) | ||
check_exists(handlers_test) | ||
run([handlers_test]) | ||
|
||
deno_exe = os.path.join(build_dir, "deno" + executable_suffix) | ||
check_exists(deno_exe) | ||
check_output_test(deno_exe) | ||
|
||
deno_ns_exe = os.path.join(build_dir, "deno_ns" + executable_suffix) | ||
check_exists(deno_ns_exe) | ||
check_output_test(deno_ns_exe) | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main(sys.argv)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters