diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 9a35ba3005..ff3777626c 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -12,6 +12,36 @@ use std::io::BufRead; use std::process::Command; use tempfile::TempDir; +#[test] +fn no_color() { + let output = util::deno_cmd() + .current_dir(util::root_path()) + .arg("run") + .arg("cli/tests/no_color.js") + .env("NO_COLOR", "1") + .stdout(std::process::Stdio::piped()) + .spawn() + .unwrap() + .wait_with_output() + .unwrap(); + assert!(output.status.success()); + let stdout_str = std::str::from_utf8(&output.stdout).unwrap().trim(); + assert_eq!("noColor true", stdout_str); + + let output = util::deno_cmd() + .current_dir(util::root_path()) + .arg("run") + .arg("cli/tests/no_color.js") + .stdout(std::process::Stdio::piped()) + .spawn() + .unwrap() + .wait_with_output() + .unwrap(); + assert!(output.status.success()); + let stdout_str = std::str::from_utf8(&output.stdout).unwrap().trim(); + assert_eq!("noColor false", stdout_str); +} + // TODO re-enable. This hangs on macOS // https://github.com/denoland/deno/issues/4262 #[cfg(unix)] @@ -780,11 +810,6 @@ fn repl_test_assign_underscore_error() { assert_eq!(err, "Thrown: 2\n"); } -#[test] -fn target_test() { - util::run_python_script("tools/target_test.py") -} - #[test] fn util_test() { util::run_python_script("tools/util_test.py") diff --git a/tools/target_test.py b/tools/target_test.py deleted file mode 100644 index 690ae2dc92..0000000000 --- a/tools/target_test.py +++ /dev/null @@ -1,36 +0,0 @@ -import os -import sys - -from test_util import DenoTestCase, run_tests -from util import executable_suffix, tests_path, run, run_output - - -class TestTarget(DenoTestCase): - @staticmethod - def check_exists(filename): - if not os.path.exists(filename): - print "Required target doesn't exist:", filename - sys.exit(1) - - def test_executable_exists(self): - self.check_exists(self.deno_exe) - - def _test(self, executable): - "Test executable runs and exits with code 0." - bin_file = os.path.join(self.build_dir, executable + executable_suffix) - self.check_exists(bin_file) - run([bin_file], quiet=True) - - def test_no_color(self): - t = os.path.join(tests_path, "no_color.js") - result = run_output([self.deno_exe, "run", t], - merge_env={"NO_COLOR": "1"}, - quiet=True) - assert result.out.strip() == "noColor true" - t = os.path.join(tests_path, "no_color.js") - result = run_output([self.deno_exe, "run", t], quiet=True) - assert result.out.strip() == "noColor false" - - -if __name__ == "__main__": - run_tests() diff --git a/tools/util_test.py b/tools/util_test.py index 2d67701597..8c25b10ed2 100755 --- a/tools/util_test.py +++ b/tools/util_test.py @@ -37,6 +37,9 @@ class TestUtil(DenoTestCase): assert stats3['req_per_sec'] == 96037 assert stats3['max_latency'] == 6.36 + def test_executable_exists(self): + assert os.path.exists(self.deno_exe) + if __name__ == '__main__': run_tests()