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

Reorg tests #2955

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
members = [
"cli",
"cli/tty_tests",
"core",
"tools/hyper_hello",
"deno_typescript",
Expand Down
2 changes: 2 additions & 0 deletions cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ extern crate url;

#[cfg(test)]
mod integration_tests;
#[cfg(test)]
mod misc_tests;

mod ansi;
mod assets;
Expand Down
63 changes: 63 additions & 0 deletions cli/misc_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
use std::process::Command;

fn run_python_script(script: &str) -> bool {
let mut child = Command::new("python")
.current_dir("../")
.arg(script)
.spawn()
.expect("failed to spawn script");

let ecode = child.wait().expect("failed to wait for the child process");

ecode.success()
}

#[test]
fn benchmark_test() {
assert!(run_python_script("tools/benchmark_test.py"))
}

#[test]
fn deno_dir_test() {
assert!(run_python_script("tools/deno_dir_test.py"))
}

// TODO(#2933): Rewrite this test in rust.
#[test]
fn fetch_test() {
assert!(run_python_script("tools/fetch_test.py"))
}

// TODO(#2933): Rewrite this test in rust.
#[test]
fn fmt_test() {
assert!(run_python_script("tools/fmt_test.py"))
}

// TODO(#2933): Rewrite this test in rust.
#[test]
fn js_unit_tests() {
assert!(run_python_script("tools/unit_tests.py"))
}

// TODO(#2933): Rewrite this test in rust.
#[test]
fn repl_test() {
assert!(run_python_script("tools/repl_test.py"))
}

#[test]
fn setup_test() {
assert!(run_python_script("tools/setup_test.py"))
}

#[test]
fn target_test() {
assert!(run_python_script("tools/target_test.py"))
}

#[test]
fn util_test() {
assert!(run_python_script("tools/util_test.py"))
}
8 changes: 8 additions & 0 deletions cli/tty_tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
[lib]
path = "lib.rs"

[package]
name = "deno_tty_tests"
version = "0.18.0"
edition = "2018"
23 changes: 23 additions & 0 deletions cli/tty_tests/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
use std::process::Command;

pub fn run_python_script(script: &str) -> bool {
let mut child = Command::new("python")
.current_dir("../../")
.arg(script)
.spawn()
.expect("failed to spawn script");

let ecode = child.wait().expect("failed to wait for the child process");

ecode.success()
}

// TODO(#2933): Rewrite these tests in rust.
#[test]
fn tty_tests() {
// FIXME: These tests can't run in parallel.
ry marked this conversation as resolved.
Show resolved Hide resolved
assert!(run_python_script("tools/complex_permissions_test.py"));
assert!(run_python_script("tools/is_tty_test.py"));
assert!(run_python_script("tools/permission_prompt_test.py"));
}
3 changes: 1 addition & 2 deletions tools/complex_permissions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,4 @@ def complex_permissions_tests():


if __name__ == "__main__":
with http_server.spawn():
run_tests()
run_tests()
3 changes: 1 addition & 2 deletions tools/fetch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ def test_fetch(self):


if __name__ == "__main__":
with http_server.spawn():
run_tests()
run_tests()
8 changes: 0 additions & 8 deletions tools/target_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ def _test(self, executable):
self.check_exists(bin_file)
run([bin_file], quiet=True)

def test_cargo_test(self):
cargo_test = ["cargo", "test", "--all", "--locked"]
if "DENO_BUILD_MODE" in os.environ and \
os.environ["DENO_BUILD_MODE"] == "release":
run(cargo_test + ["--release"])
else:
run(cargo_test)

def test_libdeno(self):
self._test("libdeno_test")

Expand Down
46 changes: 10 additions & 36 deletions tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,9 @@
# Usage: ./tools/test.py out/Debug
import os

from benchmark_test import TestBenchmark
from deno_dir_test import TestDenoDir
from fetch_test import TestFetch
from fmt_test import TestFmt
from repl_test import TestRepl
from setup_test import TestSetup
from target_test import TestTarget
from unit_tests import JsUnitTests
from util_test import TestUtil
# NOTE: These tests are skipped on Windows
from is_tty_test import TestIsTty
from permission_prompt_test import permission_prompt_tests
from complex_permissions_test import complex_permissions_tests

import http_server
from util import (enable_ansi_colors, build_path, RESET, FG_RED, FG_GREEN,
executable_suffix, rmtree, tests_path)
from test_util import parse_test_args, run_tests
from util import enable_ansi_colors, rmtree, run
from test_util import parse_test_args


def main():
Expand All @@ -34,25 +19,14 @@ def main():

enable_ansi_colors()

test_cases = [
TestSetup,
TestUtil,
TestTarget,
JsUnitTests,
TestFetch,
TestRepl,
TestDenoDir,
TestBenchmark,
TestIsTty,
]
test_cases += permission_prompt_tests()
test_cases += complex_permissions_tests()
# It is very slow, so do TestFmt at the end.
test_cases += [TestFmt]

with http_server.spawn():
run_tests(test_cases)
ry marked this conversation as resolved.
Show resolved Hide resolved
cargo_test = ["cargo", "test", "--locked"]
if "DENO_BUILD_MODE" in os.environ and \
os.environ["DENO_BUILD_MODE"] == "release":
run(cargo_test + ["--release"])
else:
run(cargo_test)


if __name__ == '__main__':
main()
with http_server.spawn():
ry marked this conversation as resolved.
Show resolved Hide resolved
main()
3 changes: 1 addition & 2 deletions tools/unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ def test_unit_test_runner(self):


if __name__ == '__main__':
with http_server.spawn():
run_tests()
run_tests()