chore(test): move npm registries to separate servers and to the tests/registry folder (#23717)

1. Moves the npm registries to their own dedicated ports.
2. Moves the data files out of `tests/testdata/npm/registry` to
`tests/registry/npm`.
This commit is contained in:
David Sherret 2024-05-06 21:06:01 -04:00 committed by GitHub
parent 87d1ead7d0
commit 1587387bcc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
725 changed files with 875 additions and 825 deletions

View file

@ -28,6 +28,7 @@
"cli/tsc/dts/lib.es*.d.ts",
"cli/tsc/dts/typescript.d.ts",
"tests/node_compat/test",
"tests/registry/",
"tests/testdata/file_extensions/ts_with_js_extension.js",
"tests/testdata/fmt/badly_formatted.json",
"tests/testdata/fmt/badly_formatted.md",
@ -41,7 +42,6 @@
"tests/testdata/run/error_syntax_empty_trailing_line.mjs",
"tests/testdata/run/inline_js_source_map*",
"tests/testdata/malformed_config/",
"tests/testdata/npm/registry/",
"tests/testdata/test/markdown_windows.md",
"cli/tsc/*typescript.js",
"gh-pages",

View file

@ -489,8 +489,7 @@ const ci = {
)
),
{
// only necessary for benchmarks
if: "matrix.job == 'bench'",
if: "matrix.job == 'bench' || matrix.job == 'test'",
...installNodeStep,
},
installProtocStep,

View file

@ -194,7 +194,7 @@ jobs:
Where-Object { Test-Path "$_\python.exe" } |
Select-Object -Skip 1 |
ForEach-Object { Move-Item "$_" "$_.disabled" }
- if: '!(matrix.skip) && (matrix.job == ''bench'')'
- if: '!(matrix.skip) && (matrix.job == ''bench'' || matrix.job == ''test'')'
name: Install Node
uses: actions/setup-node@v4
with:

View file

@ -39,8 +39,8 @@ fn cache_matching_package_json_dep_should_not_install_all() {
.args("cache npm:@types/node@18.8.2")
.run();
output.assert_matches_text(concat!(
"Download http://localhost:4545/npm/registry/@types/node\n",
"Download http://localhost:4545/npm/registry/@types/node/node-18.8.2.tgz\n",
"Download http://localhost:4558/@types/node\n",
"Download http://localhost:4558/@types/node/node-18.8.2.tgz\n",
"Initialize @types/node@18.8.2\n",
));
}

View file

@ -1083,8 +1083,8 @@ console.log(getValue());"#,
.run();
output.assert_exit_code(0);
output.assert_matches_text(
r#"Download http://localhost:4545/npm/registry/@denotest/esm-basic
Download http://localhost:4545/npm/registry/@denotest/esm-basic/1.0.0.tgz
r#"Download http://localhost:4558/@denotest/esm-basic
Download http://localhost:4558/@denotest/esm-basic/1.0.0.tgz
Initialize @denotest/esm-basic@1.0.0
Check file:///[WILDCARD]/main.ts
Compile file:///[WILDCARD]/main.ts to [WILDCARD]

View file

@ -921,9 +921,7 @@ fn node_modules_dir_cache() {
let package_global_cache_dir = deno_dir
.path()
.join("npm")
.join("localhost_4545")
.join("npm")
.join("registry")
.join("localhost_4558")
.join("@denotest")
.join("dual-cjs-esm")
.join("1.0.0");
@ -953,7 +951,7 @@ fn node_modules_dir_cache() {
#[test]
fn ensure_registry_files_local() {
// ensures the registry files all point at local tarballs
let registry_dir_path = util::testdata_path().join("npm").join("registry");
let registry_dir_path = util::tests_path().join("registry").join("npm");
for entry in std::fs::read_dir(&registry_dir_path).unwrap() {
let entry = entry.unwrap();
if entry.metadata().unwrap().is_dir() {
@ -1509,7 +1507,7 @@ fn auto_discover_lock_file() {
.run();
output
.assert_matches_text(
r#"Download http://localhost:4545/npm/registry/@denotest/bin
r#"Download http://localhost:4558/@denotest/bin
error: Integrity check failed for package: "npm:@denotest/bin@1.0.0". Unable to verify that the package
is the same as when the lockfile was generated.
@ -1548,9 +1546,7 @@ fn peer_deps_with_copied_folders_and_lockfile() {
let grandchild_path = deno_dir
.path()
.join("npm")
.join("localhost_4545")
.join("npm")
.join("registry")
.join("localhost_4558")
.join("@denotest")
.join("peer-dep-test-grandchild");
assert!(grandchild_path.join("1.0.0").exists());
@ -1664,8 +1660,8 @@ itest!(non_existent_dep {
exit_code: 1,
output_str: Some(concat!(
"[UNORDERED_START]\n",
"Download http://localhost:4545/npm/registry/@denotest/non-existent-dep\n",
"Download http://localhost:4545/npm/registry/@denotest/non-existent\n",
"Download http://localhost:4558/@denotest/non-existent-dep\n",
"Download http://localhost:4558/@denotest/non-existent\n",
"[UNORDERED_END]\n",
"error: npm package '@denotest/non-existent' does not exist.\n"
)),
@ -1678,14 +1674,14 @@ itest!(non_existent_dep_version {
exit_code: 1,
output_str: Some(concat!(
"[UNORDERED_START]\n",
"Download http://localhost:4545/npm/registry/@denotest/non-existent-dep-version\n",
"Download http://localhost:4545/npm/registry/@denotest/esm-basic\n",
"Download http://localhost:4558/@denotest/non-existent-dep-version\n",
"Download http://localhost:4558/@denotest/esm-basic\n",
"[UNORDERED_END]\n",
// does two downloads because when failing once it max tries to
// get the latest version a second time
"[UNORDERED_START]\n",
"Download http://localhost:4545/npm/registry/@denotest/non-existent-dep-version\n",
"Download http://localhost:4545/npm/registry/@denotest/esm-basic\n",
"Download http://localhost:4558/@denotest/non-existent-dep-version\n",
"Download http://localhost:4558/@denotest/esm-basic\n",
"[UNORDERED_END]\n",
"error: Could not find npm package '@denotest/esm-basic' matching '=99.99.99'.\n"
)),
@ -1710,7 +1706,7 @@ fn reload_info_not_found_cache_but_exists_remote() {
version: &str,
) {
let registry_json_path =
format!("npm/localhost_4545/npm/registry/{}/registry.json", package);
format!("npm/localhost_4558/{}/registry.json", package);
let mut registry_json: Value =
serde_json::from_str(&deno_dir.read_to_string(&registry_json_path))
.unwrap();
@ -1747,12 +1743,12 @@ fn reload_info_not_found_cache_but_exists_remote() {
.run();
output.assert_matches_text(concat!(
"[UNORDERED_START]\n",
"Download http://localhost:4545/npm/registry/@denotest/esm-basic\n",
"Download http://localhost:4545/npm/registry/@denotest/esm-import-cjs-default\n",
"Download http://localhost:4545/npm/registry/@denotest/cjs-default-export\n",
"Download http://localhost:4545/npm/registry/@denotest/cjs-default-export/1.0.0.tgz\n",
"Download http://localhost:4545/npm/registry/@denotest/esm-basic/1.0.0.tgz\n",
"Download http://localhost:4545/npm/registry/@denotest/esm-import-cjs-default/1.0.0.tgz\n",
"Download http://localhost:4558/@denotest/esm-basic\n",
"Download http://localhost:4558/@denotest/esm-import-cjs-default\n",
"Download http://localhost:4558/@denotest/cjs-default-export\n",
"Download http://localhost:4558/@denotest/cjs-default-export/1.0.0.tgz\n",
"Download http://localhost:4558/@denotest/esm-basic/1.0.0.tgz\n",
"Download http://localhost:4558/@denotest/esm-import-cjs-default/1.0.0.tgz\n",
"[UNORDERED_END]\n",
));
@ -1777,8 +1773,8 @@ fn reload_info_not_found_cache_but_exists_remote() {
let output = test_context.new_command().args("run main.ts").run();
output.assert_matches_text(concat!(
"[UNORDERED_START]\n",
"Download http://localhost:4545/npm/registry/@denotest/esm-import-cjs-default\n",
"Download http://localhost:4545/npm/registry/@denotest/cjs-default-export\n",
"Download http://localhost:4558/@denotest/esm-import-cjs-default\n",
"Download http://localhost:4558/@denotest/cjs-default-export\n",
"[UNORDERED_END]\n",
"Node esm importing node cjs\n[WILDCARD]",
));
@ -1809,8 +1805,8 @@ fn reload_info_not_found_cache_but_exists_remote() {
let output = test_context.new_command().args("run main.ts").run();
output.assert_matches_text(concat!(
"[UNORDERED_START]\n",
"Download http://localhost:4545/npm/registry/@denotest/esm-import-cjs-default\n",
"Download http://localhost:4545/npm/registry/@denotest/cjs-default-export\n",
"Download http://localhost:4558/@denotest/esm-import-cjs-default\n",
"Download http://localhost:4558/@denotest/cjs-default-export\n",
"[UNORDERED_END]\n",
"Node esm importing node cjs\n[WILDCARD]",
));
@ -1847,8 +1843,8 @@ fn reload_info_not_found_cache_but_exists_remote() {
let output = test_context.new_command().args("run main.ts").run();
output.assert_matches_text(concat!(
"[UNORDERED_START]\n",
"Download http://localhost:4545/npm/registry/@denotest/esm-import-cjs-default\n",
"Download http://localhost:4545/npm/registry/@denotest/cjs-default-export\n",
"Download http://localhost:4558/@denotest/esm-import-cjs-default\n",
"Download http://localhost:4558/@denotest/cjs-default-export\n",
"[UNORDERED_END]\n",
"[UNORDERED_START]\n",
"Initialize @denotest/cjs-default-export@1.0.0\n",
@ -1884,9 +1880,9 @@ fn reload_info_not_found_cache_but_exists_remote() {
let output = test_context.new_command().args("run main.ts").run();
output.assert_matches_text(concat!(
"[UNORDERED_START]\n",
"Download http://localhost:4545/npm/registry/@denotest/esm-basic\n",
"Download http://localhost:4545/npm/registry/@denotest/esm-import-cjs-default\n",
"Download http://localhost:4545/npm/registry/@denotest/cjs-default-export\n",
"Download http://localhost:4558/@denotest/esm-basic\n",
"Download http://localhost:4558/@denotest/esm-import-cjs-default\n",
"Download http://localhost:4558/@denotest/cjs-default-export\n",
"[UNORDERED_END]\n",
"Initialize @denotest/esm-basic@1.0.0\n",
"Node esm importing node cjs\n[WILDCARD]",
@ -1922,9 +1918,9 @@ fn reload_info_not_found_cache_but_exists_remote() {
let output = test_context.new_command().args("run main.ts").run();
output.assert_matches_text(concat!(
"[UNORDERED_START]\n",
"Download http://localhost:4545/npm/registry/@denotest/cjs-default-export\n",
"Download http://localhost:4545/npm/registry/@denotest/esm-basic\n",
"Download http://localhost:4545/npm/registry/@denotest/esm-import-cjs-default\n",
"Download http://localhost:4558/@denotest/cjs-default-export\n",
"Download http://localhost:4558/@denotest/esm-basic\n",
"Download http://localhost:4558/@denotest/esm-import-cjs-default\n",
"[UNORDERED_END]\n",
"Node esm importing node cjs\n[WILDCARD]",
));
@ -2103,13 +2099,11 @@ fn top_level_install_package_json_explicit_opt_in() {
temp_dir.write("main.ts", "console.log(5);");
let output = test_context.new_command().args("cache main.ts").run();
output.assert_matches_text(
concat!(
"Download http://localhost:4545/npm/registry/@denotest/esm-basic\n",
"Download http://localhost:4545/npm/registry/@denotest/esm-basic/1.0.0.tgz\n",
"Initialize @denotest/esm-basic@1.0.0\n",
)
);
output.assert_matches_text(concat!(
"Download http://localhost:4558/@denotest/esm-basic\n",
"Download http://localhost:4558/@denotest/esm-basic/1.0.0.tgz\n",
"Initialize @denotest/esm-basic@1.0.0\n",
));
rm_created_files();
let output = test_context
@ -3093,9 +3087,7 @@ async fn test_private_npm_registry() {
let client = reqwest::Client::new();
let url =
Url::parse("http://127.0.0.1:4252/npm/registry/@denotest/bin/0.5.0")
.unwrap();
let url = Url::parse("http://127.0.0.1:4559/@denotest2/basic").unwrap();
let req = reqwest::Request::new(reqwest::Method::GET, url.clone());
let resp = client.execute(req).await.unwrap();

View file

@ -975,12 +975,11 @@ fn lock_redirects() {
.new_command()
.args("run main.ts Hi there")
.run()
.assert_matches_text(
concat!(
"Download http://localhost:4545/echo.ts\n",
"Download http://localhost:4545/npm/registry/@denotest/esm-basic\n",
"Download http://localhost:4545/npm/registry/@denotest/esm-basic/1.0.0.tgz\n",
"Hi, there",
.assert_matches_text(concat!(
"Download http://localhost:4545/echo.ts\n",
"Download http://localhost:4558/@denotest/esm-basic\n",
"Download http://localhost:4558/@denotest/esm-basic/1.0.0.tgz\n",
"Hi, there",
));
util::assertions::assert_wildcard_match(
&temp_dir.read_to_string("deno.lock"),
@ -5217,7 +5216,7 @@ fn code_cache_npm_test() {
output
.assert_stdout_matches_text("Hello World[WILDCARD]")
.assert_stderr_matches_text("[WILDCARD]Updating V8 code cache for ES module: file:///[WILDCARD]/main.js[WILDCARD]")
.assert_stderr_matches_text("[WILDCARD]Updating V8 code cache for ES module: file:///[WILDCARD]/npm/registry/chalk/5.[WILDCARD]/source/index.js[WILDCARD]");
.assert_stderr_matches_text("[WILDCARD]Updating V8 code cache for ES module: file:///[WILDCARD]/chalk/5.[WILDCARD]/source/index.js[WILDCARD]");
assert!(!output.stderr().contains("V8 code cache hit"));
// Check that the code cache database exists.
@ -5241,7 +5240,7 @@ fn code_cache_npm_test() {
output
.assert_stdout_matches_text("Hello World[WILDCARD]")
.assert_stderr_matches_text("[WILDCARD]V8 code cache hit for ES module: file:///[WILDCARD]/main.js[WILDCARD]")
.assert_stderr_matches_text("[WILDCARD]V8 code cache hit for ES module: file:///[WILDCARD]/npm/registry/chalk/5.[WILDCARD]/source/index.js[WILDCARD]");
.assert_stderr_matches_text("[WILDCARD]V8 code cache hit for ES module: file:///[WILDCARD]/chalk/5.[WILDCARD]/source/index.js[WILDCARD]");
assert!(!output.stderr().contains("Updating V8 code cache"));
}
}
@ -5275,9 +5274,9 @@ fn code_cache_npm_with_require_test() {
output
.assert_stdout_matches_text("function[WILDCARD]")
.assert_stderr_matches_text("[WILDCARD]Updating V8 code cache for ES module: file:///[WILDCARD]/main.js[WILDCARD]")
.assert_stderr_matches_text("[WILDCARD]Updating V8 code cache for ES module: file:///[WILDCARD]/npm/registry/autoprefixer/[WILDCARD]/autoprefixer.js[WILDCARD]")
.assert_stderr_matches_text("[WILDCARD]Updating V8 code cache for script: file:///[WILDCARD]/npm/registry/autoprefixer/[WILDCARD]/autoprefixer.js[WILDCARD]")
.assert_stderr_matches_text("[WILDCARD]Updating V8 code cache for script: file:///[WILDCARD]/npm/registry/browserslist/[WILDCARD]/index.js[WILDCARD]");
.assert_stderr_matches_text("[WILDCARD]Updating V8 code cache for ES module: file:///[WILDCARD]/autoprefixer/[WILDCARD]/autoprefixer.js[WILDCARD]")
.assert_stderr_matches_text("[WILDCARD]Updating V8 code cache for script: file:///[WILDCARD]/autoprefixer/[WILDCARD]/autoprefixer.js[WILDCARD]")
.assert_stderr_matches_text("[WILDCARD]Updating V8 code cache for script: file:///[WILDCARD]/browserslist/[WILDCARD]/index.js[WILDCARD]");
assert!(!output.stderr().contains("V8 code cache hit"));
// Check that the code cache database exists.
@ -5301,9 +5300,9 @@ fn code_cache_npm_with_require_test() {
output
.assert_stdout_matches_text("function[WILDCARD]")
.assert_stderr_matches_text("[WILDCARD]V8 code cache hit for ES module: file:///[WILDCARD]/main.js[WILDCARD]")
.assert_stderr_matches_text("[WILDCARD]V8 code cache hit for ES module: file:///[WILDCARD]/npm/registry/autoprefixer/[WILDCARD]/autoprefixer.js[WILDCARD]")
.assert_stderr_matches_text("[WILDCARD]V8 code cache hit for script: file:///[WILDCARD]/npm/registry/autoprefixer/[WILDCARD]/autoprefixer.js[WILDCARD]")
.assert_stderr_matches_text("[WILDCARD]V8 code cache hit for script: file:///[WILDCARD]/npm/registry/browserslist/[WILDCARD]/index.js[WILDCARD]");
.assert_stderr_matches_text("[WILDCARD]V8 code cache hit for ES module: file:///[WILDCARD]/autoprefixer/[WILDCARD]/autoprefixer.js[WILDCARD]")
.assert_stderr_matches_text("[WILDCARD]V8 code cache hit for script: file:///[WILDCARD]/autoprefixer/[WILDCARD]/autoprefixer.js[WILDCARD]")
.assert_stderr_matches_text("[WILDCARD]V8 code cache hit for script: file:///[WILDCARD]/browserslist/[WILDCARD]/index.js[WILDCARD]");
assert!(!output.stderr().contains("Updating V8 code cache"));
}
}

View file

@ -576,22 +576,20 @@ fn vendor_npm_node_specifiers() {
temp_dir.write("deno.json", "{}");
let output = context.new_command().args("vendor my_app.ts").run();
output.assert_matches_text(
format!(
concat!(
"Download http://localhost:4545/vendor/npm_and_node_specifier.ts\n",
"Download http://localhost:4545/npm/registry/@denotest/esm-basic\n",
"Download http://localhost:4545/npm/registry/@denotest/esm-basic/1.0.0.tgz\n",
"{}\n",
"Initialize @denotest/esm-basic@1.0.0\n",
"{}\n\n",
"{}\n",
),
vendored_text("1 module", "vendor/"),
vendored_npm_package_text("1 npm package"),
success_text_updated_deno_json("vendor/")
)
);
output.assert_matches_text(format!(
concat!(
"Download http://localhost:4545/vendor/npm_and_node_specifier.ts\n",
"Download http://localhost:4558/@denotest/esm-basic\n",
"Download http://localhost:4558/@denotest/esm-basic/1.0.0.tgz\n",
"{}\n",
"Initialize @denotest/esm-basic@1.0.0\n",
"{}\n\n",
"{}\n",
),
vendored_text("1 module", "vendor/"),
vendored_npm_package_text("1 npm package"),
success_text_updated_deno_json("vendor/")
));
let output = context.new_command().args("run -A my_app.ts").run();
output.assert_matches_text("true 5\n");
assert!(temp_dir.path().join("node_modules").exists());
@ -652,19 +650,17 @@ fn vendor_only_npm_specifiers() {
temp_dir.write("deno.json", "{}");
let output = context.new_command().args("vendor my_app.ts").run();
output.assert_matches_text(
format!(
concat!(
"Download http://localhost:4545/npm/registry/@denotest/esm-basic\n",
"Download http://localhost:4545/npm/registry/@denotest/esm-basic/1.0.0.tgz\n",
"{}\n",
"Initialize @denotest/esm-basic@1.0.0\n",
"{}\n",
),
vendored_text("0 modules", "vendor/"),
vendored_npm_package_text("1 npm package"),
)
);
output.assert_matches_text(format!(
concat!(
"Download http://localhost:4558/@denotest/esm-basic\n",
"Download http://localhost:4558/@denotest/esm-basic/1.0.0.tgz\n",
"{}\n",
"Initialize @denotest/esm-basic@1.0.0\n",
"{}\n",
),
vendored_text("0 modules", "vendor/"),
vendored_npm_package_text("1 npm package"),
));
}
fn success_text(module_count: &str, dir: &str, has_import_map: bool) -> String {

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show more