mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 04:51:22 +00:00
test: rewrite some ignored tests to spec tests (#25652)
Ref https://github.com/denoland/deno/issues/25241 Rewritten these tests: - check::package_json_basic - check::package_json_fail_check - check::package_json_with_deno_json - info::package_json_basic - test::package_json_basic - run::package_json_auto_discovered_for_npm_binary - run::package_json_with_deno_json
This commit is contained in:
parent
8fa92228bb
commit
968f441da3
@ -246,39 +246,6 @@ itest!(check_dts {
|
||||
exit_code: 1,
|
||||
});
|
||||
|
||||
// TODO(2.0): this should be rewritten to a spec test and first run `deno install`
|
||||
// itest!(package_json_basic {
|
||||
// args: "check main.ts",
|
||||
// output: "package_json/basic/main.check.out",
|
||||
// envs: env_vars_for_npm_tests(),
|
||||
// http_server: true,
|
||||
// cwd: Some("package_json/basic"),
|
||||
// copy_temp_dir: Some("package_json/basic"),
|
||||
// exit_code: 0,
|
||||
// });
|
||||
|
||||
// TODO(2.0): this should be rewritten to a spec test and first run `deno install`
|
||||
// itest!(package_json_fail_check {
|
||||
// args: "check --quiet fail_check.ts",
|
||||
// output: "package_json/basic/fail_check.check.out",
|
||||
// envs: env_vars_for_npm_tests(),
|
||||
// http_server: true,
|
||||
// cwd: Some("package_json/basic"),
|
||||
// copy_temp_dir: Some("package_json/basic"),
|
||||
// exit_code: 1,
|
||||
// });
|
||||
|
||||
// TODO(2.0): this should be rewritten to a spec test and first run `deno install`
|
||||
// itest!(package_json_with_deno_json {
|
||||
// args: "check --quiet main.ts",
|
||||
// output: "package_json/deno_json/main.check.out",
|
||||
// cwd: Some("package_json/deno_json/"),
|
||||
// copy_temp_dir: Some("package_json/deno_json/"),
|
||||
// envs: env_vars_for_npm_tests(),
|
||||
// http_server: true,
|
||||
// exit_code: 1,
|
||||
// });
|
||||
|
||||
#[test]
|
||||
fn check_error_in_dep_then_fix() {
|
||||
let test_context = TestContextBuilder::new().use_temp_cwd().build();
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
use test_util as util;
|
||||
use test_util::itest;
|
||||
// use util::env_vars_for_npm_tests;
|
||||
use util::TestContextBuilder;
|
||||
|
||||
#[test]
|
||||
@ -110,17 +109,6 @@ itest!(with_config_override {
|
||||
output: "info/with_config/with_config.out",
|
||||
});
|
||||
|
||||
// TODO(2.0): this test should be a spec test and first run `deno install`
|
||||
// itest!(package_json_basic {
|
||||
// args: "info --quiet main.ts",
|
||||
// output: "package_json/basic/main.info.out",
|
||||
// envs: env_vars_for_npm_tests(),
|
||||
// http_server: true,
|
||||
// cwd: Some("package_json/basic"),
|
||||
// copy_temp_dir: Some("package_json/basic"),
|
||||
// exit_code: 0,
|
||||
// });
|
||||
|
||||
itest!(info_import_map {
|
||||
args: "info preact/debug",
|
||||
output: "info/with_import_map/with_import_map.out",
|
||||
|
@ -3359,42 +3359,6 @@ itest!(
|
||||
}
|
||||
);
|
||||
|
||||
// TODO(2.0): this should be rewritten to a spec test and first run `deno install`
|
||||
// itest!(package_json_auto_discovered_for_npm_binary {
|
||||
// args: "run -L debug -A npm:@denotest/bin/cli-esm this is a test",
|
||||
// output: "run/with_package_json/npm_binary/main.out",
|
||||
// cwd: Some("run/with_package_json/npm_binary/"),
|
||||
// copy_temp_dir: Some("run/with_package_json/"),
|
||||
// envs: env_vars_for_npm_tests(),
|
||||
// http_server: true,
|
||||
// });
|
||||
|
||||
// TODO(2.0): this should be rewritten to a spec test and first run `deno install`
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn package_json_with_deno_json() {
|
||||
let context = TestContextBuilder::for_npm()
|
||||
.use_copy_temp_dir("package_json/deno_json/")
|
||||
.cwd("package_json/deno_json/")
|
||||
.build();
|
||||
let output = context.new_command().args("run --quiet -A main.ts").run();
|
||||
output.assert_matches_file("package_json/deno_json/main.out");
|
||||
|
||||
assert!(context
|
||||
.temp_dir()
|
||||
.path()
|
||||
.join("package_json/deno_json/deno.lock")
|
||||
.exists());
|
||||
|
||||
// run again and ensure the top level install doesn't happen twice
|
||||
let output = context
|
||||
.new_command()
|
||||
.args("run --log-level=debug -A main.ts")
|
||||
.run();
|
||||
let output = output.combined_output();
|
||||
assert_contains!(output, "Skipping top level install.");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn package_json_no_node_modules_dir_created() {
|
||||
// it should not create a node_modules directory
|
||||
|
@ -6,7 +6,6 @@ use test_util as util;
|
||||
use test_util::itest;
|
||||
use util::assert_contains;
|
||||
use util::assert_not_contains;
|
||||
// use util::env_vars_for_npm_tests;
|
||||
use util::wildcard_match;
|
||||
use util::TestContext;
|
||||
use util::TestContextBuilder;
|
||||
@ -599,17 +598,6 @@ fn sigint_with_hanging_test() {
|
||||
);
|
||||
}
|
||||
|
||||
// TODO(2.0): this should be rewritten to a spec test and first run `deno install`
|
||||
// itest!(package_json_basic {
|
||||
// args: "test",
|
||||
// output: "package_json/basic/lib.test.out",
|
||||
// envs: env_vars_for_npm_tests(),
|
||||
// http_server: true,
|
||||
// cwd: Some("package_json/basic"),
|
||||
// copy_temp_dir: Some("package_json/basic"),
|
||||
// exit_code: 0,
|
||||
// });
|
||||
|
||||
itest!(test_replace_timers {
|
||||
args: "test test/replace_timers.js",
|
||||
output: "test/replace_timers.js.out",
|
||||
|
13
tests/specs/check/package_json/__test__.jsonc
Normal file
13
tests/specs/check/package_json/__test__.jsonc
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"tempDir": true,
|
||||
"steps": [
|
||||
{
|
||||
"args": "install",
|
||||
"output": "install.out"
|
||||
},
|
||||
{
|
||||
"args": "check main.ts",
|
||||
"output": "check.out"
|
||||
}
|
||||
]
|
||||
}
|
1
tests/specs/check/package_json/check.out
Normal file
1
tests/specs/check/package_json/check.out
Normal file
@ -0,0 +1 @@
|
||||
Check file://[WILDCARD]/main.ts
|
3
tests/specs/check/package_json/install.out
Normal file
3
tests/specs/check/package_json/install.out
Normal file
@ -0,0 +1,3 @@
|
||||
Download http://localhost:4260/@denotest/esm-basic
|
||||
Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz
|
||||
Initialize @denotest/esm-basic@1.0.0
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"tempDir": true,
|
||||
"steps": [
|
||||
{
|
||||
"args": "check main.ts",
|
||||
"output": "check.out"
|
||||
}
|
||||
]
|
||||
}
|
3
tests/specs/check/package_json_auto_install/deno.json
Normal file
3
tests/specs/check/package_json_auto_install/deno.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"nodeModulesDir": "auto"
|
||||
}
|
9
tests/specs/check/package_json_auto_install/lib.ts
Normal file
9
tests/specs/check/package_json_auto_install/lib.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import * as test from "@denotest/esm-basic";
|
||||
|
||||
export function add(a: number, b: number) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
export function getValue() {
|
||||
return test.getValue();
|
||||
}
|
3
tests/specs/check/package_json_auto_install/main.ts
Normal file
3
tests/specs/check/package_json_auto_install/main.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { getValue } from "./lib.ts";
|
||||
|
||||
console.log(getValue());
|
14
tests/specs/check/package_json_fail_check/__test__.jsonc
Normal file
14
tests/specs/check/package_json_fail_check/__test__.jsonc
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"tempDir": true,
|
||||
"steps": [
|
||||
{
|
||||
"args": "install",
|
||||
"output": "install.out"
|
||||
},
|
||||
{
|
||||
"args": "check --quiet fail_check.ts",
|
||||
"output": "fail_check.out",
|
||||
"exitCode": 1
|
||||
}
|
||||
]
|
||||
}
|
3
tests/specs/check/package_json_fail_check/install.out
Normal file
3
tests/specs/check/package_json_fail_check/install.out
Normal file
@ -0,0 +1,3 @@
|
||||
Download http://localhost:4260/@denotest/esm-basic
|
||||
Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz
|
||||
Initialize @denotest/esm-basic@1.0.0
|
9
tests/specs/check/package_json_fail_check/lib.ts
Normal file
9
tests/specs/check/package_json_fail_check/lib.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import * as test from "@denotest/esm-basic";
|
||||
|
||||
export function add(a: number, b: number) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
export function getValue() {
|
||||
return test.getValue();
|
||||
}
|
5
tests/specs/check/package_json_fail_check/package.json
Normal file
5
tests/specs/check/package_json_fail_check/package.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@denotest/esm-basic": "*"
|
||||
}
|
||||
}
|
14
tests/specs/check/package_json_with_deno_json/__test__.jsonc
Normal file
14
tests/specs/check/package_json_with_deno_json/__test__.jsonc
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"tempDir": true,
|
||||
"steps": [
|
||||
{
|
||||
"args": "install",
|
||||
"output": "install.out"
|
||||
},
|
||||
{
|
||||
"args": "check --quiet main.ts",
|
||||
"output": "check.out",
|
||||
"exitCode": 1
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
Download http://localhost:4260/@denotest/esm-basic
|
||||
Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz
|
||||
Initialize @denotest/esm-basic@1.0.0
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@denotest/esm-basic": "*"
|
||||
}
|
||||
}
|
13
tests/specs/info/package_json_basic/__test__.jsonc
Normal file
13
tests/specs/info/package_json_basic/__test__.jsonc
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"tempDir": true,
|
||||
"steps": [
|
||||
{
|
||||
"args": "install",
|
||||
"output": "install.out"
|
||||
},
|
||||
{
|
||||
"args": "info --quiet main.ts",
|
||||
"output": "info.out"
|
||||
}
|
||||
]
|
||||
}
|
9
tests/specs/info/package_json_basic/info.out
Normal file
9
tests/specs/info/package_json_basic/info.out
Normal file
@ -0,0 +1,9 @@
|
||||
local: [WILDCARD]main.ts
|
||||
type: TypeScript
|
||||
dependencies: 3 unique
|
||||
size: [WILDCARD]
|
||||
|
||||
file:///[WILDCARD]/main.ts (63B)
|
||||
└─┬ file:///[WILDCARD]/lib.ts (166B)
|
||||
├── file:///[WILDCARD]@denotest/esm-basic/main.mjs (unknown)
|
||||
└── file:///[WILDCARD]@denotest/esm-basic/main.d.mts (unknown)
|
3
tests/specs/info/package_json_basic/install.out
Normal file
3
tests/specs/info/package_json_basic/install.out
Normal file
@ -0,0 +1,3 @@
|
||||
Download http://localhost:4260/@denotest/esm-basic
|
||||
Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz
|
||||
Initialize @denotest/esm-basic@1.0.0
|
9
tests/specs/info/package_json_basic/lib.ts
Normal file
9
tests/specs/info/package_json_basic/lib.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import * as test from "@denotest/esm-basic";
|
||||
|
||||
export function add(a: number, b: number) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
export function getValue() {
|
||||
return test.getValue();
|
||||
}
|
3
tests/specs/info/package_json_basic/main.ts
Normal file
3
tests/specs/info/package_json_basic/main.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { getValue } from "./lib.ts";
|
||||
|
||||
console.log(getValue());
|
5
tests/specs/info/package_json_basic/package.json
Normal file
5
tests/specs/info/package_json_basic/package.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@denotest/esm-basic": "*"
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"tempDir": true,
|
||||
"steps": [
|
||||
{
|
||||
"args": "info --quiet main.ts",
|
||||
"output": "info.out"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"nodeModulesDir": "auto"
|
||||
}
|
9
tests/specs/info/package_json_basic_auto_install/lib.ts
Normal file
9
tests/specs/info/package_json_basic_auto_install/lib.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import * as test from "@denotest/esm-basic";
|
||||
|
||||
export function add(a: number, b: number) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
export function getValue() {
|
||||
return test.getValue();
|
||||
}
|
3
tests/specs/info/package_json_basic_auto_install/main.ts
Normal file
3
tests/specs/info/package_json_basic_auto_install/main.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { getValue } from "./lib.ts";
|
||||
|
||||
console.log(getValue());
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@denotest/esm-basic": "*"
|
||||
}
|
||||
}
|
16
tests/specs/run/package_json/with_deno_json/__test__.jsonc
Normal file
16
tests/specs/run/package_json/with_deno_json/__test__.jsonc
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"tempDir": true,
|
||||
"steps": [
|
||||
{
|
||||
"args": "run --quiet -A main.ts",
|
||||
"output": "main.out"
|
||||
},
|
||||
{
|
||||
"args": [
|
||||
"eval",
|
||||
"console.log(Deno.readTextFileSync('deno.lock').trim())"
|
||||
],
|
||||
"output": "lock.out"
|
||||
}
|
||||
]
|
||||
}
|
3
tests/specs/run/package_json/with_deno_json/deno.json
Normal file
3
tests/specs/run/package_json/with_deno_json/deno.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"nodeModulesDir": "auto"
|
||||
}
|
9
tests/specs/run/package_json/with_deno_json/lib.ts
Normal file
9
tests/specs/run/package_json/with_deno_json/lib.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import * as test from "@denotest/esm-basic";
|
||||
|
||||
export function add(a: number, b: number) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
export function getValue() {
|
||||
return test.getValue();
|
||||
}
|
18
tests/specs/run/package_json/with_deno_json/lock.out
Normal file
18
tests/specs/run/package_json/with_deno_json/lock.out
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"version": "4",
|
||||
"specifiers": {
|
||||
"npm:@denotest/esm-basic@*": "1.0.0"
|
||||
},
|
||||
"npm": {
|
||||
"@denotest/esm-basic@1.0.0": {
|
||||
"integrity": "sha512-[WILDCARD]"
|
||||
}
|
||||
},
|
||||
"workspace": {
|
||||
"packageJson": {
|
||||
"dependencies": [
|
||||
"npm:@denotest/esm-basic@*"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
1
tests/specs/run/package_json/with_deno_json/main.out
Normal file
1
tests/specs/run/package_json/with_deno_json/main.out
Normal file
@ -0,0 +1 @@
|
||||
0
|
3
tests/specs/run/package_json/with_deno_json/main.ts
Normal file
3
tests/specs/run/package_json/with_deno_json/main.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { getValue } from "./lib.ts";
|
||||
|
||||
console.log(getValue());
|
5
tests/specs/run/package_json/with_deno_json/package.json
Normal file
5
tests/specs/run/package_json/with_deno_json/package.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@denotest/esm-basic": "*"
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"tempDir": true,
|
||||
"args": "run -L debug npm:@denotest/bin/cli-esm this is a test",
|
||||
"output": "main.out"
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"nodeModulesDir": "auto"
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
[WILDCARD]
|
||||
[WILDCARD]package.json file found at '[WILDCARD]package.json'
|
||||
[WILDCARD]
|
||||
this
|
||||
is
|
||||
a
|
||||
test
|
||||
[WILDCARD]
|
13
tests/specs/test/package_json_basic/__test__.jsonc
Normal file
13
tests/specs/test/package_json_basic/__test__.jsonc
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"tempDir": true,
|
||||
"steps": [
|
||||
{
|
||||
"args": "install",
|
||||
"output": "install.out"
|
||||
},
|
||||
{
|
||||
"args": "test",
|
||||
"output": "test.out"
|
||||
}
|
||||
]
|
||||
}
|
3
tests/specs/test/package_json_basic/install.out
Normal file
3
tests/specs/test/package_json_basic/install.out
Normal file
@ -0,0 +1,3 @@
|
||||
Download http://localhost:4260/@denotest/esm-basic
|
||||
Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz
|
||||
Initialize @denotest/esm-basic@1.0.0
|
9
tests/specs/test/package_json_basic/lib.ts
Normal file
9
tests/specs/test/package_json_basic/lib.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import * as test from "@denotest/esm-basic";
|
||||
|
||||
export function add(a: number, b: number) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
export function getValue() {
|
||||
return test.getValue();
|
||||
}
|
5
tests/specs/test/package_json_basic/package.json
Normal file
5
tests/specs/test/package_json_basic/package.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@denotest/esm-basic": "*"
|
||||
}
|
||||
}
|
6
tests/specs/test/package_json_basic/test.out
Normal file
6
tests/specs/test/package_json_basic/test.out
Normal file
@ -0,0 +1,6 @@
|
||||
Check file://[WILDCARD]/lib.test.ts
|
||||
running 1 test from [WILDCARD]lib.test.ts
|
||||
should add ... ok ([WILDCARD])
|
||||
|
||||
ok | 1 passed | 0 failed ([WILDCARD])
|
||||
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"tempDir": true,
|
||||
"steps": [
|
||||
{
|
||||
"args": "test",
|
||||
"output": "test.out"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"nodeModulesDir": "auto"
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
import { add } from "./lib.ts";
|
||||
|
||||
Deno.test("should add", () => {
|
||||
if (add(1, 2) !== 3) {
|
||||
throw new Error("Fail");
|
||||
}
|
||||
});
|
9
tests/specs/test/package_json_basic_auto_install/lib.ts
Normal file
9
tests/specs/test/package_json_basic_auto_install/lib.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import * as test from "@denotest/esm-basic";
|
||||
|
||||
export function add(a: number, b: number) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
export function getValue() {
|
||||
return test.getValue();
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@denotest/esm-basic": "*"
|
||||
}
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
1
|
||||
2
|
@ -1,7 +0,0 @@
|
||||
[WILDCARD]package.json file found at '[WILDCARD]with_package_json[WILDCARD]npm_binary[WILDCARD]package.json'
|
||||
[WILDCARD]
|
||||
this
|
||||
is
|
||||
a
|
||||
test
|
||||
[WILDCARD]
|
@ -198,13 +198,13 @@ async function ensureNoNewITests() {
|
||||
"bench_tests.rs": 0,
|
||||
"cache_tests.rs": 0,
|
||||
"cert_tests.rs": 0,
|
||||
"check_tests.rs": 21,
|
||||
"check_tests.rs": 18,
|
||||
"compile_tests.rs": 0,
|
||||
"coverage_tests.rs": 0,
|
||||
"eval_tests.rs": 0,
|
||||
"flags_tests.rs": 0,
|
||||
"fmt_tests.rs": 16,
|
||||
"info_tests.rs": 18,
|
||||
"info_tests.rs": 17,
|
||||
"init_tests.rs": 0,
|
||||
"inspector_tests.rs": 0,
|
||||
"install_tests.rs": 0,
|
||||
@ -220,10 +220,10 @@ async function ensureNoNewITests() {
|
||||
"pm_tests.rs": 0,
|
||||
"publish_tests.rs": 0,
|
||||
"repl_tests.rs": 0,
|
||||
"run_tests.rs": 335,
|
||||
"run_tests.rs": 334,
|
||||
"shared_library_tests.rs": 0,
|
||||
"task_tests.rs": 4,
|
||||
"test_tests.rs": 74,
|
||||
"test_tests.rs": 73,
|
||||
"upgrade_tests.rs": 0,
|
||||
"vendor_tests.rs": 1,
|
||||
"watcher_tests.rs": 0,
|
||||
|
Loading…
Reference in New Issue
Block a user