Skip to content

Commit

Permalink
chore: move info itests (#25659)
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammadSu1 authored Sep 16, 2024
1 parent e47606a commit acc32e1
Show file tree
Hide file tree
Showing 78 changed files with 270 additions and 146 deletions.
124 changes: 0 additions & 124 deletions tests/integration/info_tests.rs

This file was deleted.

2 changes: 0 additions & 2 deletions tests/integration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ mod eval;
mod flags;
#[path = "fmt_tests.rs"]
mod fmt;
#[path = "info_tests.rs"]
mod info;
#[path = "init_tests.rs"]
mod init;
#[path = "inspector_tests.rs"]
Expand Down
11 changes: 11 additions & 0 deletions tests/specs/info_tests/_054_info_local_imports/005_more_imports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { printHello3, returnsFoo2, returnsHi } from "./mod1.ts";

printHello3();

if (returnsHi() !== "Hi") {
throw Error("Unexpected");
}

if (returnsFoo2() !== "Foo") {
throw Error("Unexpected");
}
Original file line number Diff line number Diff line change
@@ -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])
5 changes: 5 additions & 0 deletions tests/specs/info_tests/_054_info_local_imports/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"args": "info --quiet 005_more_imports.ts",
"output": "054_info_local_imports.out",
"exitCode": 0
}
17 changes: 17 additions & 0 deletions tests/specs/info_tests/_054_info_local_imports/mod1.ts
Original file line number Diff line number Diff line change
@@ -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");
}
1 change: 1 addition & 0 deletions tests/specs/info_tests/_054_info_local_imports/mod2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { printHello } from "./print_hello.ts";
3 changes: 3 additions & 0 deletions tests/specs/info_tests/_054_info_local_imports/print_hello.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function printHello() {
console.log("Hello");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(async () => {
const { printHello } = await import("../mod2.ts");
printHello();
})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { printHello } from "../print_hello.ts";

export function returnsFoo(): string {
return "Foo";
}

export function printHello2() {
printHello();
}
4 changes: 4 additions & 0 deletions tests/specs/info_tests/data_null_error/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"args": "info data_null_error/mod.ts",
"output": "data_null_error/data_null_error.out"
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"args": "info dynamic_imports_tmp_lit/main.js",
"output": "dynamic_imports_tmp_lit/main.info.out",
"exitCode": 0
}
Original file line number Diff line number Diff line change
@@ -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])
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"data": 5
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"data": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("a");
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("b");
File renamed without changes.
4 changes: 4 additions & 0 deletions tests/specs/info_tests/info_flag/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"args": "info",
"output": "041_info_flag.out"
}
4 changes: 4 additions & 0 deletions tests/specs/info_tests/info_flag_location/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"args": "info --location https://deno.land",
"output": "041_info_flag_location.out"
}
4 changes: 4 additions & 0 deletions tests/specs/info_tests/info_flag_script_jsx/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -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"
}
5 changes: 5 additions & 0 deletions tests/specs/info_tests/info_import_map/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"args": "info preact/debug",
"output": "with_import_map.out",
"exitCode": 0
}
4 changes: 4 additions & 0 deletions tests/specs/info_tests/info_json/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"args": "info --json",
"output": "info_json.out"
}
File renamed without changes.
4 changes: 4 additions & 0 deletions tests/specs/info_tests/info_json_deps_order/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"args": "info --json 076_info_json_deps_order.ts",
"output": "076_info_json_deps_order.out"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { B } from "./B.ts";
import { thing } from "./common.ts";

export function A() {
thing();
B();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { C } from "./C.ts";
import { thing } from "./common.ts";

export function B() {
thing();
C();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { A } from "./A.ts";
import { thing } from "./common.ts";

export function C() {
if (A != null) {
thing();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export function thing() {
}
4 changes: 4 additions & 0 deletions tests/specs/info_tests/info_json_location/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"args": "info --json --location https://deno.land",
"output": "info_json_location.out"
}
File renamed without changes.
4 changes: 4 additions & 0 deletions tests/specs/info_tests/info_missing_module/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"args": "info error_009_missing_js_module.js",
"output": "info_missing_module.out"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "./bad-module.js";
File renamed without changes.
5 changes: 5 additions & 0 deletions tests/specs/info_tests/info_recursive_modules/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"args": "info --quiet info_recursive_imports_test.ts",
"output": "info_recursive_imports_test.out",
"exitCode": 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { A } from "./recursive_imports/A.ts";

export function test() {
A();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { B } from "./B.ts";
import { thing } from "./common.ts";

export function A() {
thing();
B();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { C } from "./C.ts";
import { thing } from "./common.ts";

export function B() {
thing();
C();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { A } from "./A.ts";
import { thing } from "./common.ts";

export function C() {
if (A != null) {
thing();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export function thing() {
}
4 changes: 4 additions & 0 deletions tests/specs/info_tests/info_type_import/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"args": "info info_type_import.ts",
"output": "info_type_import.out"
}
File renamed without changes.
3 changes: 3 additions & 0 deletions tests/specs/info_tests/info_type_import/info_type_import.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { AnInterface as _, isAnInterface } from "./type_and_code.ts";

isAnInterface({});
7 changes: 7 additions & 0 deletions tests/specs/info_tests/info_type_import/type_and_code.ts
Original file line number Diff line number Diff line change
@@ -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;
}
5 changes: 5 additions & 0 deletions tests/specs/info_tests/json_file/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"args": "info --quiet --json json_output/main.ts",
"output": "json_output/main.out",
"exitCode": 0
}
Loading

0 comments on commit acc32e1

Please sign in to comment.