chore: add tests for moduleGraph2 (#23603)

Also did some renames from underscores to hyphens
This commit is contained in:
David Sherret 2024-04-29 14:09:58 -04:00 committed by GitHub
parent 67d00fb1e3
commit 48daf2dc88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
37 changed files with 127 additions and 66 deletions

1
cli/cache/mod.rs vendored
View file

@ -296,6 +296,7 @@ impl Loader for FetchCacher {
source: &Arc<[u8]>, source: &Arc<[u8]>,
module_info: &deno_graph::ModuleInfo, module_info: &deno_graph::ModuleInfo,
) { ) {
log::debug!("Caching module info for {}", specifier);
let source_hash = ModuleInfoCacheSourceHash::from_source(source); let source_hash = ModuleInfoCacheSourceHash::from_source(source);
let result = self.module_info_cache.set_module_info( let result = self.module_info_cache.set_module_info(
specifier, specifier,

View file

@ -128,7 +128,7 @@ fn specifiers_in_lockfile() {
temp_dir.write( temp_dir.write(
"main.ts", "main.ts",
r#"import version from "jsr:@denotest/no_module_graph@0.1"; r#"import version from "jsr:@denotest/no-module-graph@0.1";
console.log(version);"#, console.log(version);"#,
); );
@ -146,8 +146,8 @@ console.log(version);"#,
.content .content
.packages .packages
.specifiers .specifiers
.get_mut("jsr:@denotest/no_module_graph@0.1") .get_mut("jsr:@denotest/no-module-graph@0.1")
.unwrap() = "jsr:@denotest/no_module_graph@0.1.0".to_string(); .unwrap() = "jsr:@denotest/no-module-graph@0.1.0".to_string();
lockfile_path.write(lockfile.as_json_string()); lockfile_path.write(lockfile.as_json_string());
test_context test_context
@ -238,7 +238,7 @@ fn lockfile_bad_package_integrity() {
temp_dir.write( temp_dir.write(
"main.ts", "main.ts",
r#"import version from "jsr:@denotest/no_module_graph@0.1"; r#"import version from "jsr:@denotest/no-module-graph@0.1";
console.log(version);"#, console.log(version);"#,
); );
@ -252,14 +252,14 @@ console.log(version);"#,
let lockfile_path = temp_dir.path().join("deno.lock"); let lockfile_path = temp_dir.path().join("deno.lock");
let mut lockfile = Lockfile::new(lockfile_path.to_path_buf(), false).unwrap(); let mut lockfile = Lockfile::new(lockfile_path.to_path_buf(), false).unwrap();
let pkg_name = "@denotest/no_module_graph@0.1.1"; let pkg_name = "@denotest/no-module-graph@0.1.1";
let original_integrity = get_lockfile_pkg_integrity(&lockfile, pkg_name); let original_integrity = get_lockfile_pkg_integrity(&lockfile, pkg_name);
set_lockfile_pkg_integrity(&mut lockfile, pkg_name, "bad_integrity"); set_lockfile_pkg_integrity(&mut lockfile, pkg_name, "bad_integrity");
lockfile_path.write(lockfile.as_json_string()); lockfile_path.write(lockfile.as_json_string());
let actual_integrity = let actual_integrity =
test_context.get_jsr_package_integrity("@denotest/no_module_graph/0.1.1"); test_context.get_jsr_package_integrity("@denotest/no-module-graph/0.1.1");
let integrity_check_failed_msg = format!("error: Integrity check failed for http://127.0.0.1:4250/@denotest/no_module_graph/0.1.1_meta.json let integrity_check_failed_msg = format!("error: Integrity check failed for http://127.0.0.1:4250/@denotest/no-module-graph/0.1.1_meta.json
Actual: {} Actual: {}
Expected: bad_integrity Expected: bad_integrity

View file

@ -1018,7 +1018,7 @@ fn lock_deno_json_package_json_deps() {
deno_json.write_json(&json!({ deno_json.write_json(&json!({
"imports": { "imports": {
"esm-basic": "npm:@denotest/esm-basic", "esm-basic": "npm:@denotest/esm-basic",
"module_graph": "jsr:@denotest/module_graph@1.4", "module_graph": "jsr:@denotest/module-graph@1.4",
} }
})); }));
let main_ts = temp_dir.join("main.ts"); let main_ts = temp_dir.join("main.ts");
@ -1035,11 +1035,11 @@ fn lock_deno_json_package_json_deps() {
"version": "3", "version": "3",
"packages": { "packages": {
"specifiers": { "specifiers": {
"jsr:@denotest/module_graph@1.4": "jsr:@denotest/module_graph@1.4.0", "jsr:@denotest/module-graph@1.4": "jsr:@denotest/module-graph@1.4.0",
"npm:@denotest/esm-basic": "npm:@denotest/esm-basic@1.0.0" "npm:@denotest/esm-basic": "npm:@denotest/esm-basic@1.0.0"
}, },
"jsr": { "jsr": {
"@denotest/module_graph@1.4.0": { "@denotest/module-graph@1.4.0": {
"integrity": "32de0973c5fa55772326fcd504a757f386d2b010db3e13e78f3bcf851e69473d" "integrity": "32de0973c5fa55772326fcd504a757f386d2b010db3e13e78f3bcf851e69473d"
} }
}, },
@ -1053,7 +1053,7 @@ fn lock_deno_json_package_json_deps() {
"remote": {}, "remote": {},
"workspace": { "workspace": {
"dependencies": [ "dependencies": [
"jsr:@denotest/module_graph@1.4", "jsr:@denotest/module-graph@1.4",
"npm:@denotest/esm-basic" "npm:@denotest/esm-basic"
] ]
} }
@ -1063,7 +1063,7 @@ fn lock_deno_json_package_json_deps() {
// it to a package.json that uses an alias // it to a package.json that uses an alias
deno_json.write_json(&json!({ deno_json.write_json(&json!({
"imports": { "imports": {
"module_graph": "jsr:@denotest/module_graph@1.4", "module_graph": "jsr:@denotest/module-graph@1.4",
} }
})); }));
package_json.write_json(&json!({ package_json.write_json(&json!({
@ -1087,11 +1087,11 @@ fn lock_deno_json_package_json_deps() {
"version": "3", "version": "3",
"packages": { "packages": {
"specifiers": { "specifiers": {
"jsr:@denotest/module_graph@1.4": "jsr:@denotest/module_graph@1.4.0", "jsr:@denotest/module-graph@1.4": "jsr:@denotest/module-graph@1.4.0",
"npm:@denotest/esm-basic": "npm:@denotest/esm-basic@1.0.0" "npm:@denotest/esm-basic": "npm:@denotest/esm-basic@1.0.0"
}, },
"jsr": { "jsr": {
"@denotest/module_graph@1.4.0": { "@denotest/module-graph@1.4.0": {
"integrity": "32de0973c5fa55772326fcd504a757f386d2b010db3e13e78f3bcf851e69473d" "integrity": "32de0973c5fa55772326fcd504a757f386d2b010db3e13e78f3bcf851e69473d"
} }
}, },
@ -1105,7 +1105,7 @@ fn lock_deno_json_package_json_deps() {
"remote": {}, "remote": {},
"workspace": { "workspace": {
"dependencies": [ "dependencies": [
"jsr:@denotest/module_graph@1.4" "jsr:@denotest/module-graph@1.4"
], ],
"packageJson": { "packageJson": {
"dependencies": [ "dependencies": [
@ -1128,10 +1128,10 @@ fn lock_deno_json_package_json_deps() {
"version": "3", "version": "3",
"packages": { "packages": {
"specifiers": { "specifiers": {
"jsr:@denotest/module_graph@1.4": "jsr:@denotest/module_graph@1.4.0", "jsr:@denotest/module-graph@1.4": "jsr:@denotest/module-graph@1.4.0",
}, },
"jsr": { "jsr": {
"@denotest/module_graph@1.4.0": { "@denotest/module-graph@1.4.0": {
"integrity": "32de0973c5fa55772326fcd504a757f386d2b010db3e13e78f3bcf851e69473d" "integrity": "32de0973c5fa55772326fcd504a757f386d2b010db3e13e78f3bcf851e69473d"
} }
} }
@ -1139,7 +1139,7 @@ fn lock_deno_json_package_json_deps() {
"remote": {}, "remote": {},
"workspace": { "workspace": {
"dependencies": [ "dependencies": [
"jsr:@denotest/module_graph@1.4" "jsr:@denotest/module-graph@1.4"
] ]
} }
})); }));

View file

@ -1,13 +1,13 @@
Download http://127.0.0.1:4250/@denotest/deps/meta.json Download http://127.0.0.1:4250/@denotest/deps/meta.json
Download http://127.0.0.1:4250/@denotest/deps/1.0.0_meta.json Download http://127.0.0.1:4250/@denotest/deps/1.0.0_meta.json
Download http://127.0.0.1:4250/@denotest/module_graph/meta.json Download http://127.0.0.1:4250/@denotest/module-graph/meta.json
Download http://127.0.0.1:4250/@denotest/no_module_graph/meta.json Download http://127.0.0.1:4250/@denotest/no-module-graph/meta.json
Download http://127.0.0.1:4250/@denotest/module_graph/1.4.0_meta.json Download http://127.0.0.1:4250/@denotest/module-graph/1.4.0_meta.json
Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.1_meta.json Download http://127.0.0.1:4250/@denotest/no-module-graph/0.1.1_meta.json
[UNORDERED_START] [UNORDERED_START]
Download http://127.0.0.1:4250/@denotest/deps/1.0.0/mod.ts Download http://127.0.0.1:4250/@denotest/deps/1.0.0/mod.ts
Download http://127.0.0.1:4250/@denotest/module_graph/1.4.0/other.ts Download http://127.0.0.1:4250/@denotest/module-graph/1.4.0/other.ts
Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.1/mod.ts Download http://127.0.0.1:4250/@denotest/no-module-graph/0.1.1/mod.ts
Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.1/TestClass.ts Download http://127.0.0.1:4250/@denotest/no-module-graph/0.1.1/TestClass.ts
[UNORDERED_END] [UNORDERED_END]
{ version: "0.1.1", other: Other {} } { version: "0.1.1", other: Other {} }

View file

@ -1,14 +1,14 @@
Download http://127.0.0.1:4250/@denotest/deps/meta.json Download http://127.0.0.1:4250/@denotest/deps/meta.json
Download http://127.0.0.1:4250/@denotest/deps/1.0.0_meta.json Download http://127.0.0.1:4250/@denotest/deps/1.0.0_meta.json
Download http://127.0.0.1:4250/@denotest/module_graph/meta.json Download http://127.0.0.1:4250/@denotest/module-graph/meta.json
Download http://127.0.0.1:4250/@denotest/no_module_graph/meta.json Download http://127.0.0.1:4250/@denotest/no-module-graph/meta.json
Download http://127.0.0.1:4250/@denotest/module_graph/1.4.0_meta.json Download http://127.0.0.1:4250/@denotest/module-graph/1.4.0_meta.json
Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.1_meta.json Download http://127.0.0.1:4250/@denotest/no-module-graph/0.1.1_meta.json
[UNORDERED_START] [UNORDERED_START]
Download http://127.0.0.1:4250/@denotest/deps/1.0.0/mod.ts Download http://127.0.0.1:4250/@denotest/deps/1.0.0/mod.ts
Download http://127.0.0.1:4250/@denotest/module_graph/1.4.0/other.ts Download http://127.0.0.1:4250/@denotest/module-graph/1.4.0/other.ts
Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.1/mod.ts Download http://127.0.0.1:4250/@denotest/no-module-graph/0.1.1/mod.ts
Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.1/TestClass.ts Download http://127.0.0.1:4250/@denotest/no-module-graph/0.1.1/TestClass.ts
[UNORDERED_END] [UNORDERED_END]
local: [WILDCARD]main.ts local: [WILDCARD]main.ts
type: TypeScript type: TypeScript
@ -17,6 +17,6 @@ size: [WILDCARD]
file:///[WILDCARD]main.ts ([WILDCARD]) file:///[WILDCARD]main.ts ([WILDCARD])
└─┬ http://127.0.0.1:4250/@denotest/deps/1.0.0/mod.ts ([WILDCARD]) └─┬ http://127.0.0.1:4250/@denotest/deps/1.0.0/mod.ts ([WILDCARD])
├── http://127.0.0.1:4250/@denotest/module_graph/1.4.0/other.ts ([WILDCARD]) ├── http://127.0.0.1:4250/@denotest/module-graph/1.4.0/other.ts ([WILDCARD])
└─┬ http://127.0.0.1:4250/@denotest/no_module_graph/0.1.1/mod.ts ([WILDCARD]) └─┬ http://127.0.0.1:4250/@denotest/no-module-graph/0.1.1/mod.ts ([WILDCARD])
└── http://127.0.0.1:4250/@denotest/no_module_graph/0.1.1/TestClass.ts ([WILDCARD]) └── http://127.0.0.1:4250/@denotest/no-module-graph/0.1.1/TestClass.ts ([WILDCARD])

View file

@ -1,6 +1,6 @@
{ {
"steps": [{ "steps": [{
"args": "run main.ts", "args": "run --log-level=debug main.ts",
"output": "main.out" "output": "main.out"
}, { }, {
"cleanDenoDir": true, "cleanDenoDir": true,

View file

@ -1,7 +1,5 @@
Download http://127.0.0.1:4250/@denotest/module_graph/meta.json [WILDCARD]Caching module info for http://[WILDLINE]/@denotest/module-graph/1.4.0/mod.ts
Download http://127.0.0.1:4250/@denotest/module_graph/1.4.0_meta.json [WILDCARD]Caching module info for http://[WILDLINE]/@denotest/module-graph/1.4.0/other.ts
[UNORDERED_START] [WILDCARD]
Download http://127.0.0.1:4250/@denotest/module_graph/1.4.0/other.ts
Download http://127.0.0.1:4250/@denotest/module_graph/1.4.0/mod.ts
[UNORDERED_END]
Test { other: Other {} } Test { other: Other {} }
[WILDCARD]

View file

@ -1,3 +1,3 @@
import { Test } from "jsr:@denotest/module_graph"; import { Test } from "jsr:@denotest/module-graph";
console.log(new Test()); console.log(new Test());

View file

@ -1,8 +1,8 @@
Download http://127.0.0.1:4250/@denotest/module_graph/meta.json Download http://127.0.0.1:4250/@denotest/module-graph/meta.json
Download http://127.0.0.1:4250/@denotest/module_graph/1.4.0_meta.json Download http://127.0.0.1:4250/@denotest/module-graph/1.4.0_meta.json
[UNORDERED_START] [UNORDERED_START]
Download http://127.0.0.1:4250/@denotest/module_graph/1.4.0/mod.ts Download http://127.0.0.1:4250/@denotest/module-graph/1.4.0/mod.ts
Download http://127.0.0.1:4250/@denotest/module_graph/1.4.0/other.ts Download http://127.0.0.1:4250/@denotest/module-graph/1.4.0/other.ts
[UNORDERED_END] [UNORDERED_END]
local: [WILDCARD]main.ts local: [WILDCARD]main.ts
type: TypeScript type: TypeScript
@ -10,5 +10,5 @@ dependencies: 2 unique
size: [WILDCARD] size: [WILDCARD]
file:///[WILDCARD]/module_graph/main.ts ([WILDCARD]) file:///[WILDCARD]/module_graph/main.ts ([WILDCARD])
└─┬ http://127.0.0.1:4250/@denotest/module_graph/1.4.0/mod.ts ([WILDCARD]) └─┬ http://127.0.0.1:4250/@denotest/module-graph/1.4.0/mod.ts ([WILDCARD])
└── http://127.0.0.1:4250/@denotest/module_graph/1.4.0/other.ts ([WILDCARD]) └── http://127.0.0.1:4250/@denotest/module-graph/1.4.0/other.ts ([WILDCARD])

View file

@ -0,0 +1,10 @@
{
"steps": [{
"args": "run --log-level=debug main.ts",
"output": "main.out"
}, {
"cleanDenoDir": true,
"args": "info main.ts",
"output": "main_info.out"
}]
}

View file

@ -0,0 +1,5 @@
[WILDCARD]Caching module info for http://[WILDLINE]/@denotest/module-graph2/1.4.0/mod.ts
[WILDCARD]Caching module info for http://[WILDLINE]/@denotest/module-graph2/1.4.0/other.ts
[WILDCARD]
Test { other: Other {} }
[WILDCARD]

View file

@ -0,0 +1,3 @@
import { Test } from "jsr:@denotest/module-graph2";
console.log(new Test());

View file

@ -0,0 +1,14 @@
Download http://127.0.0.1:4250/@denotest/module-graph2/meta.json
Download http://127.0.0.1:4250/@denotest/module-graph2/1.4.0_meta.json
[UNORDERED_START]
Download http://127.0.0.1:4250/@denotest/module-graph2/1.4.0/mod.ts
Download http://127.0.0.1:4250/@denotest/module-graph2/1.4.0/other.ts
[UNORDERED_END]
local: [WILDCARD]main.ts
type: TypeScript
dependencies: 2 unique
size: [WILDCARD]
file:///[WILDCARD]/module_graph2/main.ts ([WILDCARD])
└─┬ http://127.0.0.1:4250/@denotest/module-graph2/1.4.0/mod.ts ([WILDCARD])
└── http://127.0.0.1:4250/@denotest/module-graph2/1.4.0/other.ts ([WILDCARD])

View file

@ -1,6 +1,6 @@
Download http://127.0.0.1:4250/@denotest/no_module_graph/meta.json Download http://127.0.0.1:4250/@denotest/no-module-graph/meta.json
Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.0_meta.json Download http://127.0.0.1:4250/@denotest/no-module-graph/0.1.0_meta.json
Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.0/mod.ts Download http://127.0.0.1:4250/@denotest/no-module-graph/0.1.0/mod.ts
Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.0/TestClass.ts Download http://127.0.0.1:4250/@denotest/no-module-graph/0.1.0/TestClass.ts
0.1.0 0.1.0
TestClass {} TestClass {}

View file

@ -1,4 +1,4 @@
import version, { TestClass } from "jsr:@denotest/no_module_graph@0.1.0"; import version, { TestClass } from "jsr:@denotest/no-module-graph@0.1.0";
console.log(version); console.log(version);
console.log(new TestClass()); console.log(new TestClass());

View file

@ -1,12 +1,12 @@
Download http://127.0.0.1:4250/@denotest/no_module_graph/meta.json Download http://127.0.0.1:4250/@denotest/no-module-graph/meta.json
Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.0_meta.json Download http://127.0.0.1:4250/@denotest/no-module-graph/0.1.0_meta.json
Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.0/mod.ts Download http://127.0.0.1:4250/@denotest/no-module-graph/0.1.0/mod.ts
Download http://127.0.0.1:4250/@denotest/no_module_graph/0.1.0/TestClass.ts Download http://127.0.0.1:4250/@denotest/no-module-graph/0.1.0/TestClass.ts
local: [WILDCARD]main.ts local: [WILDCARD]main.ts
type: TypeScript type: TypeScript
dependencies: 2 unique dependencies: 2 unique
size: [WILDCARD] size: [WILDCARD]
file:///[WILDCARD]/jsr/no_module_graph/main.ts ([WILDCARD]) file:///[WILDCARD]/jsr/no_module_graph/main.ts ([WILDCARD])
└─┬ http://127.0.0.1:4250/@denotest/no_module_graph/0.1.0/mod.ts ([WILDCARD]) └─┬ http://127.0.0.1:4250/@denotest/no-module-graph/0.1.0/mod.ts ([WILDCARD])
└── http://127.0.0.1:4250/@denotest/no_module_graph/0.1.0/TestClass.ts ([WILDCARD]) └── http://127.0.0.1:4250/@denotest/no-module-graph/0.1.0/TestClass.ts ([WILDCARD])

View file

@ -1,5 +1,5 @@
import version1 from "jsr:@denotest/no_module_graph@0.1.0"; import version1 from "jsr:@denotest/no-module-graph@0.1.0";
import version2 from "jsr:@denotest/no_module_graph@^0.2"; import version2 from "jsr:@denotest/no-module-graph@^0.2";
console.log(version1); console.log(version1);
console.log(version2); console.log(version2);

View file

@ -1,5 +1,5 @@
import { Other } from "jsr:@denotest/module_graph@1/other"; import { Other } from "jsr:@denotest/module-graph@1/other";
import version from "jsr:@denotest/no_module_graph@^0.1"; import version from "jsr:@denotest/no-module-graph@^0.1";
export default { export default {
version, version,

View file

@ -8,13 +8,13 @@
"type": "static", "type": "static",
"kind": "import", "kind": "import",
"range": [[0, 0], [0, 59]], "range": [[0, 0], [0, 59]],
"specifier": "jsr:@denotest/module_graph@1/other", "specifier": "jsr:@denotest/module-graph@1/other",
"specifierRange": [[0, 22], [0, 58]] "specifierRange": [[0, 22], [0, 58]]
}, { }, {
"type": "static", "type": "static",
"kind": "import", "kind": "import",
"range": [[1, 0], [1, 57]], "range": [[1, 0], [1, 57]],
"specifier": "jsr:@denotest/no_module_graph@^0.1", "specifier": "jsr:@denotest/no-module-graph@^0.1",
"specifierRange": [[1, 20], [1, 56]] "specifierRange": [[1, 20], [1, 56]]
}] }]
} }

View file

@ -0,0 +1,5 @@
import { Other } from "./other.ts";
export class Test {
other = new Other();
}

View file

@ -0,0 +1,2 @@
export class Other {
}

View file

@ -0,0 +1,17 @@
{
"exports": {
".": "./mod.ts",
"./other": "./other.ts"
},
"moduleGraph2": {
"/mod.ts": {
"dependencies": [{
"kind": "import",
"type": "static",
"specifier": "./other.ts",
"specifierRange": [[0, 22], [0, 34]]
}]
},
"/other.ts": {}
}
}

View file

@ -0,0 +1,6 @@
{
"versions": {
"1.0.0": {},
"1.4.0": {}
}
}