1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 07:44:48 -05: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:
Bartek Iwańczuk 2024-09-16 14:39:58 +01:00 committed by GitHub
parent 8fa92228bb
commit 968f441da3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
67 changed files with 309 additions and 106 deletions

View file

@ -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();

View file

@ -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",

View file

@ -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

View file

@ -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",

View file

@ -0,0 +1,13 @@
{
"tempDir": true,
"steps": [
{
"args": "install",
"output": "install.out"
},
{
"args": "check main.ts",
"output": "check.out"
}
]
}

View file

@ -0,0 +1 @@
Check file://[WILDCARD]/main.ts

View 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

View file

@ -0,0 +1,9 @@
{
"tempDir": true,
"steps": [
{
"args": "check main.ts",
"output": "check.out"
}
]
}

View file

@ -0,0 +1,3 @@
{
"nodeModulesDir": "auto"
}

View 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();
}

View file

@ -0,0 +1,3 @@
import { getValue } from "./lib.ts";
console.log(getValue());

View 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
}
]
}

View 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

View 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();
}

View file

@ -0,0 +1,5 @@
{
"dependencies": {
"@denotest/esm-basic": "*"
}
}

View file

@ -0,0 +1,14 @@
{
"tempDir": true,
"steps": [
{
"args": "install",
"output": "install.out"
},
{
"args": "check --quiet main.ts",
"output": "check.out",
"exitCode": 1
}
]
}

View 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

View file

@ -0,0 +1,5 @@
{
"dependencies": {
"@denotest/esm-basic": "*"
}
}

View file

@ -0,0 +1,13 @@
{
"tempDir": true,
"steps": [
{
"args": "install",
"output": "install.out"
},
{
"args": "info --quiet main.ts",
"output": "info.out"
}
]
}

View 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)

View 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

View 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();
}

View file

@ -0,0 +1,3 @@
import { getValue } from "./lib.ts";
console.log(getValue());

View file

@ -0,0 +1,5 @@
{
"dependencies": {
"@denotest/esm-basic": "*"
}
}

View file

@ -0,0 +1,9 @@
{
"tempDir": true,
"steps": [
{
"args": "info --quiet main.ts",
"output": "info.out"
}
]
}

View file

@ -0,0 +1,3 @@
{
"nodeModulesDir": "auto"
}

View 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();
}

View file

@ -0,0 +1,3 @@
import { getValue } from "./lib.ts";
console.log(getValue());

View file

@ -0,0 +1,5 @@
{
"dependencies": {
"@denotest/esm-basic": "*"
}
}

View 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"
}
]
}

View file

@ -0,0 +1,3 @@
{
"nodeModulesDir": "auto"
}

View 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();
}

View 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@*"
]
}
}
}

View file

@ -0,0 +1 @@
0

View file

@ -0,0 +1,3 @@
import { getValue } from "./lib.ts";
console.log(getValue());

View file

@ -0,0 +1,5 @@
{
"dependencies": {
"@denotest/esm-basic": "*"
}
}

View file

@ -0,0 +1,5 @@
{
"tempDir": true,
"args": "run -L debug npm:@denotest/bin/cli-esm this is a test",
"output": "main.out"
}

View file

@ -0,0 +1,3 @@
{
"nodeModulesDir": "auto"
}

View file

@ -0,0 +1,8 @@
[WILDCARD]
[WILDCARD]package.json file found at '[WILDCARD]package.json'
[WILDCARD]
this
is
a
test
[WILDCARD]

View file

@ -0,0 +1,13 @@
{
"tempDir": true,
"steps": [
{
"args": "install",
"output": "install.out"
},
{
"args": "test",
"output": "test.out"
}
]
}

View 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

View 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();
}

View file

@ -0,0 +1,5 @@
{
"dependencies": {
"@denotest/esm-basic": "*"
}
}

View 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])

View file

@ -0,0 +1,9 @@
{
"tempDir": true,
"steps": [
{
"args": "test",
"output": "test.out"
}
]
}

View file

@ -0,0 +1,3 @@
{
"nodeModulesDir": "auto"
}

View file

@ -0,0 +1,7 @@
import { add } from "./lib.ts";
Deno.test("should add", () => {
if (add(1, 2) !== 3) {
throw new Error("Fail");
}
});

View 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();
}

View file

@ -0,0 +1,5 @@
{
"dependencies": {
"@denotest/esm-basic": "*"
}
}

View file

@ -1,2 +0,0 @@
1
2

View file

@ -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]

View file

@ -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,