1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

chore: move info itests (#25659)

This commit is contained in:
Mohammad Sulaiman 2024-09-16 20:08:00 +03:00 committed by GitHub
parent e47606a554
commit acc32e1cee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
78 changed files with 270 additions and 146 deletions

View file

@ -1,124 +0,0 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use test_util as util;
use test_util::itest;
use util::TestContextBuilder;
#[test]
fn info_lock_write() {
let context = TestContextBuilder::new().use_http_server().build();
context.temp_dir().write("deno.json", "{}");
let module_path = "http://127.0.0.1:4545/run/048_media_types_jsx.ts";
let output = context
.new_command()
.current_dir(context.temp_dir().path())
.args_vec(["info", module_path])
.run();
output.assert_exit_code(0);
output.skip_output_check();
assert!(
context.temp_dir().path().join("deno.lock").exists(),
"missing deno.lock"
);
}
itest!(multiple_imports {
args: "info http://127.0.0.1:4545/run/019_media_types.ts",
output: "info/multiple_imports.out",
http_server: true,
});
itest!(info_flag {
args: "info",
output: "info/041_info_flag.out",
});
itest!(info_flag_location {
args: "info --location https://deno.land",
output: "info/041_info_flag_location.out",
});
itest!(info_json {
args: "info --json",
output: "info/info_json.out",
});
itest!(info_json_location {
args: "info --json --location https://deno.land",
output: "info/info_json_location.out",
});
itest!(info_flag_script_jsx {
args: "info http://127.0.0.1:4545/run/048_media_types_jsx.ts",
output: "info/049_info_flag_script_jsx.out",
http_server: true,
});
itest!(json_file {
args: "info --quiet --json info/json_output/main.ts",
output: "info/json_output/main.out",
exit_code: 0,
});
itest!(info_json_deps_order {
args: "info --json info/076_info_json_deps_order.ts",
output: "info/076_info_json_deps_order.out",
});
itest!(info_missing_module {
args: "info info/error_009_missing_js_module.js",
output: "info/info_missing_module.out",
});
itest!(info_recursive_modules {
args: "info --quiet info/info_recursive_imports_test.ts",
output: "info/info_recursive_imports_test.out",
exit_code: 0,
});
itest!(info_type_import {
args: "info info/info_type_import.ts",
output: "info/info_type_import.out",
});
itest!(_054_info_local_imports {
args: "info --quiet run/005_more_imports.ts",
output: "info/054_info_local_imports.out",
exit_code: 0,
});
// Tests for AssertionError where "data" is unexpectedly null when
// a file contains only triple slash references (#11196)
itest!(data_null_error {
args: "info info/data_null_error/mod.ts",
output: "info/data_null_error/data_null_error.out",
});
itest!(types_header_direct {
args: "info --reload run/type_directives_01.ts",
output: "info/types_header.out",
http_server: true,
});
itest!(with_config_override {
args: "info info/with_config/test.ts --config info/with_config/deno-override.json --import-map info/with_config/import_map.json",
output: "info/with_config/with_config.out",
});
itest!(info_import_map {
args: "info preact/debug",
output: "info/with_import_map/with_import_map.out",
cwd: Some("info/with_import_map"),
copy_temp_dir: Some("info/with_import_map"),
exit_code: 0,
});
itest!(info_dynamic_imports_tmpl_lit {
args: "info compile/dynamic_imports_tmp_lit/main.js",
output: "compile/dynamic_imports_tmp_lit/main.info.out",
exit_code: 0,
});

View file

@ -23,8 +23,6 @@ mod eval;
mod flags; mod flags;
#[path = "fmt_tests.rs"] #[path = "fmt_tests.rs"]
mod fmt; mod fmt;
#[path = "info_tests.rs"]
mod info;
#[path = "init_tests.rs"] #[path = "init_tests.rs"]
mod init; mod init;
#[path = "inspector_tests.rs"] #[path = "inspector_tests.rs"]

View file

@ -0,0 +1,11 @@
import { printHello3, returnsFoo2, returnsHi } from "./mod1.ts";
printHello3();
if (returnsHi() !== "Hi") {
throw Error("Unexpected");
}
if (returnsFoo2() !== "Foo") {
throw Error("Unexpected");
}

View file

@ -0,0 +1,9 @@
local: [WILDCARD]005_more_imports.ts
type: TypeScript
dependencies: 3 unique
size: [WILDCARD]
file://[WILDCARD]/005_more_imports.ts ([WILDCARD])
└─┬ file://[WILDCARD]/mod1.ts ([WILDCARD])
└─┬ file://[WILDCARD]/subdir2/mod2.ts ([WILDCARD])
└── file://[WILDCARD]/print_hello.ts ([WILDCARD])

View file

@ -0,0 +1,5 @@
{
"args": "info --quiet 005_more_imports.ts",
"output": "054_info_local_imports.out",
"exitCode": 0
}

View file

@ -0,0 +1,17 @@
import { printHello2, returnsFoo } from "./subdir2/mod2.ts";
export function returnsHi(): string {
return "Hi";
}
export function returnsFoo2(): string {
return returnsFoo();
}
export function printHello3() {
printHello2();
}
export function throwsError() {
throw Error("exception from mod1");
}

View file

@ -0,0 +1 @@
export { printHello } from "./print_hello.ts";

View file

@ -0,0 +1,3 @@
export function printHello() {
console.log("Hello");
}

View file

@ -0,0 +1,4 @@
(async () => {
const { printHello } = await import("../mod2.ts");
printHello();
})();

View file

@ -0,0 +1,9 @@
import { printHello } from "../print_hello.ts";
export function returnsFoo(): string {
return "Foo";
}
export function printHello2() {
printHello();
}

View file

@ -0,0 +1,4 @@
{
"args": "info data_null_error/mod.ts",
"output": "data_null_error/data_null_error.out"
}

View file

@ -0,0 +1,5 @@
{
"args": "info dynamic_imports_tmp_lit/main.js",
"output": "dynamic_imports_tmp_lit/main.info.out",
"exitCode": 0
}

View file

@ -0,0 +1,10 @@
local: [WILDCARD]main.js
type: JavaScript
dependencies: 4 unique
size: [WILDCARD]
file:///[WILDCARD]/dynamic_imports_tmp_lit/main.js ([WILDCARD])
├── file:///[WILDCARD]/dynamic_imports_tmp_lit/sub/a.js ([WILDCARD])
├── file:///[WILDCARD]/dynamic_imports_tmp_lit/sub/b.ts ([WILDCARD])
├── file:///[WILDCARD]/dynamic_imports_tmp_lit/other/data.json ([WILDCARD])
└── file:///[WILDCARD]/dynamic_imports_tmp_lit/other/sub/data2.json ([WILDCARD])

View file

@ -0,0 +1,14 @@
const fileNames = [
"a.js",
"b.ts",
];
for (const fileName of fileNames) {
await import(`./sub/${fileName}`);
}
const jsonFileNames = ["data.json", "sub/data2.json"];
for (const fileName of jsonFileNames) {
const mod = await import(`./other/${fileName}`, { with: { type: "json" } });
console.log(mod.default);
}

View file

@ -0,0 +1 @@
console.log("a");

View file

@ -0,0 +1 @@
console.log("b");

View file

@ -0,0 +1,4 @@
{
"args": "info",
"output": "041_info_flag.out"
}

View file

@ -0,0 +1,4 @@
{
"args": "info --location https://deno.land",
"output": "041_info_flag_location.out"
}

View file

@ -0,0 +1,4 @@
{
"args": "info http://127.0.0.1:4545/run/048_media_types_jsx.ts",
"output": "049_info_flag_script_jsx.out"
}

View file

@ -0,0 +1,5 @@
{
"args": "info preact/debug",
"output": "with_import_map.out",
"exitCode": 0
}

View file

@ -0,0 +1,4 @@
{
"args": "info --json",
"output": "info_json.out"
}

View file

@ -0,0 +1,4 @@
{
"args": "info --json 076_info_json_deps_order.ts",
"output": "076_info_json_deps_order.out"
}

View file

@ -0,0 +1,7 @@
import { B } from "./B.ts";
import { thing } from "./common.ts";
export function A() {
thing();
B();
}

View file

@ -0,0 +1,7 @@
import { C } from "./C.ts";
import { thing } from "./common.ts";
export function B() {
thing();
C();
}

View file

@ -0,0 +1,8 @@
import { A } from "./A.ts";
import { thing } from "./common.ts";
export function C() {
if (A != null) {
thing();
}
}

View file

@ -0,0 +1,2 @@
export function thing() {
}

View file

@ -0,0 +1,4 @@
{
"args": "info --json --location https://deno.land",
"output": "info_json_location.out"
}

View file

@ -0,0 +1,4 @@
{
"args": "info error_009_missing_js_module.js",
"output": "info_missing_module.out"
}

View file

@ -0,0 +1 @@
import "./bad-module.js";

View file

@ -0,0 +1,5 @@
{
"args": "info --quiet info_recursive_imports_test.ts",
"output": "info_recursive_imports_test.out",
"exitCode": 0
}

View file

@ -0,0 +1,5 @@
import { A } from "./recursive_imports/A.ts";
export function test() {
A();
}

View file

@ -0,0 +1,7 @@
import { B } from "./B.ts";
import { thing } from "./common.ts";
export function A() {
thing();
B();
}

View file

@ -0,0 +1,7 @@
import { C } from "./C.ts";
import { thing } from "./common.ts";
export function B() {
thing();
C();
}

View file

@ -0,0 +1,8 @@
import { A } from "./A.ts";
import { thing } from "./common.ts";
export function C() {
if (A != null) {
thing();
}
}

View file

@ -0,0 +1,2 @@
export function thing() {
}

View file

@ -0,0 +1,4 @@
{
"args": "info info_type_import.ts",
"output": "info_type_import.out"
}

View file

@ -0,0 +1,3 @@
import { AnInterface as _, isAnInterface } from "./type_and_code.ts";
isAnInterface({});

View file

@ -0,0 +1,7 @@
export interface AnInterface {
a: string;
}
export function isAnInterface(value: unknown): value is AnInterface {
return value && typeof value === "object" && "a" in value;
}

View file

@ -0,0 +1,5 @@
{
"args": "info --quiet --json json_output/main.ts",
"output": "json_output/main.out",
"exitCode": 0
}

View file

@ -1,15 +1,15 @@
{ {
"roots": [ "roots": [
"file://[WILDCARD]/info/json_output/main.ts" "file://[WILDCARD]/json_output/main.ts"
], ],
"modules": [ "modules": [
{ {
"kind": "esm", "kind": "esm",
"dependencies": [ "dependencies": [
{ {
"specifier": "../../subdir/mod1.ts", "specifier": "../mod1.ts",
"code": { "code": {
"specifier": "file://[WILDCARD]/subdir/mod1.ts", "specifier": "file://[WILDCARD]/mod1.ts",
"span": { "span": {
"start": { "start": {
"line": 0, "line": 0,
@ -17,7 +17,7 @@
}, },
"end": { "end": {
"line": 0, "line": 0,
"character": 74 "character": 64
} }
} }
} }
@ -34,7 +34,7 @@
{ {
"specifier": "./subdir2/mod2.ts", "specifier": "./subdir2/mod2.ts",
"code": { "code": {
"specifier": "file://[WILDCARD]/subdir/subdir2/mod2.ts", "specifier": "file://[WILDCARD]/subdir2/mod2.ts",
"span": { "span": {
"start": { "start": {
"line": 0, "line": 0,
@ -51,14 +51,14 @@
"local": "[WILDCARD]mod1.ts", "local": "[WILDCARD]mod1.ts",
[WILDCARD] [WILDCARD]
"mediaType": "TypeScript", "mediaType": "TypeScript",
"specifier": "file://[WILDCARD]/subdir/mod1.ts" "specifier": "file://[WILDCARD]/mod1.ts"
}, },
{ {
"kind": "esm", "kind": "esm",
"local": "[WILDCARD]print_hello.ts", "local": "[WILDCARD]print_hello.ts",
[WILDCARD] [WILDCARD]
"mediaType": "TypeScript", "mediaType": "TypeScript",
"specifier": "file://[WILDCARD]/subdir/print_hello.ts" "specifier": "file://[WILDCARD]/print_hello.ts"
}, },
{ {
"kind": "esm", "kind": "esm",
@ -66,7 +66,7 @@
{ {
"specifier": "../print_hello.ts", "specifier": "../print_hello.ts",
"code": { "code": {
"specifier": "file://[WILDCARD]/subdir/print_hello.ts", "specifier": "file://[WILDCARD]/print_hello.ts",
"span": { "span": {
"start": { "start": {
"line": 0, "line": 0,
@ -83,7 +83,7 @@
"local": "[WILDCARD]mod2.ts", "local": "[WILDCARD]mod2.ts",
[WILDCARD] [WILDCARD]
"mediaType": "TypeScript", "mediaType": "TypeScript",
"specifier": "file://[WILDCARD]/subdir/subdir2/mod2.ts" "specifier": "file://[WILDCARD]/subdir2/mod2.ts"
} }
], ],
"redirects": {}, "redirects": {},

View file

@ -1,4 +1,4 @@
import { printHello3, returnsFoo2, returnsHi } from "../../subdir/mod1.ts"; import { printHello3, returnsFoo2, returnsHi } from "../mod1.ts";
printHello3(); printHello3();

View file

@ -0,0 +1,17 @@
import { printHello2, returnsFoo } from "./subdir2/mod2.ts";
export function returnsHi(): string {
return "Hi";
}
export function returnsFoo2(): string {
return returnsFoo();
}
export function printHello3() {
printHello2();
}
export function throwsError() {
throw Error("exception from mod1");
}

View file

@ -0,0 +1 @@
export { printHello } from "./print_hello.ts";

View file

@ -0,0 +1,3 @@
export function printHello() {
console.log("Hello");
}

View file

@ -0,0 +1,4 @@
(async () => {
const { printHello } = await import("../mod2.ts");
printHello();
})();

View file

@ -0,0 +1,9 @@
import { printHello } from "../print_hello.ts";
export function returnsFoo(): string {
return "Foo";
}
export function printHello2() {
printHello();
}

View file

@ -0,0 +1,4 @@
{
"args": "info http://127.0.0.1:4545/run/019_media_types.ts",
"output": "multiple_imports.out"
}

View file

@ -0,0 +1,4 @@
{
"args": "info --reload type_directives_01.ts",
"output": "types_header.out"
}

View file

@ -0,0 +1,3 @@
import * as foo from "http://127.0.0.1:4545/xTypeScriptTypes.js";
console.log(foo.foo);

View file

@ -0,0 +1,4 @@
{
"args": "info with_config/test.ts --config with_config/deno-override.json --import-map with_config/import_map.json",
"output": "with_config/with_config.out"
}

View file

@ -1,9 +0,0 @@
local: [WILDCARD]005_more_imports.ts
type: TypeScript
dependencies: 3 unique
size: [WILDCARD]
file://[WILDCARD]/005_more_imports.ts ([WILDCARD])
└─┬ file://[WILDCARD]/subdir/mod1.ts ([WILDCARD])
└─┬ file://[WILDCARD]/subdir/subdir2/mod2.ts ([WILDCARD])
└── file://[WILDCARD]/subdir/print_hello.ts ([WILDCARD])

View file

@ -204,7 +204,6 @@ async function ensureNoNewITests() {
"eval_tests.rs": 0, "eval_tests.rs": 0,
"flags_tests.rs": 0, "flags_tests.rs": 0,
"fmt_tests.rs": 16, "fmt_tests.rs": 16,
"info_tests.rs": 17,
"init_tests.rs": 0, "init_tests.rs": 0,
"inspector_tests.rs": 0, "inspector_tests.rs": 0,
"install_tests.rs": 0, "install_tests.rs": 0,