summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml7
-rw-r--r--src/from_filesystem.cc2
-rw-r--r--tests/001_hello.js (renamed from testdata/001_hello.js)0
-rw-r--r--tests/001_hello.js.out1
-rw-r--r--tests/002_hello.ts (renamed from testdata/002_hello.ts)0
-rw-r--r--tests/002_hello.ts.out1
-rwxr-xr-xtools/check_output_test.py41
-rwxr-xr-xtools/test.py41
-rw-r--r--tools/util.py9
9 files changed, 90 insertions, 12 deletions
diff --git a/.travis.yml b/.travis.yml
index 4549b5bfd..8c819d78d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -47,9 +47,4 @@ install:
- ninja -j2 -C $BUILD_PATH :all
script:
- ./tools/lint.py
- - $BUILD_PATH/test_cc
- - $BUILD_PATH/handlers_test
- - $BUILD_PATH/deno ./testdata/001_hello.js
- - $BUILD_PATH/deno ./testdata/002_hello.ts
- - $BUILD_PATH/deno_ns ./testdata/001_hello.js
- - $BUILD_PATH/deno_ns ./testdata/002_hello.ts
+ - ./tools/test.py $BUILD_PATH
diff --git a/src/from_filesystem.cc b/src/from_filesystem.cc
index bf63ef46f..3a3de85c6 100644
--- a/src/from_filesystem.cc
+++ b/src/from_filesystem.cc
@@ -15,8 +15,6 @@
namespace deno {
Deno* NewFromFileSystem(void* data, deno_recv_cb cb) {
- printf("load bundle " BUNDLE_LOCATION "\n");
-
std::string js_source;
CHECK(deno::ReadFileToString(BUNDLE_LOCATION, &js_source));
diff --git a/testdata/001_hello.js b/tests/001_hello.js
index accefceba..accefceba 100644
--- a/testdata/001_hello.js
+++ b/tests/001_hello.js
diff --git a/tests/001_hello.js.out b/tests/001_hello.js.out
new file mode 100644
index 000000000..557db03de
--- /dev/null
+++ b/tests/001_hello.js.out
@@ -0,0 +1 @@
+Hello World
diff --git a/testdata/002_hello.ts b/tests/002_hello.ts
index accefceba..accefceba 100644
--- a/testdata/002_hello.ts
+++ b/tests/002_hello.ts
diff --git a/tests/002_hello.ts.out b/tests/002_hello.ts.out
new file mode 100644
index 000000000..557db03de
--- /dev/null
+++ b/tests/002_hello.ts.out
@@ -0,0 +1 @@
+Hello World
diff --git a/tools/check_output_test.py b/tools/check_output_test.py
new file mode 100755
index 000000000..c8b01952d
--- /dev/null
+++ b/tools/check_output_test.py
@@ -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))
diff --git a/tools/test.py b/tools/test.py
new file mode 100755
index 000000000..e62efd0f6
--- /dev/null
+++ b/tools/test.py
@@ -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))
diff --git a/tools/util.py b/tools/util.py
index 8a65f2ede..4141396df 100644
--- a/tools/util.py
+++ b/tools/util.py
@@ -3,6 +3,8 @@
import os
import subprocess
+executable_suffix = ".exe" if os.name == "nt" else ""
+
def run(args, quiet=False, envs={}):
if not quiet:
@@ -10,10 +12,9 @@ def run(args, quiet=False, envs={}):
env = os.environ.copy()
for key in envs.keys():
env[key] = envs[key]
- if os.name == "nt":
- # Run through shell to make .bat/.cmd files work.
- args = ["cmd", "/c"] + args
- subprocess.check_call(args, env=env)
+ args[0] = os.path.normpath(args[0])
+ shell = os.name == "nt" # Run through shell to make .bat/.cmd files work.
+ subprocess.check_call(args, env=env, shell=shell)
def remove_and_symlink(target, name, target_is_dir=False):