1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-18 11:53:59 -05:00

move js unit tests to cli/tests (#5678)

This commit is contained in:
Ryan Dahl 2020-05-20 17:52:51 -04:00 committed by GitHub
parent 49dda23f6b
commit 30702e2678
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
71 changed files with 14 additions and 14 deletions

View file

@ -400,7 +400,7 @@ fn js_unit_tests() {
.arg("--unstable") .arg("--unstable")
.arg("--reload") .arg("--reload")
.arg("-A") .arg("-A")
.arg("cli/js/tests/unit_test_runner.ts") .arg("cli/tests/unit/unit_test_runner.ts")
.arg("--master") .arg("--master")
.arg("--verbose") .arg("--verbose")
.env("NO_COLOR", "1") .env("NO_COLOR", "1")

View file

@ -42,7 +42,7 @@ ways:
`unit_test_runner.ts` is the main script used to run unit tests. `unit_test_runner.ts` is the main script used to run unit tests.
Runner discovers required permissions combinations by loading Runner discovers required permissions combinations by loading
`cli/js/tests/unit_tests.ts` and going through all registered instances of `cli/tests/unit/unit_tests.ts` and going through all registered instances of
`unitTest`. `unitTest`.
There are three ways to run `unit_test_runner.ts`: There are three ways to run `unit_test_runner.ts`:
@ -50,27 +50,27 @@ There are three ways to run `unit_test_runner.ts`:
``` ```
# Run all tests. Spawns worker processes for each discovered permission # Run all tests. Spawns worker processes for each discovered permission
# combination: # combination:
target/debug/deno run -A cli/js/tests/unit_test_runner.ts --master target/debug/deno run -A cli/tests/unit/unit_test_runner.ts --master
# By default all output of worker processes is discarded; for debug purposes # By default all output of worker processes is discarded; for debug purposes
# the --verbose flag preserves output from the worker # the --verbose flag preserves output from the worker
target/debug/deno run -A cli/js/tests/unit_test_runner.ts --master --verbose target/debug/deno run -A cli/tests/unit/unit_test_runner.ts --master --verbose
# Run subset of tests that don't require any permissions # Run subset of tests that don't require any permissions
target/debug/deno run --unstable cli/js/tests/unit_test_runner.ts target/debug/deno run --unstable cli/tests/unit/unit_test_runner.ts
# Run subset tests that require "net" and "read" permissions # Run subset tests that require "net" and "read" permissions
target/debug/deno run --unstable --allow-net --allow-read cli/js/tests/unit_test_runner.ts target/debug/deno run --unstable --allow-net --allow-read cli/tests/unit/unit_test_runner.ts
# "worker" mode communicates with parent using TCP socket on provided address; # "worker" mode communicates with parent using TCP socket on provided address;
# after initial setup drops permissions to specified set. It shouldn't be used # after initial setup drops permissions to specified set. It shouldn't be used
# directly, only be "master" process. # directly, only be "master" process.
target/debug/deno run -A cli/js/tests/unit_test_runner.ts --worker --addr=127.0.0.1:4500 --perms=net,write,run target/debug/deno run -A cli/tests/unit/unit_test_runner.ts --worker --addr=127.0.0.1:4500 --perms=net,write,run
# Run specific tests # Run specific tests
target/debug/deno run --unstable --allow-net cli/js/tests/unit_test_runner.ts -- netTcpListenClose target/debug/deno run --unstable --allow-net cli/tests/unit/unit_test_runner.ts -- netTcpListenClose
RUST_BACKTRACE=1 cargo run -- run --unstable --allow-read --allow-write cli/js/tests/unit_test_runner.ts -- netUnixDialListen RUST_BACKTRACE=1 cargo run -- run --unstable --allow-read --allow-write cli/tests/unit/unit_test_runner.ts -- netUnixDialListen
``` ```
### Http server ### Http server

View file

@ -327,12 +327,12 @@ unitTest(function permissionsMatches(): void {
/* /*
* Ensure all unit test files (e.g. xxx_test.ts) are present as imports in * Ensure all unit test files (e.g. xxx_test.ts) are present as imports in
* cli/js/tests/unit_tests.ts as it is easy to miss this out * cli/tests/unit/unit_tests.ts as it is easy to miss this out
*/ */
unitTest( unitTest(
{ perms: { read: true } }, { perms: { read: true } },
function assertAllUnitTestFilesImported(): void { function assertAllUnitTestFilesImported(): void {
const directoryTestFiles = [...Deno.readDirSync("./cli/js/tests/")] const directoryTestFiles = [...Deno.readDirSync("./cli/tests/unit/")]
.map((k) => k.name) .map((k) => k.name)
.filter( .filter(
(file) => (file) =>
@ -342,7 +342,7 @@ unitTest(
!file!.endsWith("unit_test_runner.ts") !file!.endsWith("unit_test_runner.ts")
); );
const unitTestsFile: Uint8Array = Deno.readFileSync( const unitTestsFile: Uint8Array = Deno.readFileSync(
"./cli/js/tests/unit_tests.ts" "./cli/tests/unit/unit_tests.ts"
); );
const importLines = new TextDecoder("utf-8") const importLines = new TextDecoder("utf-8")
.decode(unitTestsFile) .decode(unitTestsFile)
@ -355,7 +355,7 @@ unitTest(
directoryTestFiles.forEach((dirFile) => { directoryTestFiles.forEach((dirFile) => {
if (!importedTestFiles.includes(dirFile!)) { if (!importedTestFiles.includes(dirFile!)) {
throw new Error( throw new Error(
"cil/js/tests/unit_tests.ts is missing import of test file: cli/js/" + "cil/tests/unit/unit_tests.ts is missing import of test file: cli/js/" +
dirFile dirFile
); );
} }

View file

@ -96,7 +96,7 @@ function spawnWorkerRunner(
"run", "run",
"--unstable", // TODO(ry) be able to test stable vs unstable "--unstable", // TODO(ry) be able to test stable vs unstable
"-A", "-A",
"cli/js/tests/unit_test_runner.ts", "cli/tests/unit/unit_test_runner.ts",
"--worker", "--worker",
`--addr=${addr}`, `--addr=${addr}`,
`--perms=${permStr}`, `--perms=${permStr}`,