diff --git a/.dprint.json b/.dprint.json index a6a03055702c4..4e32c747bf3b7 100644 --- a/.dprint.json +++ b/.dprint.json @@ -59,7 +59,7 @@ "plugins": [ "https://plugins.dprint.dev/typescript-0.90.4.wasm", "https://plugins.dprint.dev/json-0.19.2.wasm", - "https://plugins.dprint.dev/markdown-0.16.4.wasm", + "https://plugins.dprint.dev/markdown-0.17.0.wasm", "https://plugins.dprint.dev/toml-0.6.1.wasm", "https://plugins.dprint.dev/exec-0.4.4.json@c207bf9b9a4ee1f0ecb75c594f774924baf62e8e53a2ce9d873816a408cecbf7" ] diff --git a/.github/workflows/ci.generate.ts b/.github/workflows/ci.generate.ts index da9c55ff7740e..2ee48d511531a 100755 --- a/.github/workflows/ci.generate.ts +++ b/.github/workflows/ci.generate.ts @@ -664,6 +664,12 @@ const ci = { run: "deno run --unstable --allow-write --allow-read --allow-run --allow-net ./tools/lint.js", }, + { + name: "jsdoc_checker.js", + if: "matrix.job == 'lint'", + run: + "deno run --allow-read --allow-env --allow-sys ./tools/jsdoc_checker.js", + }, { name: "node_compat/setup.ts --check", if: "matrix.job == 'lint' && matrix.os == 'linux'", diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a670a66a98271..4709abf481433 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -396,6 +396,9 @@ jobs: - name: lint.js if: '!(matrix.skip) && (matrix.job == ''lint'')' run: deno run --unstable --allow-write --allow-read --allow-run --allow-net ./tools/lint.js + - name: jsdoc_checker.js + if: '!(matrix.skip) && (matrix.job == ''lint'')' + run: deno run --allow-read --allow-env --allow-sys ./tools/jsdoc_checker.js - name: node_compat/setup.ts --check if: '!(matrix.skip) && (matrix.job == ''lint'' && matrix.os == ''linux'')' run: deno run --allow-write --allow-read --allow-run=git ./tests/node_compat/runner/setup.ts --check diff --git a/Cargo.lock b/Cargo.lock index c1bbd41df114d..1eea1d20ea001 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1272,9 +1272,9 @@ dependencies = [ [[package]] name = "deno_config" -version = "0.16.1" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc55559b6b4ebf190c75ad76a4204c792ac27e64e83e685fb5f4e4317bb94c5" +checksum = "f28ad258b58ade470cd745191eacee35562db3c967ffb26b4aa6f0f88f0882dd" dependencies = [ "anyhow", "glob", @@ -1399,6 +1399,7 @@ dependencies = [ "regex", "serde", "serde_json", + "syntect", "termcolor", ] @@ -2277,9 +2278,9 @@ dependencies = [ [[package]] name = "dprint-plugin-markdown" -version = "0.16.4" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9153b4bd411eea99ed14afa19b7aede250594d96a6ebeee3130b18b575a9ac7" +checksum = "2b2642e4a5f3a2262bb9baef8739f90d99b73ca21bc65f46c320a7817fd65438" dependencies = [ "anyhow", "dprint-core", @@ -2633,9 +2634,9 @@ checksum = "c007b1ae3abe1cb6f85a16305acd418b7ca6343b953633fee2b76d8f108b830f" [[package]] name = "file_test_runner" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b66e9ef00f9f6b82b030b7a9d659030f73498921d4c021b0772e75dfd7090d80" +checksum = "5f33b00489de0a5fd03df89aefe9fa55da5da3c1a207ea19cd381d1de7e6204b" dependencies = [ "anyhow", "crossbeam-channel", @@ -4362,6 +4363,28 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "onig" +version = "6.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f" +dependencies = [ + "bitflags 1.3.2", + "libc", + "once_cell", + "onig_sys", +] + +[[package]] +name = "onig_sys" +version = "69.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b829e3d7e9cc74c7e315ee8edb185bf4190da5acde74afd7fc59c35b1f086e7" +dependencies = [ + "cc", + "pkg-config", +] + [[package]] name = "opaque-debug" version = "0.3.1" @@ -6480,6 +6503,26 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "syntect" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "874dcfa363995604333cf947ae9f751ca3af4522c60886774c4963943b4746b1" +dependencies = [ + "bincode", + "bitflags 1.3.2", + "flate2", + "fnv", + "once_cell", + "onig", + "regex-syntax", + "serde", + "serde_derive", + "serde_json", + "thiserror", + "walkdir", +] + [[package]] name = "tap" version = "1.0.1" @@ -6555,7 +6598,6 @@ dependencies = [ "base64", "bytes", "console_static_text", - "deno_tls", "deno_unsync", "denokv_proto", "fastwebsockets", @@ -6581,6 +6623,8 @@ dependencies = [ "prost-build", "regex", "reqwest", + "rustls-pemfile", + "rustls-tokio-stream", "semver 1.0.14", "serde", "serde_json", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 761be4d069103..605b1075ec4ba 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -65,9 +65,9 @@ winres.workspace = true [dependencies] deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] } deno_cache_dir = { workspace = true } -deno_config = "=0.16.1" +deno_config = "=0.16.2" deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] } -deno_doc = { version = "=0.128.1", features = ["html"] } +deno_doc = { version = "=0.128.1", features = ["html", "syntect"] } deno_emit = "=0.40.1" deno_graph = { version = "=0.74.0", features = ["tokio_executor"] } deno_lint = { version = "=0.58.4", features = ["docs"] } @@ -98,7 +98,7 @@ dissimilar = "=1.0.4" dotenvy = "0.15.7" dprint-plugin-json = "=0.19.2" dprint-plugin-jupyter = "=0.1.3" -dprint-plugin-markdown = "=0.16.4" +dprint-plugin-markdown = "=0.17.0" dprint-plugin-typescript = "=0.90.4" env_logger = "=0.10.0" fancy-regex = "=0.10.0" diff --git a/cli/args/mod.rs b/cli/args/mod.rs index bb0ef1abac892..1d8b06f49d201 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -943,7 +943,7 @@ impl CliOptions { &self, ) -> Result, AnyError> { match self.overrides.import_map_specifier.clone() { - Some(maybe_path) => Ok(maybe_path), + Some(maybe_url) => Ok(maybe_url), None => resolve_import_map_specifier( self.flags.import_map_path.as_deref(), self.maybe_config_file.as_ref(), diff --git a/cli/cache/mod.rs b/cli/cache/mod.rs index 6ddeced9a67b8..cee93bac554c4 100644 --- a/cli/cache/mod.rs +++ b/cli/cache/mod.rs @@ -296,6 +296,7 @@ impl Loader for FetchCacher { source: &Arc<[u8]>, module_info: &deno_graph::ModuleInfo, ) { + log::debug!("Caching module info for {}", specifier); let source_hash = ModuleInfoCacheSourceHash::from_source(source); let result = self.module_info_cache.set_module_info( specifier, diff --git a/cli/lsp/analysis.rs b/cli/lsp/analysis.rs index 9ea8d710e0586..63d39ad6e379d 100644 --- a/cli/lsp/analysis.rs +++ b/cli/lsp/analysis.rs @@ -4,11 +4,10 @@ use super::diagnostics::DenoDiagnostic; use super::diagnostics::DiagnosticSource; use super::documents::Documents; use super::language_server; +use super::resolver::LspResolver; use super::tsc; use crate::args::jsr_url; -use crate::npm::CliNpmResolver; -use crate::resolver::CliNodeResolver; use crate::tools::lint::create_linter; use deno_runtime::fs_util::specifier_to_file_path; @@ -27,7 +26,6 @@ use deno_lint::diagnostic::LintDiagnostic; use deno_lint::rules::LintRule; use deno_runtime::deno_node::NpmResolver; use deno_runtime::deno_node::PathClean; -use deno_runtime::permissions::PermissionsContainer; use deno_semver::jsr::JsrPackageNvReference; use deno_semver::jsr::JsrPackageReqReference; use deno_semver::npm::NpmPackageReqReference; @@ -217,22 +215,19 @@ fn code_as_string(code: &Option) -> String { pub struct TsResponseImportMapper<'a> { documents: &'a Documents, maybe_import_map: Option<&'a ImportMap>, - node_resolver: Option<&'a CliNodeResolver>, - npm_resolver: Option<&'a dyn CliNpmResolver>, + resolver: &'a LspResolver, } impl<'a> TsResponseImportMapper<'a> { pub fn new( documents: &'a Documents, maybe_import_map: Option<&'a ImportMap>, - node_resolver: Option<&'a CliNodeResolver>, - npm_resolver: Option<&'a dyn CliNpmResolver>, + resolver: &'a LspResolver, ) -> Self { Self { documents, maybe_import_map, - node_resolver, - npm_resolver, + resolver, } } @@ -304,9 +299,7 @@ impl<'a> TsResponseImportMapper<'a> { return Some(spec_str); } - if let Some(npm_resolver) = - self.npm_resolver.as_ref().and_then(|r| r.as_managed()) - { + if let Some(npm_resolver) = self.resolver.maybe_managed_npm_resolver() { if npm_resolver.in_npm_package(specifier) { if let Ok(Some(pkg_id)) = npm_resolver.resolve_pkg_id_from_specifier(specifier) @@ -370,9 +363,9 @@ impl<'a> TsResponseImportMapper<'a> { &self, specifier: &ModuleSpecifier, ) -> Option { - let node_resolver = self.node_resolver?; - let package_json = node_resolver - .get_closest_package_json(specifier, &PermissionsContainer::allow_all()) + let package_json = self + .resolver + .get_closest_package_json(specifier) .ok() .flatten()?; let root_folder = package_json.path.parent()?; diff --git a/cli/lsp/completions.rs b/cli/lsp/completions.rs index a4a7c81c16c8c..f9d2316ae52cb 100644 --- a/cli/lsp/completions.rs +++ b/cli/lsp/completions.rs @@ -1,7 +1,7 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use super::client::Client; -use super::config::ConfigSnapshot; +use super::config::Config; use super::config::WorkspaceSettings; use super::documents::Documents; use super::documents::DocumentsFilter; @@ -148,7 +148,7 @@ fn to_narrow_lsp_range( pub async fn get_import_completions( specifier: &ModuleSpecifier, position: &lsp::Position, - config: &ConfigSnapshot, + config: &Config, client: &Client, module_registries: &ModuleRegistry, jsr_search_api: &CliJsrSearchApi, diff --git a/cli/lsp/config.rs b/cli/lsp/config.rs index 2bbd3ea7e9748..5ddc41cb22d62 100644 --- a/cli/lsp/config.rs +++ b/cli/lsp/config.rs @@ -726,53 +726,6 @@ impl WorkspaceSettings { } } -#[derive(Debug, Clone, Default)] -pub struct ConfigSnapshot { - pub client_capabilities: ClientCapabilities, - pub settings: Settings, - pub workspace_folders: Vec<(ModuleSpecifier, lsp::WorkspaceFolder)>, - pub tree: ConfigTree, -} - -impl ConfigSnapshot { - pub fn workspace_settings_for_specifier( - &self, - specifier: &ModuleSpecifier, - ) -> &WorkspaceSettings { - self.settings.get_for_specifier(specifier).0 - } - - /// Determine if the provided specifier is enabled or not. - pub fn specifier_enabled(&self, specifier: &ModuleSpecifier) -> bool { - let config_file = self.tree.config_file_for_specifier(specifier); - if let Some(cf) = config_file { - if let Ok(files) = cf.to_files_config() { - if !files.matches_specifier(specifier) { - return false; - } - } - } - self - .settings - .specifier_enabled(specifier) - .unwrap_or_else(|| config_file.is_some()) - } - - pub fn specifier_enabled_for_test( - &self, - specifier: &ModuleSpecifier, - ) -> bool { - if let Some(cf) = self.tree.config_file_for_specifier(specifier) { - if let Some(options) = cf.to_test_config().ok().flatten() { - if !options.files.matches_specifier(specifier) { - return false; - } - } - } - self.specifier_enabled(specifier) - } -} - #[derive(Debug, Default, Clone)] pub struct Settings { pub unscoped: WorkspaceSettings, @@ -982,15 +935,6 @@ impl Config { self.workspace_folders.first().map(|p| &p.0) } - pub fn snapshot(&self) -> Arc { - Arc::new(ConfigSnapshot { - client_capabilities: self.client_capabilities.clone(), - settings: self.settings.clone(), - workspace_folders: self.workspace_folders.clone(), - tree: self.tree.clone(), - }) - } - pub fn specifier_enabled(&self, specifier: &ModuleSpecifier) -> bool { let config_file = self.tree.config_file_for_specifier(specifier); if let Some(cf) = config_file { @@ -1150,6 +1094,7 @@ pub enum ConfigWatchedFileType { /// Contains the config file and dependent information. #[derive(Debug, Clone)] pub struct ConfigData { + pub scope: ModuleSpecifier, pub config_file: Option>, pub fmt_options: Arc, pub lint_options: Arc, @@ -1487,6 +1432,7 @@ impl ConfigData { let ts_config = LspTsConfig::new(config_file.as_ref(), import_map.as_ref()); ConfigData { + scope: scope.clone(), config_file: config_file.map(Arc::new), fmt_options, lint_options, @@ -1803,8 +1749,7 @@ mod tests { .unwrap(), vec![], ); - let config_snapshot = config.snapshot(); - assert!(config_snapshot.specifier_enabled(&specifier)); + assert!(config.specifier_enabled(&specifier)); } #[test] @@ -1820,9 +1765,6 @@ mod tests { config.set_workspace_settings(workspace_settings, vec![]); assert!(config.specifier_enabled(&specifier_a)); assert!(!config.specifier_enabled(&specifier_b)); - let config_snapshot = config.snapshot(); - assert!(config_snapshot.specifier_enabled(&specifier_a)); - assert!(!config_snapshot.specifier_enabled(&specifier_b)); } #[test] @@ -2144,35 +2086,4 @@ mod tests { !config.specifier_enabled_for_test(&root_uri.join("mod2.ts").unwrap()) ); } - - #[tokio::test] - async fn config_snapshot_specifier_enabled_for_test() { - let root_uri = resolve_url("file:///root/").unwrap(); - let mut config = Config::new_with_roots(vec![root_uri.clone()]); - config.settings.unscoped.enable = Some(true); - config - .tree - .inject_config_file( - ConfigFile::new( - &json!({ - "exclude": ["mod2.ts"], - "test": { - "exclude": ["mod3.ts"], - }, - }) - .to_string(), - root_uri.join("deno.json").unwrap(), - &deno_config::ParseOptions::default(), - ) - .unwrap(), - ) - .await; - let config_snapshot = config.snapshot(); - assert!(config_snapshot - .specifier_enabled_for_test(&root_uri.join("mod1.ts").unwrap())); - assert!(!config_snapshot - .specifier_enabled_for_test(&root_uri.join("mod2.ts").unwrap())); - assert!(!config_snapshot - .specifier_enabled_for_test(&root_uri.join("mod3.ts").unwrap())); - } } diff --git a/cli/lsp/diagnostics.rs b/cli/lsp/diagnostics.rs index b4422d493efdd..87bb72d1e53d7 100644 --- a/cli/lsp/diagnostics.rs +++ b/cli/lsp/diagnostics.rs @@ -3,7 +3,7 @@ use super::analysis; use super::cache; use super::client::Client; -use super::config::ConfigSnapshot; +use super::config::Config; use super::documents; use super::documents::Document; use super::documents::DocumentsFilter; @@ -62,7 +62,6 @@ use tower_lsp::lsp_types as lsp; #[derive(Debug)] pub struct DiagnosticServerUpdateMessage { pub snapshot: Arc, - pub config: Arc, pub url_map: LspUrlMap, } @@ -458,12 +457,7 @@ impl DiagnosticsServer { } }; let ChannelUpdateMessage { - message: - DiagnosticServerUpdateMessage { - snapshot, - config, - url_map, - }, + message: DiagnosticServerUpdateMessage { snapshot, url_map }, batch_index, } = message; let url_map = Arc::new(url_map); @@ -480,7 +474,7 @@ impl DiagnosticsServer { let token = token.clone(); let ts_diagnostics_store = ts_diagnostics_store.clone(); let snapshot = snapshot.clone(); - let config = config.clone(); + let config = snapshot.config.clone(); let url_map = url_map.clone(); async move { if let Some(previous_handle) = previous_ts_handle { @@ -555,7 +549,7 @@ impl DiagnosticsServer { let diagnostics_publisher = diagnostics_publisher.clone(); let token = token.clone(); let snapshot = snapshot.clone(); - let config = config.clone(); + let config = snapshot.config.clone(); let url_map = url_map.clone(); async move { if let Some(previous_handle) = previous_deps_handle { @@ -604,7 +598,7 @@ impl DiagnosticsServer { let diagnostics_publisher = diagnostics_publisher.clone(); let token = token.clone(); let snapshot = snapshot.clone(); - let config = config.clone(); + let config = snapshot.config.clone(); let url_map = url_map.clone(); async move { if let Some(previous_handle) = previous_lint_handle { @@ -784,7 +778,7 @@ fn ts_json_to_diagnostics( fn generate_lint_diagnostics( snapshot: &language_server::StateSnapshot, - config: &ConfigSnapshot, + config: &Config, token: CancellationToken, ) -> DiagnosticVec { let documents = snapshot @@ -809,10 +803,8 @@ fn generate_lint_diagnostics( break; } // ignore any npm package files - if let Some(npm) = &snapshot.npm { - if npm.node_resolver.in_npm_package(specifier) { - continue; - } + if snapshot.resolver.in_npm_package(specifier) { + continue; } let version = document.maybe_lsp_version(); let (lint_options, lint_rules) = config @@ -867,7 +859,7 @@ fn generate_document_lint_diagnostics( async fn generate_ts_diagnostics( snapshot: Arc, - config: &ConfigSnapshot, + config: &Config, ts_server: &tsc::TsServer, token: CancellationToken, ) -> Result { @@ -1347,6 +1339,7 @@ fn diagnose_resolution( diagnostics.push(DenoDiagnostic::DenoWarn(message)); } } + let managed_npm_resolver = snapshot.resolver.maybe_managed_npm_resolver(); if let Some(doc) = snapshot.documents.get(specifier) { if let Some(diagnostic) = check_redirect_diagnostic(specifier, &doc) { diagnostics.push(diagnostic); @@ -1375,11 +1368,7 @@ fn diagnose_resolution( } else if let Ok(pkg_ref) = NpmPackageReqReference::from_specifier(specifier) { - if let Some(npm_resolver) = snapshot - .npm - .as_ref() - .and_then(|n| n.npm_resolver.as_managed()) - { + if let Some(npm_resolver) = managed_npm_resolver { // show diagnostics for npm package references that aren't cached let req = pkg_ref.into_inner().req; if !npm_resolver.is_pkg_req_folder_cached(&req) { @@ -1406,11 +1395,7 @@ fn diagnose_resolution( diagnostics .push(DenoDiagnostic::BareNodeSpecifier(module_name.to_string())); } - } else if let Some(npm_resolver) = snapshot - .npm - .as_ref() - .and_then(|n| n.npm_resolver.as_managed()) - { + } else if let Some(npm_resolver) = managed_npm_resolver { // check that a @types/node package exists in the resolver let types_node_req = PackageReq::from_str("@types/node").unwrap(); if !npm_resolver.is_pkg_req_folder_cached(&types_node_req) { @@ -1451,10 +1436,8 @@ fn diagnose_dependency( dependency_key: &str, dependency: &deno_graph::Dependency, ) { - if let Some(npm) = &snapshot.npm { - if npm.npm_resolver.in_npm_package(referrer) { - return; // ignore, surface typescript errors instead - } + if snapshot.resolver.in_npm_package(referrer) { + return; // ignore, surface typescript errors instead } let import_map = snapshot.config.tree.root_import_map(); @@ -1543,7 +1526,7 @@ fn diagnose_dependency( /// an import map to shorten an URL. fn generate_deno_diagnostics( snapshot: &language_server::StateSnapshot, - config: &ConfigSnapshot, + config: &Config, token: CancellationToken, ) -> DiagnosticVec { let mut diagnostics_vec = Vec::new(); @@ -1586,12 +1569,12 @@ mod tests { use crate::cache::GlobalHttpCache; use crate::cache::RealDenoCacheEnv; use crate::lsp::config::Config; - use crate::lsp::config::ConfigSnapshot; use crate::lsp::config::Settings; use crate::lsp::config::WorkspaceSettings; use crate::lsp::documents::Documents; use crate::lsp::documents::LanguageId; use crate::lsp::language_server::StateSnapshot; + use crate::lsp::resolver::LspResolver; use deno_config::ConfigFile; use pretty_assertions::assert_eq; use std::path::Path; @@ -1630,6 +1613,9 @@ mod tests { .unwrap(); config.tree.inject_config_file(config_file).await; } + let resolver = LspResolver::default() + .with_new_config(&config, None, None) + .await; StateSnapshot { project_version: 0, documents, @@ -1637,14 +1623,14 @@ mod tests { cache_metadata: cache::CacheMetadata::new(Arc::new( GlobalHttpCache::new(location.to_path_buf(), RealDenoCacheEnv), )), - config: config.snapshot(), - npm: None, + config: Arc::new(config), + resolver, } } - fn mock_config() -> ConfigSnapshot { + fn mock_config() -> Config { let root_uri = resolve_url("file:///").unwrap(); - ConfigSnapshot { + Config { settings: Settings { unscoped: WorkspaceSettings { enable: Some(true), diff --git a/cli/lsp/documents.rs b/cli/lsp/documents.rs index 2de2a4406097a..71cc63f836065 100644 --- a/cli/lsp/documents.rs +++ b/cli/lsp/documents.rs @@ -3,22 +3,17 @@ use super::cache::calculate_fs_version; use super::cache::LSP_DISALLOW_GLOBAL_TO_LOCAL_COPY; use super::config::Config; -use super::language_server::StateNpmSnapshot; +use super::resolver::LspResolver; use super::testing::TestCollector; use super::testing::TestModule; use super::text::LineIndex; use super::tsc; use super::tsc::AssetDocument; -use crate::args::package_json; use crate::cache::HttpCache; use crate::graph_util::CliJsrUrlProvider; use crate::jsr::JsrCacheResolver; use crate::lsp::logging::lsp_warn; -use crate::npm::CliNpmResolver; -use crate::resolver::CliGraphResolver; -use crate::resolver::CliGraphResolverOptions; -use crate::resolver::CliNodeResolver; use crate::resolver::SloppyImportsFsEntry; use crate::resolver::SloppyImportsResolution; use crate::resolver::SloppyImportsResolver; @@ -43,12 +38,10 @@ use deno_lockfile::Lockfile; use deno_runtime::deno_node; use deno_runtime::deno_node::NodeResolution; use deno_runtime::deno_node::NodeResolutionMode; -use deno_runtime::permissions::PermissionsContainer; use deno_semver::jsr::JsrPackageReqReference; use deno_semver::npm::NpmPackageReqReference; use deno_semver::package::PackageReq; use indexmap::IndexMap; -use package_json::PackageJsonDepsProvider; use std::borrow::Cow; use std::collections::BTreeSet; use std::collections::HashMap; @@ -294,7 +287,7 @@ pub struct Document { media_type: MediaType, /// Present if and only if this is an open document. open_data: Option, - resolver: Arc, + resolver: Arc, specifier: ModuleSpecifier, text_info: SourceTextInfo, } @@ -308,8 +301,7 @@ impl Document { maybe_lsp_version: Option, maybe_language_id: Option, maybe_headers: Option>, - resolver: Arc, - maybe_node_resolver: Option<&CliNodeResolver>, + resolver: Arc, config: Arc, cache: &Arc, ) -> Arc { @@ -318,7 +310,7 @@ impl Document { &specifier, maybe_headers.as_ref(), maybe_language_id, - maybe_node_resolver, + &resolver, ); let (maybe_parsed_source, maybe_module) = if media_type_is_diagnosable(media_type) { @@ -366,17 +358,14 @@ impl Document { fn with_new_config( &self, - resolver: Arc, - maybe_node_resolver: Option<&CliNodeResolver>, + resolver: Arc, config: Arc, ) -> Arc { - let graph_resolver = resolver.as_graph_resolver(); - let npm_resolver = resolver.as_graph_npm_resolver(); let media_type = resolve_media_type( &self.specifier, self.maybe_headers.as_ref(), self.maybe_language_id, - maybe_node_resolver, + &resolver, ); let dependencies; let maybe_types_dependency; @@ -403,6 +392,8 @@ impl Document { maybe_test_module_fut = get_maybe_test_module_fut(maybe_parsed_source.as_ref(), &config); } else { + let graph_resolver = resolver.as_graph_resolver(); + let npm_resolver = resolver.as_graph_npm_resolver(); dependencies = Arc::new( self .dependencies @@ -682,20 +673,19 @@ fn resolve_media_type( specifier: &ModuleSpecifier, maybe_headers: Option<&HashMap>, maybe_language_id: Option, - maybe_node_resolver: Option<&CliNodeResolver>, + resolver: &LspResolver, ) -> MediaType { - if let Some(node_resolver) = maybe_node_resolver { - if node_resolver.in_npm_package(specifier) { - match node_resolver.url_to_node_resolution(specifier.clone()) { - Ok(resolution) => { - let (_, media_type) = - NodeResolution::into_specifier_and_media_type(Some(resolution)); - return media_type; - } - Err(err) => { - lsp_warn!("Node resolution failed for '{}': {}", specifier, err); - } + if resolver.in_npm_package(specifier) { + match resolver.url_to_node_resolution(specifier.clone()) { + Ok(Some(resolution)) => { + let (_, media_type) = + NodeResolution::into_specifier_and_media_type(Some(resolution)); + return media_type; + } + Err(err) => { + lsp_warn!("Node resolution failed for '{}': {}", specifier, err); } + _ => {} } } @@ -794,8 +784,7 @@ impl FileSystemDocuments { pub fn get( &self, specifier: &ModuleSpecifier, - resolver: &Arc, - maybe_node_resolver: Option<&CliNodeResolver>, + resolver: &Arc, config: &Arc, cache: &Arc, ) -> Option> { @@ -814,13 +803,7 @@ impl FileSystemDocuments { }; if dirty { // attempt to update the file on the file system - self.refresh_document( - specifier, - resolver, - maybe_node_resolver, - config, - cache, - ) + self.refresh_document(specifier, resolver, config, cache) } else { old_doc } @@ -831,8 +814,7 @@ impl FileSystemDocuments { fn refresh_document( &self, specifier: &ModuleSpecifier, - resolver: &Arc, - maybe_node_resolver: Option<&CliNodeResolver>, + resolver: &Arc, config: &Arc, cache: &Arc, ) -> Option> { @@ -848,7 +830,6 @@ impl FileSystemDocuments { None, None, resolver.clone(), - maybe_node_resolver, config.clone(), cache, ) @@ -864,7 +845,6 @@ impl FileSystemDocuments { None, None, resolver.clone(), - maybe_node_resolver, config.clone(), cache, ) @@ -893,7 +873,6 @@ impl FileSystemDocuments { None, maybe_headers, resolver.clone(), - maybe_node_resolver, config.clone(), cache, ) @@ -942,11 +921,9 @@ pub struct Documents { /// Any imports to the context supplied by configuration files. This is like /// the imports into the a module graph in CLI. imports: Arc>, - /// Resolver for node_modules. - maybe_node_resolver: Option>, /// A resolver that takes into account currently loaded import map and JSX /// settings. - resolver: Arc, + resolver: Arc, jsr_resolver: Arc, lockfile: Option>>, /// The npm package requirements found in npm specifiers. @@ -969,17 +946,7 @@ impl Documents { open_docs: HashMap::default(), file_system_docs: Default::default(), imports: Default::default(), - maybe_node_resolver: None, - resolver: Arc::new(CliGraphResolver::new(CliGraphResolverOptions { - node_resolver: None, - npm_resolver: None, - package_json_deps_provider: Arc::new(PackageJsonDepsProvider::default()), - maybe_jsx_import_source_config: None, - maybe_import_map: None, - maybe_vendor_dir: None, - bare_node_builtins_enabled: false, - sloppy_imports_resolver: None, - })), + resolver: Default::default(), jsr_resolver: Arc::new(JsrCacheResolver::new(cache.clone(), None)), lockfile: None, npm_specifier_reqs: Default::default(), @@ -1022,7 +989,6 @@ impl Documents { // x-typescript-types? None, self.resolver.clone(), - self.maybe_node_resolver.as_deref(), self.config.clone(), &self.cache, ); @@ -1218,7 +1184,6 @@ impl Documents { self.file_system_docs.get( &specifier, &self.resolver, - self.maybe_node_resolver.as_deref(), &self.config, &self.cache, ) @@ -1280,29 +1245,21 @@ impl Documents { &self, specifiers: &[String], referrer: &ModuleSpecifier, - maybe_npm: Option<&StateNpmSnapshot>, ) -> Vec> { let document = self.get(referrer); let dependencies = document.as_ref().map(|d| d.dependencies()); let mut results = Vec::new(); for specifier in specifiers { - if let Some(npm) = maybe_npm { - if npm.node_resolver.in_npm_package(referrer) { - // we're in an npm package, so use node resolution - results.push(Some(NodeResolution::into_specifier_and_media_type( - npm - .node_resolver - .resolve( - specifier, - referrer, - NodeResolutionMode::Types, - &PermissionsContainer::allow_all(), - ) - .ok() - .flatten(), - ))); - continue; - } + if self.resolver.in_npm_package(referrer) { + // we're in an npm package, so use node resolution + results.push(Some(NodeResolution::into_specifier_and_media_type( + self + .resolver + .node_resolve(specifier, referrer, NodeResolutionMode::Types) + .ok() + .flatten(), + ))); + continue; } if specifier.starts_with("asset:") { if let Ok(specifier) = ModuleSpecifier::parse(specifier) { @@ -1315,9 +1272,9 @@ impl Documents { dependencies.as_ref().and_then(|d| d.get(specifier)) { if let Some(specifier) = dep.maybe_type.maybe_specifier() { - results.push(self.resolve_dependency(specifier, maybe_npm, referrer)); + results.push(self.resolve_dependency(specifier, referrer)); } else if let Some(specifier) = dep.maybe_code.maybe_specifier() { - results.push(self.resolve_dependency(specifier, maybe_npm, referrer)); + results.push(self.resolve_dependency(specifier, referrer)); } else { results.push(None); } @@ -1325,14 +1282,14 @@ impl Documents { .resolve_imports_dependency(specifier) .and_then(|r| r.maybe_specifier()) { - results.push(self.resolve_dependency(specifier, maybe_npm, referrer)); + results.push(self.resolve_dependency(specifier, referrer)); } else if let Ok(npm_req_ref) = NpmPackageReqReference::from_str(specifier) { results.push(node_resolve_npm_req_ref( &npm_req_ref, - maybe_npm, referrer, + &self.resolver, )); } else if let Ok(specifier) = self.resolver.as_graph_resolver().resolve( specifier, @@ -1343,7 +1300,7 @@ impl Documents { }, ResolutionMode::Types, ) { - results.push(self.resolve_dependency(&specifier, maybe_npm, referrer)); + results.push(self.resolve_dependency(&specifier, referrer)); } else { results.push(None); } @@ -1372,36 +1329,13 @@ impl Documents { pub fn update_config( &mut self, config: &Config, - node_resolver: Option>, - npm_resolver: Option>, + resolver: &Arc, workspace_files: &BTreeSet, ) { self.config = Arc::new(config.clone()); let config_data = config.tree.root_data(); let config_file = config_data.and_then(|d| d.config_file.as_deref()); - self.maybe_node_resolver = node_resolver.clone(); - self.resolver = Arc::new(CliGraphResolver::new(CliGraphResolverOptions { - node_resolver, - npm_resolver, - package_json_deps_provider: Arc::new(PackageJsonDepsProvider::new( - config_data - .and_then(|d| d.package_json.as_ref()) - .map(|package_json| { - package_json::get_local_package_json_version_reqs(package_json) - }), - )), - maybe_jsx_import_source_config: config_file - .and_then(|cf| cf.to_maybe_jsx_import_source_config().ok().flatten()), - maybe_import_map: config_data.and_then(|d| d.import_map.clone()), - maybe_vendor_dir: config_data.and_then(|d| d.vendor_dir.as_ref()), - bare_node_builtins_enabled: config_file - .map(|config| config.has_unstable("bare-node-builtins")) - .unwrap_or(false), - // Don't set this for the LSP because instead we'll use the OpenDocumentsLoader - // because it's much easier and we get diagnostics/quick fixes about a redirected - // specifier for free. - sloppy_imports_resolver: None, - })); + self.resolver = resolver.clone(); self.jsr_resolver = Arc::new(JsrCacheResolver::new( self.cache.clone(), config.tree.root_lockfile().cloned(), @@ -1452,21 +1386,14 @@ impl Documents { if !config.specifier_enabled(doc.specifier()) { continue; } - *doc = doc.with_new_config( - self.resolver.clone(), - self.maybe_node_resolver.as_deref(), - self.config.clone(), - ); + *doc = doc.with_new_config(self.resolver.clone(), self.config.clone()); } for mut doc in self.file_system_docs.docs.iter_mut() { if !config.specifier_enabled(doc.specifier()) { continue; } - *doc.value_mut() = doc.with_new_config( - self.resolver.clone(), - self.maybe_node_resolver.as_deref(), - self.config.clone(), - ); + *doc.value_mut() = + doc.with_new_config(self.resolver.clone(), self.config.clone()); } self.open_docs = open_docs; let mut preload_count = 0; @@ -1484,7 +1411,6 @@ impl Documents { fs_docs.refresh_document( specifier, &self.resolver, - self.maybe_node_resolver.as_deref(), &self.config, &self.cache, ); @@ -1566,7 +1492,6 @@ impl Documents { fn resolve_dependency( &self, specifier: &ModuleSpecifier, - maybe_npm: Option<&StateNpmSnapshot>, referrer: &ModuleSpecifier, ) -> Option<(ModuleSpecifier, MediaType)> { if let Some(module_name) = specifier.as_str().strip_prefix("node:") { @@ -1579,13 +1504,13 @@ impl Documents { } if let Ok(npm_ref) = NpmPackageReqReference::from_specifier(specifier) { - return node_resolve_npm_req_ref(&npm_ref, maybe_npm, referrer); + return node_resolve_npm_req_ref(&npm_ref, referrer, &self.resolver); } let Some(doc) = self.get(specifier) else { return Some((specifier.clone(), MediaType::from_specifier(specifier))); }; if let Some(specifier) = doc.maybe_types_dependency().maybe_specifier() { - self.resolve_dependency(specifier, maybe_npm, referrer) + self.resolve_dependency(specifier, referrer) } else { let media_type = doc.media_type(); Some((doc.specifier().clone(), media_type)) @@ -1608,22 +1533,19 @@ impl Documents { fn node_resolve_npm_req_ref( npm_req_ref: &NpmPackageReqReference, - maybe_npm: Option<&StateNpmSnapshot>, referrer: &ModuleSpecifier, + resolver: &LspResolver, ) -> Option<(ModuleSpecifier, MediaType)> { - maybe_npm.map(|npm| { - NodeResolution::into_specifier_and_media_type( - npm - .node_resolver - .resolve_req_reference( - npm_req_ref, - &PermissionsContainer::allow_all(), - referrer, - NodeResolutionMode::Types, - ) - .ok(), - ) - }) + Some(NodeResolution::into_specifier_and_media_type( + resolver + .resolve_npm_req_reference( + npm_req_ref, + referrer, + NodeResolutionMode::Types, + ) + .ok() + .flatten(), + )) } /// Loader that will look at the open documents. @@ -1717,7 +1639,7 @@ fn parse_and_analyze_module( text_info: SourceTextInfo, maybe_headers: Option<&HashMap>, media_type: MediaType, - resolver: &CliGraphResolver, + resolver: &LspResolver, ) -> (Option, Option) { let parsed_source_result = parse_source(specifier, text_info, media_type); let module_result = @@ -1744,7 +1666,7 @@ fn analyze_module( specifier: &ModuleSpecifier, parsed_source_result: &ParsedSourceResult, maybe_headers: Option<&HashMap>, - resolver: &CliGraphResolver, + resolver: &LspResolver, ) -> ModuleResult { match parsed_source_result { Ok(parsed_source) => Ok(deno_graph::parse_module_from_ast( @@ -1939,7 +1861,10 @@ console.log(b, "hello deno"); ) .await; - documents.update_config(&config, None, None, &workspace_files); + let resolver = LspResolver::default() + .with_new_config(&config, None, None) + .await; + documents.update_config(&config, &resolver, &workspace_files); // open the document let document = documents.open( @@ -1980,7 +1905,10 @@ console.log(b, "hello deno"); ) .await; - documents.update_config(&config, None, None, &workspace_files); + let resolver = LspResolver::default() + .with_new_config(&config, None, None) + .await; + documents.update_config(&config, &resolver, &workspace_files); // check the document's dependencies let document = documents.get(&file1_specifier).unwrap(); diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index f15f40f1bfa6c..07d3d8cb78f82 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -13,9 +13,6 @@ use deno_core::url; use deno_core::ModuleSpecifier; use deno_graph::GraphKind; use deno_graph::Resolution; -use deno_npm::NpmSystemInfo; -use deno_runtime::deno_fs; -use deno_runtime::deno_node::NodeResolver; use deno_runtime::deno_tls::rustls::RootCertStore; use deno_runtime::deno_tls::RootCertStoreProvider; use deno_semver::jsr::JsrPackageReqReference; @@ -29,7 +26,6 @@ use std::collections::HashSet; use std::collections::VecDeque; use std::env; use std::fmt::Write as _; -use std::path::Path; use std::path::PathBuf; use std::sync::Arc; use tokio::sync::mpsc::unbounded_channel; @@ -52,8 +48,6 @@ use super::client::Client; use super::code_lens; use super::completions; use super::config::Config; -use super::config::ConfigData; -use super::config::ConfigSnapshot; use super::config::UpdateImportsOnFileMoveEnabled; use super::config::WorkspaceSettings; use super::config::SETTINGS_SECTION; @@ -79,6 +73,7 @@ use super::performance::Performance; use super::performance::PerformanceMark; use super::refactor; use super::registries::ModuleRegistry; +use super::resolver::LspResolver; use super::testing; use super::text; use super::tsc; @@ -94,7 +89,6 @@ use crate::args::CacheSetting; use crate::args::CliOptions; use crate::args::Flags; use crate::cache::DenoDir; -use crate::cache::FastInsecureHasher; use crate::cache::GlobalHttpCache; use crate::cache::HttpCache; use crate::cache::LocalLspHttpCache; @@ -106,14 +100,6 @@ use crate::lsp::config::ConfigWatchedFileType; use crate::lsp::logging::init_log_file; use crate::lsp::tsc::file_text_changes_to_workspace_edit; use crate::lsp::urls::LspUrlKind; -use crate::npm::create_cli_npm_resolver_for_lsp; -use crate::npm::CliNpmResolver; -use crate::npm::CliNpmResolverByonmCreateOptions; -use crate::npm::CliNpmResolverCreateOptions; -use crate::npm::CliNpmResolverManagedCreateOptions; -use crate::npm::CliNpmResolverManagedPackageJsonInstallerOption; -use crate::npm::CliNpmResolverManagedSnapshotOption; -use crate::resolver::CliNodeResolver; use crate::tools::fmt::format_file; use crate::tools::fmt::format_parsed_source; use crate::tools::upgrade::check_for_upgrades_for_lsp; @@ -121,8 +107,6 @@ use crate::tools::upgrade::upgrade_check_enabled; use crate::util::fs::remove_dir_all_if_exists; use crate::util::path::is_importable_ext; use crate::util::path::to_percent_decoded_str; -use crate::util::progress_bar::ProgressBar; -use crate::util::progress_bar::ProgressBarStyle; use deno_runtime::fs_util::specifier_to_file_path; struct LspRootCertStoreProvider(RootCertStore); @@ -133,55 +117,18 @@ impl RootCertStoreProvider for LspRootCertStoreProvider { } } -#[derive(Debug)] -struct LspNpmServices { - /// When this hash changes, the services need updating - config_hash: LspNpmConfigHash, - /// Npm's search api. - search_api: CliNpmSearchApi, - /// Node resolver. - node_resolver: Option>, - /// Resolver for npm packages. - resolver: Option>, -} - -#[derive(Debug, PartialEq, Eq)] -struct LspNpmConfigHash(u64); - -impl LspNpmConfigHash { - pub fn from_inner(inner: &Inner) -> Self { - let config_data = inner.config.tree.root_data(); - let node_modules_dir = - config_data.and_then(|d| d.node_modules_dir.as_ref()); - let lockfile = config_data.and_then(|d| d.lockfile.as_ref()); - let mut hasher = FastInsecureHasher::new(); - hasher.write_hashable(node_modules_dir); - hasher.write_hashable(&inner.maybe_global_cache_path); - if let Some(lockfile) = lockfile { - hasher.write_hashable(&*lockfile.lock()); - } - Self(hasher.finish()) - } -} - #[derive(Debug, Clone)] pub struct LanguageServer(Arc>, CancellationToken); -#[derive(Clone, Debug)] -pub struct StateNpmSnapshot { - pub node_resolver: Arc, - pub npm_resolver: Arc, -} - /// Snapshot of the state used by TSC. #[derive(Clone, Debug)] pub struct StateSnapshot { pub project_version: usize, pub assets: AssetsSnapshot, pub cache_metadata: cache::CacheMetadata, - pub config: Arc, + pub config: Arc, pub documents: Documents, - pub npm: Option, + pub resolver: Arc, } type LanguageServerTaskFn = Box; @@ -253,11 +200,11 @@ pub struct Inner { maybe_global_cache_path: Option, /// A lazily create "server" for handling test run requests. maybe_testing_server: Option, - /// Services used for dealing with npm related functionality. - npm: LspNpmServices, + npm_search_api: CliNpmSearchApi, project_version: usize, /// A collection of measurements which instrument that performance of the LSP. performance: Arc, + resolver: Arc, /// A memoized version of fixable diagnostic codes retrieved from TypeScript. ts_fixable_diagnostics: Vec, /// An abstraction that handles interactions with TypeScript. @@ -544,13 +491,9 @@ impl Inner { maybe_testing_server: None, module_registries, module_registries_location, - npm: LspNpmServices { - config_hash: LspNpmConfigHash(0), // this will be updated in initialize - search_api: npm_search_api, - node_resolver: None, - resolver: None, - }, + npm_search_api, performance, + resolver: Default::default(), ts_fixable_diagnostics: Default::default(), ts_server, url_map: Default::default(), @@ -645,35 +588,13 @@ impl Inner { } pub fn snapshot(&self) -> Arc { - let maybe_state_npm_snapshot = self - .npm - .resolver - .as_ref() - .map(|resolver| resolver.clone_snapshotted()) - .map(|resolver| { - let fs = Arc::new(deno_fs::RealFs); - let node_resolver = Arc::new(NodeResolver::new( - fs.clone(), - resolver.clone().into_npm_resolver(), - )); - let cli_node_resolver = Arc::new(CliNodeResolver::new( - None, - fs, - node_resolver, - resolver.clone(), - )); - StateNpmSnapshot { - node_resolver: cli_node_resolver, - npm_resolver: resolver, - } - }); Arc::new(StateSnapshot { project_version: self.project_version, assets: self.assets.snapshot(), cache_metadata: self.cache_metadata.clone(), - config: self.config.snapshot(), + config: Arc::new(self.config.clone()), documents: self.documents.clone(), - npm: maybe_state_npm_snapshot, + resolver: self.resolver.snapshot(), }) } @@ -747,7 +668,7 @@ impl Inner { ); self.jsr_search_api = CliJsrSearchApi::new(self.module_registries.file_fetcher.clone()); - self.npm.search_api = + self.npm_search_api = CliNpmSearchApi::new(self.module_registries.file_fetcher.clone()); // update the cache path let global_cache = Arc::new(GlobalHttpCache::new( @@ -773,42 +694,6 @@ impl Inner { Ok(()) } - async fn recreate_npm_services_if_necessary(&mut self) { - let deno_dir = match DenoDir::new(self.maybe_global_cache_path.clone()) { - Ok(deno_dir) => deno_dir, - Err(err) => { - lsp_warn!("Error getting deno dir: {:#}", err); - return; - } - }; - let config_hash = LspNpmConfigHash::from_inner(self); - if config_hash == self.npm.config_hash { - return; // no need to do anything - } - let config_data = self.config.tree.root_data(); - let npm_resolver = create_npm_resolver( - &deno_dir, - &self.initial_cwd, - &self.http_client, - config_data, - ) - .await; - let node_resolver = Arc::new(NodeResolver::new( - Arc::new(deno_fs::RealFs), - npm_resolver.clone().into_npm_resolver(), - )); - self.npm.node_resolver = Some(Arc::new(CliNodeResolver::new( - None, - Arc::new(deno_fs::RealFs), - node_resolver, - npm_resolver.clone(), - ))); - self.npm.resolver = Some(npm_resolver); - - // update the hash - self.npm.config_hash = config_hash; - } - fn create_file_fetcher(&self, cache_setting: CacheSetting) -> FileFetcher { let mut file_fetcher = FileFetcher::new( self.deps_http_cache.clone(), @@ -844,52 +729,6 @@ impl Inner { } } -async fn create_npm_resolver( - deno_dir: &DenoDir, - initial_cwd: &Path, - http_client: &Arc, - config_data: Option<&ConfigData>, -) -> Arc { - let byonm = config_data.map(|d| d.byonm).unwrap_or(false); - create_cli_npm_resolver_for_lsp(if byonm { - CliNpmResolverCreateOptions::Byonm(CliNpmResolverByonmCreateOptions { - fs: Arc::new(deno_fs::RealFs), - root_node_modules_dir: initial_cwd.join("node_modules"), - }) - } else { - CliNpmResolverCreateOptions::Managed(CliNpmResolverManagedCreateOptions { - http_client: http_client.clone(), - snapshot: match config_data.and_then(|d| d.lockfile.as_ref()) { - Some(lockfile) => { - CliNpmResolverManagedSnapshotOption::ResolveFromLockfile( - lockfile.clone(), - ) - } - None => CliNpmResolverManagedSnapshotOption::Specified(None), - }, - // Don't provide the lockfile. We don't want these resolvers - // updating it. Only the cache request should update the lockfile. - maybe_lockfile: None, - fs: Arc::new(deno_fs::RealFs), - npm_global_cache_dir: deno_dir.npm_folder_path(), - // Use an "only" cache setting in order to make the - // user do an explicit "cache" command and prevent - // the cache from being filled with lots of packages while - // the user is typing. - cache_setting: CacheSetting::Only, - text_only_progress_bar: ProgressBar::new(ProgressBarStyle::TextOnly), - maybe_node_modules_path: config_data - .and_then(|d| d.node_modules_dir.clone()), - // do not install while resolving in the lsp—leave that to the cache command - package_json_installer: - CliNpmResolverManagedPackageJsonInstallerOption::NoInstall, - npm_registry_url: crate::args::npm_registry_url().to_owned(), - npm_system_info: NpmSystemInfo::default(), - }) - }) - .await -} - // lspower::LanguageServer methods. This file's LanguageServer delegates to us. impl Inner { async fn initialize( @@ -1004,7 +843,6 @@ impl Inner { self.client.show_message(MessageType::WARNING, err); } - self.recreate_npm_services_if_necessary().await; self.assets.initialize(self.snapshot()).await; self.performance.measure(mark); @@ -1178,13 +1016,20 @@ impl Inner { } } } + self.resolver = self + .resolver + .with_new_config( + &self.config, + self.maybe_global_cache_path.as_deref(), + Some(&self.http_client), + ) + .await; } async fn refresh_documents_config(&mut self) { self.documents.update_config( &self.config, - self.npm.node_resolver.clone(), - self.npm.resolver.clone(), + &self.resolver, &self.workspace_files, ); @@ -1262,17 +1107,10 @@ impl Inner { async fn refresh_npm_specifiers(&mut self) { let package_reqs = self.documents.npm_package_reqs(); - let npm_resolver = self.npm.resolver.clone(); + let resolver = self.resolver.clone(); // spawn to avoid the LSP's Send requirements - let handle = spawn(async move { - if let Some(npm_resolver) = - npm_resolver.as_ref().and_then(|r| r.as_managed()) - { - npm_resolver.set_package_reqs(&package_reqs).await - } else { - Ok(()) - } - }); + let handle = + spawn(async move { resolver.set_npm_package_reqs(&package_reqs).await }); if let Err(err) = handle.await.unwrap() { lsp_warn!("Could not set npm package requirements. {:#}", err); } @@ -1331,7 +1169,6 @@ impl Inner { lsp_warn!("Error updating registries: {:#}", err); self.client.show_message(MessageType::WARNING, err); } - self.recreate_npm_services_if_necessary().await; self.refresh_documents_config().await; self.diagnostics_server.invalidate_all(); self.send_diagnostics_update(); @@ -1408,7 +1245,6 @@ impl Inner { }, ); } - self.recreate_npm_services_if_necessary().await; self.refresh_documents_config().await; self.diagnostics_server.invalidate_all(); self.project_changed( @@ -2003,8 +1839,7 @@ impl Inner { TsResponseImportMapper::new( &self.documents, self.config.tree.root_import_map().map(|i| i.as_ref()), - self.npm.node_resolver.as_deref(), - self.npm.resolver.as_deref(), + self.resolver.as_ref(), ) } @@ -2309,11 +2144,11 @@ impl Inner { response = completions::get_import_completions( &specifier, ¶ms.text_document_position.position, - &self.config.snapshot(), + &self.config, &self.client, &self.module_registries, &self.jsr_search_api, - &self.npm.search_api, + &self.npm_search_api, &self.documents, self.config.tree.root_import_map().map(|i| i.as_ref()), ) @@ -3003,7 +2838,6 @@ impl Inner { fn send_diagnostics_update(&self) { let snapshot = DiagnosticServerUpdateMessage { snapshot: self.snapshot(), - config: self.config.snapshot(), url_map: self.url_map.clone(), }; if let Err(err) = self.diagnostics_server.update(snapshot) { diff --git a/cli/lsp/mod.rs b/cli/lsp/mod.rs index f15d2a365899d..07d829d9192d7 100644 --- a/cli/lsp/mod.rs +++ b/cli/lsp/mod.rs @@ -32,6 +32,7 @@ mod performance; mod refactor; mod registries; mod repl; +mod resolver; mod search; mod semantic_tokens; mod testing; diff --git a/cli/lsp/resolver.rs b/cli/lsp/resolver.rs new file mode 100644 index 0000000000000..076d48bb4d977 --- /dev/null +++ b/cli/lsp/resolver.rs @@ -0,0 +1,328 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. + +use crate::args::package_json; +use crate::args::CacheSetting; +use crate::cache::DenoDir; +use crate::cache::FastInsecureHasher; +use crate::http_util::HttpClient; +use crate::lsp::config::Config; +use crate::lsp::config::ConfigData; +use crate::lsp::logging::lsp_warn; +use crate::npm::create_cli_npm_resolver_for_lsp; +use crate::npm::CliNpmResolver; +use crate::npm::CliNpmResolverByonmCreateOptions; +use crate::npm::CliNpmResolverCreateOptions; +use crate::npm::CliNpmResolverManagedCreateOptions; +use crate::npm::CliNpmResolverManagedPackageJsonInstallerOption; +use crate::npm::CliNpmResolverManagedSnapshotOption; +use crate::npm::ManagedCliNpmResolver; +use crate::resolver::CliGraphResolver; +use crate::resolver::CliGraphResolverOptions; +use crate::resolver::CliNodeResolver; +use crate::util::progress_bar::ProgressBar; +use crate::util::progress_bar::ProgressBarStyle; +use deno_core::error::AnyError; +use deno_graph::source::NpmResolver; +use deno_graph::source::Resolver; +use deno_graph::ModuleSpecifier; +use deno_npm::NpmSystemInfo; +use deno_runtime::deno_fs; +use deno_runtime::deno_node::NodeResolution; +use deno_runtime::deno_node::NodeResolutionMode; +use deno_runtime::deno_node::NodeResolver; +use deno_runtime::deno_node::PackageJson; +use deno_runtime::fs_util::specifier_to_file_path; +use deno_runtime::permissions::PermissionsContainer; +use deno_semver::npm::NpmPackageReqReference; +use deno_semver::package::PackageReq; +use package_json::PackageJsonDepsProvider; +use std::path::Path; +use std::rc::Rc; +use std::sync::Arc; + +#[derive(Debug, Clone)] +pub struct LspResolver { + graph_resolver: Arc, + npm_resolver: Option>, + node_resolver: Option>, + npm_config_hash: LspNpmConfigHash, + config: Arc, +} + +impl Default for LspResolver { + fn default() -> Self { + Self { + graph_resolver: create_graph_resolver(&Default::default(), None, None), + npm_resolver: None, + node_resolver: None, + npm_config_hash: LspNpmConfigHash(0), + config: Default::default(), + } + } +} + +impl LspResolver { + pub async fn with_new_config( + &self, + config: &Config, + global_cache_path: Option<&Path>, + http_client: Option<&Arc>, + ) -> Arc { + let npm_config_hash = LspNpmConfigHash::new(config, global_cache_path); + let mut npm_resolver = None; + let mut node_resolver = None; + if npm_config_hash != self.npm_config_hash { + if let (Some(http_client), Some(config_data)) = + (http_client, config.tree.root_data()) + { + npm_resolver = + create_npm_resolver(config_data, global_cache_path, http_client) + .await; + node_resolver = create_node_resolver(npm_resolver.as_ref()); + } + } else { + npm_resolver = self.npm_resolver.clone(); + node_resolver = self.node_resolver.clone(); + } + let graph_resolver = create_graph_resolver( + config, + npm_resolver.as_ref(), + node_resolver.as_ref(), + ); + Arc::new(Self { + graph_resolver, + npm_resolver, + node_resolver, + npm_config_hash, + config: Arc::new(config.clone()), + }) + } + + pub fn snapshot(&self) -> Arc { + let npm_resolver = + self.npm_resolver.as_ref().map(|r| r.clone_snapshotted()); + let node_resolver = create_node_resolver(npm_resolver.as_ref()); + let graph_resolver = create_graph_resolver( + &self.config, + npm_resolver.as_ref(), + node_resolver.as_ref(), + ); + Arc::new(Self { + graph_resolver, + npm_resolver, + node_resolver, + npm_config_hash: self.npm_config_hash.clone(), + config: self.config.clone(), + }) + } + + pub async fn set_npm_package_reqs( + &self, + reqs: &[PackageReq], + ) -> Result<(), AnyError> { + if let Some(npm_resolver) = self.npm_resolver.as_ref() { + if let Some(npm_resolver) = npm_resolver.as_managed() { + return npm_resolver.set_package_reqs(reqs).await; + } + } + Ok(()) + } + + pub fn as_graph_resolver(&self) -> &dyn Resolver { + self.graph_resolver.as_ref() + } + + pub fn as_graph_npm_resolver(&self) -> &dyn NpmResolver { + self.graph_resolver.as_ref() + } + + pub fn maybe_managed_npm_resolver(&self) -> Option<&ManagedCliNpmResolver> { + self.npm_resolver.as_ref().and_then(|r| r.as_managed()) + } + + pub fn in_npm_package(&self, specifier: &ModuleSpecifier) -> bool { + if let Some(npm_resolver) = &self.npm_resolver { + return npm_resolver.in_npm_package(specifier); + } + false + } + + pub fn node_resolve( + &self, + specifier: &str, + referrer: &ModuleSpecifier, + mode: NodeResolutionMode, + ) -> Result, AnyError> { + let Some(node_resolver) = self.node_resolver.as_ref() else { + return Ok(None); + }; + node_resolver.resolve( + specifier, + referrer, + mode, + &PermissionsContainer::allow_all(), + ) + } + + pub fn resolve_npm_req_reference( + &self, + req_ref: &NpmPackageReqReference, + referrer: &ModuleSpecifier, + mode: NodeResolutionMode, + ) -> Result, AnyError> { + let Some(node_resolver) = self.node_resolver.as_ref() else { + return Ok(None); + }; + node_resolver + .resolve_req_reference( + req_ref, + &PermissionsContainer::allow_all(), + referrer, + mode, + ) + .map(Some) + } + + pub fn url_to_node_resolution( + &self, + specifier: ModuleSpecifier, + ) -> Result, AnyError> { + let Some(node_resolver) = self.node_resolver.as_ref() else { + return Ok(None); + }; + node_resolver.url_to_node_resolution(specifier).map(Some) + } + + pub fn get_closest_package_json( + &self, + referrer: &ModuleSpecifier, + ) -> Result>, AnyError> { + let Some(node_resolver) = self.node_resolver.as_ref() else { + return Ok(None); + }; + node_resolver + .get_closest_package_json(referrer, &PermissionsContainer::allow_all()) + } +} + +async fn create_npm_resolver( + config_data: &ConfigData, + global_cache_path: Option<&Path>, + http_client: &Arc, +) -> Option> { + let deno_dir = DenoDir::new(global_cache_path.map(|p| p.to_owned())) + .inspect_err(|err| { + lsp_warn!("Error getting deno dir: {:#}", err); + }) + .ok()?; + let node_modules_dir = config_data + .node_modules_dir + .clone() + .or_else(|| specifier_to_file_path(&config_data.scope).ok())?; + let options = if config_data.byonm { + CliNpmResolverCreateOptions::Byonm(CliNpmResolverByonmCreateOptions { + fs: Arc::new(deno_fs::RealFs), + root_node_modules_dir: node_modules_dir, + }) + } else { + CliNpmResolverCreateOptions::Managed(CliNpmResolverManagedCreateOptions { + http_client: http_client.clone(), + snapshot: match config_data.lockfile.as_ref() { + Some(lockfile) => { + CliNpmResolverManagedSnapshotOption::ResolveFromLockfile( + lockfile.clone(), + ) + } + None => CliNpmResolverManagedSnapshotOption::Specified(None), + }, + // Don't provide the lockfile. We don't want these resolvers + // updating it. Only the cache request should update the lockfile. + maybe_lockfile: None, + fs: Arc::new(deno_fs::RealFs), + npm_global_cache_dir: deno_dir.npm_folder_path(), + // Use an "only" cache setting in order to make the + // user do an explicit "cache" command and prevent + // the cache from being filled with lots of packages while + // the user is typing. + cache_setting: CacheSetting::Only, + text_only_progress_bar: ProgressBar::new(ProgressBarStyle::TextOnly), + maybe_node_modules_path: config_data.node_modules_dir.clone(), + // do not install while resolving in the lsp—leave that to the cache command + package_json_installer: + CliNpmResolverManagedPackageJsonInstallerOption::NoInstall, + npm_registry_url: crate::args::npm_registry_url().to_owned(), + npm_system_info: NpmSystemInfo::default(), + }) + }; + Some(create_cli_npm_resolver_for_lsp(options).await) +} + +fn create_node_resolver( + npm_resolver: Option<&Arc>, +) -> Option> { + let npm_resolver = npm_resolver?; + let fs = Arc::new(deno_fs::RealFs); + let node_resolver_inner = Arc::new(NodeResolver::new( + fs.clone(), + npm_resolver.clone().into_npm_resolver(), + )); + Some(Arc::new(CliNodeResolver::new( + None, + fs, + node_resolver_inner, + npm_resolver.clone(), + ))) +} + +fn create_graph_resolver( + config: &Config, + npm_resolver: Option<&Arc>, + node_resolver: Option<&Arc>, +) -> Arc { + let config_data = config.tree.root_data(); + let config_file = config_data.and_then(|d| d.config_file.as_deref()); + Arc::new(CliGraphResolver::new(CliGraphResolverOptions { + node_resolver: node_resolver.cloned(), + npm_resolver: npm_resolver.cloned(), + package_json_deps_provider: Arc::new(PackageJsonDepsProvider::new( + config_data + .and_then(|d| d.package_json.as_ref()) + .map(|package_json| { + package_json::get_local_package_json_version_reqs(package_json) + }), + )), + maybe_jsx_import_source_config: config_file + .and_then(|cf| cf.to_maybe_jsx_import_source_config().ok().flatten()), + maybe_import_map: config_data.and_then(|d| d.import_map.clone()), + maybe_vendor_dir: config_data.and_then(|d| d.vendor_dir.as_ref()), + bare_node_builtins_enabled: config_file + .map(|config| config.has_unstable("bare-node-builtins")) + .unwrap_or(false), + // Don't set this for the LSP because instead we'll use the OpenDocumentsLoader + // because it's much easier and we get diagnostics/quick fixes about a redirected + // specifier for free. + sloppy_imports_resolver: None, + })) +} + +#[derive(Debug, Clone, PartialEq, Eq)] +struct LspNpmConfigHash(u64); + +impl LspNpmConfigHash { + pub fn new(config: &Config, global_cache_path: Option<&Path>) -> Self { + let config_data = config.tree.root_data(); + let scope = config_data.map(|d| &d.scope); + let node_modules_dir = + config_data.and_then(|d| d.node_modules_dir.as_ref()); + let lockfile = config_data.and_then(|d| d.lockfile.as_ref()); + let mut hasher = FastInsecureHasher::new(); + hasher.write_hashable(scope); + hasher.write_hashable(node_modules_dir); + hasher.write_hashable(global_cache_path); + if let Some(lockfile) = lockfile { + hasher.write_hashable(&*lockfile.lock()); + } + hasher.write_hashable(global_cache_path); + Self(hasher.finish()) + } +} diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index ef096ab8bdebc..8a20ffb0f7b90 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -3999,12 +3999,7 @@ fn op_is_node_file(state: &mut OpState, #[string] path: String) -> bool { let state = state.borrow::(); let mark = state.performance.mark("tsc.op.op_is_node_file"); let r = match ModuleSpecifier::parse(&path) { - Ok(specifier) => state - .state_snapshot - .npm - .as_ref() - .map(|n| n.npm_resolver.in_npm_package(&specifier)) - .unwrap_or(false), + Ok(specifier) => state.state_snapshot.resolver.in_npm_package(&specifier), Err(_) => false, }; state.performance.measure(mark); @@ -4089,11 +4084,7 @@ fn op_resolve_inner( let specifiers = state .state_snapshot .documents - .resolve( - &args.specifiers, - &referrer, - state.state_snapshot.npm.as_ref(), - ) + .resolve(&args.specifiers, &referrer) .into_iter() .map(|o| { o.map(|(s, mt)| { @@ -4408,7 +4399,7 @@ deno_core::extension!(deno_tsc, cache_metadata: CacheMetadata::new(options.cache.clone()), config: Default::default(), documents: Documents::new(options.cache.clone()), - npm: None, + resolver: Default::default(), }), options.specifier_map, options.performance, @@ -5052,17 +5043,17 @@ impl TscRequest { #[cfg(test)] mod tests { - use super::*; use crate::cache::GlobalHttpCache; use crate::cache::HttpCache; use crate::cache::RealDenoCacheEnv; use crate::http_util::HeadersMap; use crate::lsp::cache::CacheMetadata; - use crate::lsp::config::ConfigSnapshot; + use crate::lsp::config::Config; use crate::lsp::config::WorkspaceSettings; use crate::lsp::documents::Documents; use crate::lsp::documents::LanguageId; + use crate::lsp::resolver::LspResolver; use crate::lsp::text::LineIndex; use pretty_assertions::assert_eq; use std::path::Path; @@ -5088,7 +5079,7 @@ mod tests { (*source).into(), ); } - let mut config = ConfigSnapshot::default(); + let mut config = Config::default(); config .tree .inject_config_file( @@ -5103,13 +5094,16 @@ mod tests { .unwrap(), ) .await; + let resolver = LspResolver::default() + .with_new_config(&config, None, None) + .await; StateSnapshot { project_version: 0, documents, assets: Default::default(), cache_metadata: CacheMetadata::new(cache), config: Arc::new(config), - npm: None, + resolver, } } diff --git a/cli/standalone/binary.rs b/cli/standalone/binary.rs index c96d838540107..4442f5a241bab 100644 --- a/cli/standalone/binary.rs +++ b/cli/standalone/binary.rs @@ -488,7 +488,9 @@ impl<'a> DenoCompileBinaryWriter<'a> { // Phase 2 of the 'min sized' deno compile RFC talks // about adding this as a flag. if let Some(path) = std::env::var_os("DENORT_BIN") { - return Ok(std::fs::read(path)?); + return std::fs::read(&path).with_context(|| { + format!("Could not find denort at '{}'", path.to_string_lossy()) + }); } let target = compile_flags.resolve_target(); diff --git a/cli/standalone/mod.rs b/cli/standalone/mod.rs index 8ff822f5a32ee..3cfeb4f4ce58c 100644 --- a/cli/standalone/mod.rs +++ b/cli/standalone/mod.rs @@ -150,6 +150,13 @@ impl ModuleLoader for EmbeddedModuleLoader { Some(resolved) => resolved, None => deno_core::resolve_import(specifier, referrer.as_str())?, }; + + if specifier.scheme() == "jsr" { + if let Some(module) = self.shared.eszip.get_module(specifier.as_str()) { + return Ok(ModuleSpecifier::parse(&module.specifier).unwrap()); + } + } + self .shared .node_resolver diff --git a/cli/tools/bench/mitata.rs b/cli/tools/bench/mitata.rs index 57d1fc1dffb84..64c5d5f69acb5 100644 --- a/cli/tools/bench/mitata.rs +++ b/cli/tools/bench/mitata.rs @@ -201,7 +201,6 @@ pub mod reporter { pub struct Options { size: usize, pub avg: bool, - pub colors: bool, pub min_max: bool, pub percentiles: bool, } @@ -210,7 +209,6 @@ pub mod reporter { pub fn new(names: &[&str]) -> Options { Options { avg: true, - colors: true, min_max: true, size: size(names), percentiles: true, @@ -253,23 +251,12 @@ pub mod reporter { let mut s = String::new(); s.push_str(&format!("{: s.push_str(stack), - true => s.push_str(&colors::gray(stack).to_string()), - } + s.push_str(&colors::gray(stack).to_string()); } s @@ -304,64 +291,36 @@ pub mod reporter { s.push_str(&format!("{:14}", - format!("{}/iter", fmt_duration(stats.avg)) - )); - s.push_str(&format!("{:>14}", avg_to_iter_per_s(stats.avg))); - } - if options.min_max { - s.push_str(&format!( - "{:>24}", - format!( - "({} … {})", - fmt_duration(stats.min), - fmt_duration(stats.max) - ) - )); - } - if options.percentiles { - s.push_str(&format!( - " {:>9} {:>9} {:>9}", - fmt_duration(stats.p75), - fmt_duration(stats.p99), - fmt_duration(stats.p995) - )); - } - } else { - if options.avg { - s.push_str(&format!( - "{:>30}", - format!("{}/iter", colors::yellow(fmt_duration(stats.avg))) - )); - s.push_str(&format!("{:>14}", avg_to_iter_per_s(stats.avg))); - } - if options.min_max { - s.push_str(&format!( - "{:>50}", - format!( - "({} … {})", - colors::cyan(fmt_duration(stats.min)), - colors::magenta(fmt_duration(stats.max)) - ) - )); - } - if options.percentiles { - s.push_str(&format!( - " {:>22} {:>22} {:>22}", - colors::magenta(fmt_duration(stats.p75)), - colors::magenta(fmt_duration(stats.p99)), - colors::magenta(fmt_duration(stats.p995)) - )); - } + if options.avg { + s.push_str(&format!( + "{:>30}", + format!("{}/iter", colors::yellow(fmt_duration(stats.avg))) + )); + s.push_str(&format!("{:>14}", avg_to_iter_per_s(stats.avg))); + } + if options.min_max { + s.push_str(&format!( + "{:>50}", + format!( + "({} … {})", + colors::cyan(fmt_duration(stats.min)), + colors::magenta(fmt_duration(stats.max)) + ) + )); + } + if options.percentiles { + s.push_str(&format!( + " {:>22} {:>22} {:>22}", + colors::magenta(fmt_duration(stats.p75)), + colors::magenta(fmt_duration(stats.p99)), + colors::magenta(fmt_duration(stats.p995)) + )); } s } - pub fn summary(benchmarks: &[GroupBenchmark], options: &Options) -> String { + pub fn summary(benchmarks: &[GroupBenchmark]) -> String { let mut s = String::new(); let mut benchmarks = benchmarks.to_owned(); benchmarks.sort_by(|a, b| a.stats.avg.partial_cmp(&b.stats.avg).unwrap()); @@ -370,58 +329,34 @@ pub mod reporter { .find(|b| b.baseline) .unwrap_or(&benchmarks[0]); - if !options.colors { - s.push_str(&format!("summary\n {}", baseline.name)); - - for b in benchmarks.iter().filter(|b| *b != baseline) { - let faster = b.stats.avg >= baseline.stats.avg; - let diff = f64::from_str(&format!( - "{:.2}", - 1.0 / baseline.stats.avg * b.stats.avg - )) - .unwrap(); - let inv_diff = f64::from_str(&format!( - "{:.2}", - 1.0 / b.stats.avg * baseline.stats.avg - )) - .unwrap(); - s.push_str(&format!( - "\n {}x times {} than {}", - if faster { diff } else { inv_diff }, - if faster { "faster" } else { "slower" }, - b.name - )); - } - } else { + s.push_str(&format!( + "{}\n {}", + colors::gray("summary"), + colors::cyan_bold(&baseline.name) + )); + + for b in benchmarks.iter().filter(|b| *b != baseline) { + let faster = b.stats.avg >= baseline.stats.avg; + let diff = f64::from_str(&format!( + "{:.2}", + 1.0 / baseline.stats.avg * b.stats.avg + )) + .unwrap(); + let inv_diff = f64::from_str(&format!( + "{:.2}", + 1.0 / b.stats.avg * baseline.stats.avg + )) + .unwrap(); s.push_str(&format!( - "{}\n {}", - colors::gray("summary"), - colors::cyan_bold(&baseline.name) + "\n {}x {} than {}", + if faster { + colors::green(diff.to_string()).to_string() + } else { + colors::red(inv_diff.to_string()).to_string() + }, + if faster { "faster" } else { "slower" }, + colors::cyan_bold(&b.name) )); - - for b in benchmarks.iter().filter(|b| *b != baseline) { - let faster = b.stats.avg >= baseline.stats.avg; - let diff = f64::from_str(&format!( - "{:.2}", - 1.0 / baseline.stats.avg * b.stats.avg - )) - .unwrap(); - let inv_diff = f64::from_str(&format!( - "{:.2}", - 1.0 / b.stats.avg * baseline.stats.avg - )) - .unwrap(); - s.push_str(&format!( - "\n {}x {} than {}", - if faster { - colors::green(diff.to_string()).to_string() - } else { - colors::red(inv_diff.to_string()).to_string() - }, - if faster { "faster" } else { "slower" }, - colors::cyan_bold(&b.name) - )); - } } s diff --git a/cli/tools/bench/reporters.rs b/cli/tools/bench/reporters.rs index face54943fe4a..9cc035f8f1592 100644 --- a/cli/tools/bench/reporters.rs +++ b/cli/tools/bench/reporters.rs @@ -138,7 +138,6 @@ impl BenchReporter for ConsoleReporter { let options = self.options.as_mut().unwrap(); options.percentiles = true; - options.colors = colors::use_color(); if FIRST_PLAN .compare_exchange(true, false, Ordering::SeqCst, Ordering::SeqCst) @@ -246,10 +245,9 @@ impl BenchReporter for ConsoleReporter { } fn report_group_summary(&mut self) { - let options = match self.options.as_ref() { - None => return, - Some(options) => options, - }; + if self.options.is_none() { + return; + } if 2 <= self.group_measurements.len() && (self.group.is_some() || (self.group.is_none() && self.baseline)) @@ -275,7 +273,6 @@ impl BenchReporter for ConsoleReporter { }, }) .collect::>(), - options ) ); } diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts index fc64876f4f55a..f9b61dc66f05c 100644 --- a/cli/tsc/dts/lib.deno.ns.d.ts +++ b/cli/tsc/dts/lib.deno.ns.d.ts @@ -882,7 +882,7 @@ declare namespace Deno { /** * @category Testing */ - interface DenoTest { + export interface DenoTest { /** Register a test which will be run when `deno test` is used on the command * line and the containing module looks like a test module. * @@ -4095,7 +4095,7 @@ declare namespace Deno { * @deprecated This will be removed in Deno 2.0. * * @category Observability */ - interface ResourceMap { + export interface ResourceMap { [rid: number]: unknown; } diff --git a/cli/tsc/dts/lib.deno.shared_globals.d.ts b/cli/tsc/dts/lib.deno.shared_globals.d.ts index 86bf8237eceb0..ca6b419f38235 100644 --- a/cli/tsc/dts/lib.deno.shared_globals.d.ts +++ b/cli/tsc/dts/lib.deno.shared_globals.d.ts @@ -628,6 +628,7 @@ declare interface PerformanceMarkOptions { startTime?: number; } +/** @category Performance */ declare interface PerformanceMeasureOptions { /** Metadata to be included in the measure. */ detail?: any; diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts index 0c20ec1b6a476..437a881116c8c 100644 --- a/cli/tsc/dts/lib.deno.unstable.d.ts +++ b/cli/tsc/dts/lib.deno.unstable.d.ts @@ -13,6 +13,7 @@ declare namespace Deno { /** Information for a HTTP request. * * @category HTTP Server + * @tags unstable */ export interface ServeHandlerInfo { /** The remote address of the connection. */ @@ -38,6 +39,7 @@ declare namespace Deno { * *Note*: This API is not implemented on Windows * * @category File System + * @tags unstable */ export function umask(mask?: number): number; @@ -46,8 +48,9 @@ declare namespace Deno { * All plain number types for interfacing with foreign functions. * * @category FFI + * @tags unstable */ - type NativeNumberType = + export type NativeNumberType = | "u8" | "i8" | "u16" @@ -62,8 +65,9 @@ declare namespace Deno { * All BigInt number types for interfacing with foreign functions. * * @category FFI + * @tags unstable */ - type NativeBigIntType = + export type NativeBigIntType = | "u64" | "i64" | "usize" @@ -74,69 +78,102 @@ declare namespace Deno { * The native boolean type for interfacing to foreign functions. * * @category FFI + * @tags unstable */ - type NativeBooleanType = "bool"; + export type NativeBooleanType = "bool"; /** **UNSTABLE**: New API, yet to be vetted. * * The native pointer type for interfacing to foreign functions. * * @category FFI + * @tags unstable */ - type NativePointerType = "pointer"; + export type NativePointerType = "pointer"; /** **UNSTABLE**: New API, yet to be vetted. * * The native buffer type for interfacing to foreign functions. * * @category FFI + * @tags unstable */ - type NativeBufferType = "buffer"; + export type NativeBufferType = "buffer"; /** **UNSTABLE**: New API, yet to be vetted. * * The native function type for interfacing with foreign functions. * * @category FFI + * @tags unstable */ - type NativeFunctionType = "function"; + export type NativeFunctionType = "function"; /** **UNSTABLE**: New API, yet to be vetted. * * The native void type for interfacing with foreign functions. * * @category FFI + * @tags unstable */ - type NativeVoidType = "void"; + export type NativeVoidType = "void"; /** **UNSTABLE**: New API, yet to be vetted. * * The native struct type for interfacing with foreign functions. * * @category FFI + * @tags unstable */ - type NativeStructType = { readonly struct: readonly NativeType[] }; + export type NativeStructType = { readonly struct: readonly NativeType[] }; - /** @category FFI */ - const brand: unique symbol; + /** + * @category FFI + * @tags unstable + */ + export const brand: unique symbol; - /** @category FFI */ + /** + * @category FFI + * @tags unstable + */ export type NativeU8Enum = "u8" & { [brand]: T }; - /** @category FFI */ + /** + * @category FFI + * @tags unstable + */ export type NativeI8Enum = "i8" & { [brand]: T }; - /** @category FFI */ + /** + * @category FFI + * @tags unstable + */ export type NativeU16Enum = "u16" & { [brand]: T }; - /** @category FFI */ + /** + * @category FFI + * @tags unstable + */ export type NativeI16Enum = "i16" & { [brand]: T }; - /** @category FFI */ + /** + * @category FFI + * @tags unstable + */ export type NativeU32Enum = "u32" & { [brand]: T }; - /** @category FFI */ + /** + * @category FFI + * @tags unstable + */ export type NativeI32Enum = "i32" & { [brand]: T }; - /** @category FFI */ + /** + * @category FFI + * @tags unstable + */ export type NativeTypedPointer = "pointer" & { [brand]: T; }; - /** @category FFI */ + /** + * @category FFI + * @tags unstable + */ export type NativeTypedFunction = & "function" & { @@ -148,6 +185,7 @@ declare namespace Deno { * All supported types for interfacing with foreign functions. * * @category FFI + * @tags unstable */ export type NativeType = | NativeNumberType @@ -161,6 +199,7 @@ declare namespace Deno { /** **UNSTABLE**: New API, yet to be vetted. * * @category FFI + * @tags unstable */ export type NativeResultType = NativeType | NativeVoidType; @@ -170,8 +209,9 @@ declare namespace Deno { * types. * * @category FFI + * @tags unstable */ - type ToNativeType = T extends + export type ToNativeType = T extends NativeStructType ? BufferSource : T extends NativeNumberType ? T extends NativeU8Enum ? U : T extends NativeI8Enum ? U @@ -195,34 +235,37 @@ declare namespace Deno { * Type conversion for unsafe callback return types. * * @category FFI + * @tags unstable */ - type ToNativeResultType = - T extends NativeStructType ? BufferSource - : T extends NativeNumberType ? T extends NativeU8Enum ? U - : T extends NativeI8Enum ? U - : T extends NativeU16Enum ? U - : T extends NativeI16Enum ? U - : T extends NativeU32Enum ? U - : T extends NativeI32Enum ? U - : number - : T extends NativeBigIntType ? number | bigint - : T extends NativeBooleanType ? boolean - : T extends NativePointerType - ? T extends NativeTypedPointer ? U | null : PointerValue - : T extends NativeFunctionType - ? T extends NativeTypedFunction ? PointerObject | null - : PointerValue - : T extends NativeBufferType ? BufferSource | null - : T extends NativeVoidType ? void - : never; + export type ToNativeResultType< + T extends NativeResultType = NativeResultType, + > = T extends NativeStructType ? BufferSource + : T extends NativeNumberType ? T extends NativeU8Enum ? U + : T extends NativeI8Enum ? U + : T extends NativeU16Enum ? U + : T extends NativeI16Enum ? U + : T extends NativeU32Enum ? U + : T extends NativeI32Enum ? U + : number + : T extends NativeBigIntType ? number | bigint + : T extends NativeBooleanType ? boolean + : T extends NativePointerType + ? T extends NativeTypedPointer ? U | null : PointerValue + : T extends NativeFunctionType + ? T extends NativeTypedFunction ? PointerObject | null + : PointerValue + : T extends NativeBufferType ? BufferSource | null + : T extends NativeVoidType ? void + : never; /** **UNSTABLE**: New API, yet to be vetted. * * A utility type for conversion of parameter types of foreign functions. * * @category FFI + * @tags unstable */ - type ToNativeParameterTypes = + export type ToNativeParameterTypes = // [(T[number])[]] extends [T] ? ToNativeType[] : [readonly (T[number])[]] extends [T] @@ -238,8 +281,9 @@ declare namespace Deno { * parameters. * * @category FFI + * @tags unstable */ - type FromNativeType = T extends + export type FromNativeType = T extends NativeStructType ? Uint8Array : T extends NativeNumberType ? T extends NativeU8Enum ? U : T extends NativeI8Enum ? U @@ -263,32 +307,35 @@ declare namespace Deno { * Type conversion for foreign symbol return types. * * @category FFI + * @tags unstable */ - type FromNativeResultType = - T extends NativeStructType ? Uint8Array - : T extends NativeNumberType ? T extends NativeU8Enum ? U - : T extends NativeI8Enum ? U - : T extends NativeU16Enum ? U - : T extends NativeI16Enum ? U - : T extends NativeU32Enum ? U - : T extends NativeI32Enum ? U - : number - : T extends NativeBigIntType ? number | bigint - : T extends NativeBooleanType ? boolean - : T extends NativePointerType - ? T extends NativeTypedPointer ? U | null : PointerValue - : T extends NativeBufferType ? PointerValue - : T extends NativeFunctionType - ? T extends NativeTypedFunction ? PointerObject | null - : PointerValue - : T extends NativeVoidType ? void - : never; + export type FromNativeResultType< + T extends NativeResultType = NativeResultType, + > = T extends NativeStructType ? Uint8Array + : T extends NativeNumberType ? T extends NativeU8Enum ? U + : T extends NativeI8Enum ? U + : T extends NativeU16Enum ? U + : T extends NativeI16Enum ? U + : T extends NativeU32Enum ? U + : T extends NativeI32Enum ? U + : number + : T extends NativeBigIntType ? number | bigint + : T extends NativeBooleanType ? boolean + : T extends NativePointerType + ? T extends NativeTypedPointer ? U | null : PointerValue + : T extends NativeBufferType ? PointerValue + : T extends NativeFunctionType + ? T extends NativeTypedFunction ? PointerObject | null + : PointerValue + : T extends NativeVoidType ? void + : never; /** **UNSTABLE**: New API, yet to be vetted. * * @category FFI + * @tags unstable */ - type FromNativeParameterTypes< + export type FromNativeParameterTypes< T extends readonly NativeType[], > = // @@ -306,6 +353,7 @@ declare namespace Deno { * types. * * @category FFI + * @tags unstable */ export interface ForeignFunction< Parameters extends readonly NativeType[] = readonly NativeType[], @@ -338,6 +386,7 @@ declare namespace Deno { /** **UNSTABLE**: New API, yet to be vetted. * * @category FFI + * @tags unstable */ export interface ForeignStatic { /** Name of the symbol, defaults to the key name in symbols object. */ @@ -356,6 +405,7 @@ declare namespace Deno { * A foreign library interface descriptor. * * @category FFI + * @tags unstable */ export interface ForeignLibraryInterface { [name: string]: ForeignFunction | ForeignStatic; @@ -366,8 +416,9 @@ declare namespace Deno { * A utility type that infers a foreign symbol. * * @category FFI + * @tags unstable */ - type StaticForeignSymbol = + export type StaticForeignSymbol = T extends ForeignFunction ? FromForeignFunction : T extends ForeignStatic ? FromNativeType : never; @@ -375,25 +426,28 @@ declare namespace Deno { /** **UNSTABLE**: New API, yet to be vetted. * * @category FFI + * @tags unstable */ - type FromForeignFunction = T["parameters"] extends - readonly [] ? () => StaticForeignSymbolReturnType - : ( - ...args: ToNativeParameterTypes - ) => StaticForeignSymbolReturnType; + export type FromForeignFunction = + T["parameters"] extends readonly [] ? () => StaticForeignSymbolReturnType + : ( + ...args: ToNativeParameterTypes + ) => StaticForeignSymbolReturnType; /** **UNSTABLE**: New API, yet to be vetted. * * @category FFI + * @tags unstable */ - type StaticForeignSymbolReturnType = + export type StaticForeignSymbolReturnType = ConditionalAsync>; /** **UNSTABLE**: New API, yet to be vetted. * * @category FFI + * @tags unstable */ - type ConditionalAsync = + export type ConditionalAsync = IsAsync extends true ? Promise : T; /** **UNSTABLE**: New API, yet to be vetted. @@ -401,12 +455,14 @@ declare namespace Deno { * A utility type that infers a foreign library interface. * * @category FFI + * @tags unstable */ - type StaticForeignLibraryInterface = { - [K in keyof T]: T[K]["optional"] extends true - ? StaticForeignSymbol | null - : StaticForeignSymbol; - }; + export type StaticForeignLibraryInterface = + { + [K in keyof T]: T[K]["optional"] extends true + ? StaticForeignSymbol | null + : StaticForeignSymbol; + }; /** **UNSTABLE**: New API, yet to be vetted. * @@ -422,6 +478,7 @@ declare namespace Deno { * {@linkcode UnsafePointer} class. * * @category FFI + * @tags unstable */ export type PointerObject = { [brand]: T }; @@ -431,6 +488,7 @@ declare namespace Deno { * object or a `null` if the pointer is null. * * @category FFI + * @tags unstable */ export type PointerValue = null | PointerObject; @@ -439,6 +497,7 @@ declare namespace Deno { * A collection of static functions for interacting with pointer objects. * * @category FFI + * @tags unstable */ export class UnsafePointer { /** Create a pointer from a numeric value. This one is really dangerous! */ @@ -466,6 +525,7 @@ declare namespace Deno { * location (numbers, strings and raw bytes). * * @category FFI + * @tags unstable */ export class UnsafePointerView { constructor(pointer: PointerObject); @@ -549,6 +609,7 @@ declare namespace Deno { * as symbols. * * @category FFI + * @tags unstable */ export class UnsafeFnPointer { /** The pointer to the function. */ @@ -569,6 +630,7 @@ declare namespace Deno { * Definition of a unsafe callback function. * * @category FFI + * @tags unstable */ export interface UnsafeCallbackDefinition< Parameters extends readonly NativeType[] = readonly NativeType[], @@ -585,8 +647,9 @@ declare namespace Deno { * An unsafe callback function. * * @category FFI + * @tags unstable */ - type UnsafeCallbackFunction< + export type UnsafeCallbackFunction< Parameters extends readonly NativeType[] = readonly NativeType[], Result extends NativeResultType = NativeResultType, > = Parameters extends readonly [] ? () => ToNativeResultType : ( @@ -615,6 +678,7 @@ declare namespace Deno { * called from foreign threads. * * @category FFI + * @tags unstable */ export class UnsafeCallback< const Definition extends UnsafeCallbackDefinition = @@ -698,6 +762,7 @@ declare namespace Deno { * library and return this interface. * * @category FFI + * @tags unstable */ export interface DynamicLibrary { /** All of the registered library along with functions for calling them. */ @@ -756,7 +821,7 @@ declare namespace Deno { * console.log(`Result from external addition of 35 and 34: ${result}`); * ``` * - * @tags allow-ffi + * @tags allow-ffi, unstable * @category FFI */ export function dlopen( @@ -779,6 +844,7 @@ declare namespace Deno { * | "wayland" (Linux) | `wl_surface*` | `wl_display*` | * * @category WebGPU + * @tags unstable */ export class UnsafeWindowSurface { constructor( @@ -795,8 +861,9 @@ declare namespace Deno { * These are unstable options which can be used with {@linkcode Deno.run}. * * @category Sub Process + * @tags unstable */ - interface UnstableRunOptions extends RunOptions { + export interface UnstableRunOptions extends RunOptions { /** If `true`, clears the environment variables before executing the * sub-process. * @@ -855,7 +922,7 @@ declare namespace Deno { * * Requires `allow-run` permission. * - * @tags allow-run + * @tags allow-run, unstable * @category Sub Process */ export function run( @@ -874,6 +941,7 @@ declare namespace Deno { * ``` * * @category Fetch API + * @tags unstable */ export interface HttpClient extends Disposable { /** Close the HTTP client. */ @@ -885,6 +953,7 @@ declare namespace Deno { * The options used when creating a {@linkcode Deno.HttpClient}. * * @category Fetch API + * @tags unstable */ export interface CreateHttpClientOptions { /** A list of root certificates that will be used in addition to the @@ -923,6 +992,7 @@ declare namespace Deno { * {@linkcode Deno.CreateHttpClientOptions}. * * @category Fetch API + * @tags unstable */ export interface Proxy { /** The string URL of the proxy server to use. */ @@ -937,6 +1007,7 @@ declare namespace Deno { * server when specifying {@linkcode Deno.CreateHttpClientOptions}. * * @category Fetch API + * @tags unstable */ export interface BasicAuth { /** The username to be used against the proxy server. */ @@ -965,6 +1036,7 @@ declare namespace Deno { * ``` * * @category Fetch API + * @tags unstable */ export function createHttpClient( options: CreateHttpClientOptions, @@ -986,6 +1058,7 @@ declare namespace Deno { * ``` * * @category Fetch API + * @tags unstable */ export function createHttpClient( options: CreateHttpClientOptions & TlsCertifiedKeyOptions, @@ -996,8 +1069,9 @@ declare namespace Deno { * Represents membership of a IPv4 multicast group. * * @category Network + * @tags unstable */ - interface MulticastV4Membership { + export interface MulticastV4Membership { /** Leaves the multicast group. */ leave: () => Promise; /** Sets the multicast loopback option. If enabled, multicast packets will be looped back to the local socket. */ @@ -1011,8 +1085,9 @@ declare namespace Deno { * Represents membership of a IPv6 multicast group. * * @category Network + * @tags unstable */ - interface MulticastV6Membership { + export interface MulticastV6Membership { /** Leaves the multicast group. */ leave: () => Promise; /** Sets the multicast loopback option. If enabled, multicast packets will be looped back to the local socket. */ @@ -1024,6 +1099,7 @@ declare namespace Deno { * A generic transport listener for message-oriented protocols. * * @category Network + * @tags unstable */ export interface DatagramConn extends AsyncIterable<[Uint8Array, Addr]> { /** Joins an IPv4 multicast group. */ @@ -1057,6 +1133,7 @@ declare namespace Deno { /** * @category Network + * @tags unstable */ export interface TcpListenOptions extends ListenOptions { /** When `true` the SO_REUSEPORT flag will be set on the listener. This @@ -1079,6 +1156,7 @@ declare namespace Deno { * {@linkcode Deno.listenDatagram}. * * @category Network + * @tags unstable */ export interface UdpListenOptions extends ListenOptions { /** When `true` the specified address will be reused, even if another @@ -1112,7 +1190,7 @@ declare namespace Deno { * * Requires `allow-net` permission. * - * @tags allow-net + * @tags allow-net, unstable * @category Network */ export function listenDatagram( @@ -1132,7 +1210,7 @@ declare namespace Deno { * * Requires `allow-read` and `allow-write` permission. * - * @tags allow-read, allow-write + * @tags allow-read, allow-write, unstable * @category Network */ export function listenDatagram( @@ -1145,6 +1223,7 @@ declare namespace Deno { * * @param [exclusive=false] * @category File System + * @tags unstable */ export function flock(rid: number, exclusive?: boolean): Promise; @@ -1154,6 +1233,7 @@ declare namespace Deno { * * @param [exclusive=false] * @category File System + * @tags unstable */ export function flockSync(rid: number, exclusive?: boolean): void; @@ -1162,6 +1242,7 @@ declare namespace Deno { * Release an advisory file-system lock for the provided file. * * @category File System + * @tags unstable */ export function funlock(rid: number): Promise; @@ -1170,6 +1251,7 @@ declare namespace Deno { * Release an advisory file-system lock for the provided file synchronously. * * @category File System + * @tags unstable */ export function funlockSync(rid: number): void; @@ -1186,7 +1268,7 @@ declare namespace Deno { * `localStorage` persistence). More information about the origin storage key * can be found in the Deno Manual. * - * @tags allow-read, allow-write + * @tags allow-read, allow-write, unstable * @category KV */ export function openKv(path?: string): Promise; @@ -1196,8 +1278,9 @@ declare namespace Deno { * CronScheduleExpression is used as the type of `minute`, `hour`, * `dayOfMonth`, `month`, and `dayOfWeek` in {@linkcode CronSchedule}. * @category Cron + * @tags unstable */ - type CronScheduleExpression = number | { exact: number | number[] } | { + export type CronScheduleExpression = number | { exact: number | number[] } | { start?: number; end?: number; every?: number; @@ -1208,6 +1291,7 @@ declare namespace Deno { * CronSchedule is the interface used for JSON format * cron `schedule`. * @category Cron + * @tags unstable */ export interface CronSchedule { minute?: CronScheduleExpression; @@ -1239,6 +1323,7 @@ declare namespace Deno { * using UTC time zone. * * @category Cron + * @tags unstable */ export function cron( name: string, @@ -1270,6 +1355,7 @@ declare namespace Deno { * second, 5 seconds, and 10 seconds delay between each retry. * * @category Cron + * @tags unstable */ export function cron( name: string, @@ -1294,6 +1380,7 @@ declare namespace Deno { * was passed to. * * @category KV + * @tags unstable */ export type KvKey = readonly KvKeyPart[]; @@ -1330,6 +1417,7 @@ declare namespace Deno { * over the ordering of values within a type. * * @category KV + * @tags unstable */ export type KvKeyPart = | Uint8Array @@ -1347,6 +1435,7 @@ declare namespace Deno { * - `eventual` - Eventually-consistent behavior is allowed. * * @category KV + * @tags unstable */ export type KvConsistencyLevel = "strong" | "eventual"; @@ -1361,6 +1450,7 @@ declare namespace Deno { * lexicographically between the given start and end keys. * * @category KV + * @tags unstable */ export type KvListSelector = | { prefix: KvKey } @@ -1399,6 +1489,7 @@ declare namespace Deno { * the value is set to the given value. * * @category KV + * @tags unstable */ export type KvMutation = & { key: KvKey } @@ -1418,6 +1509,7 @@ declare namespace Deno { * iteration from the current position in the future. * * @category KV + * @tags unstable */ export class KvListIterator implements AsyncIterableIterator> { /** @@ -1440,6 +1532,7 @@ declare namespace Deno { * by passing it to the `check` method of a {@linkcode Deno.AtomicOperation}. * * @category KV + * @tags unstable */ export type KvEntry = { key: KvKey; value: T; versionstamp: string }; @@ -1452,6 +1545,7 @@ declare namespace Deno { * fields may be `null` if no value exists for the given key in the KV store. * * @category KV + * @tags unstable */ export type KvEntryMaybe = KvEntry | { key: KvKey; @@ -1464,6 +1558,7 @@ declare namespace Deno { * Options for listing key-value pairs in a {@linkcode Deno.Kv}. * * @category KV + * @tags unstable */ export interface KvListOptions { /** @@ -1516,14 +1611,20 @@ declare namespace Deno { batchSize?: number; } - /** @category KV */ + /** + * @category KV + * @tags unstable + */ export interface KvCommitResult { ok: true; /** The versionstamp of the value committed to KV. */ versionstamp: string; } - /** @category KV */ + /** + * @category KV + * @tags unstable + */ export interface KvCommitError { ok: false; } @@ -1536,6 +1637,7 @@ declare namespace Deno { * that the key-value pair does not currently exist in the KV store. * * @category KV + * @tags unstable */ export interface AtomicCheck { key: KvKey; @@ -1575,9 +1677,9 @@ declare namespace Deno { * an exception will be thrown. If the operation succeeded, the return value * will be a {@linkcode Deno.KvCommitResult} object with a `ok: true` property * and the versionstamp of the value committed to KV. - * * @category KV + * @tags unstable */ export class AtomicOperation { /** @@ -1694,6 +1796,7 @@ declare namespace Deno { * an exception will be thrown. * * @category KV + * @tags unstable */ export class Kv implements Disposable { /** @@ -1964,6 +2067,7 @@ declare namespace Deno { * {@linkcode Deno.Kv}. * * @category KV + * @tags unstable */ export class KvU64 { /** Create a new `KvU64` instance from the given bigint value. If the value @@ -1978,17 +2082,25 @@ declare namespace Deno { * * When accessed outside of Jupyter notebook context an error will be thrown. * - * @category Jupyter */ + * @category Jupyter + * @tags unstable + */ export namespace jupyter { - /** @category Jupyter */ + /** + * @category Jupyter + * @tags unstable + */ export interface DisplayOptions { raw?: boolean; update?: boolean; display_id?: string; } - /** @category Jupyter */ - type VegaObject = { + /** + * @category Jupyter + * @tags unstable + */ + export type VegaObject = { $schema: string; [key: string]: unknown; }; @@ -1997,6 +2109,7 @@ declare namespace Deno { * A collection of supported media types and data for Jupyter frontends. * * @category Jupyter + * @tags unstable */ export type MediaBundle = { "text/plain"?: string; @@ -2026,10 +2139,16 @@ declare namespace Deno { [key: string]: string | object | undefined; }; - /** @category Jupyter */ + /** + * @category Jupyter + * @tags unstable + */ export const $display: unique symbol; - /** @category Jupyter */ + /** + * @category Jupyter + * @tags unstable + */ export type Displayable = { [$display]: () => MediaBundle | Promise; }; @@ -2042,6 +2161,7 @@ declare namespace Deno { * @param obj - The object to be displayed * @param options - Display options with a default { raw: true } * @category Jupyter + * @tags unstable */ export function display(obj: unknown, options?: DisplayOptions): void; @@ -2066,6 +2186,7 @@ declare namespace Deno { * ``` * * @category Jupyter + * @tags unstable */ export function md( strings: TemplateStringsArray, @@ -2085,6 +2206,7 @@ declare namespace Deno { * ``` * * @category Jupyter + * @tags unstable */ export function html( strings: TemplateStringsArray, @@ -2103,6 +2225,7 @@ declare namespace Deno { * ` * * @category Jupyter + * @tags unstable */ export function svg( strings: TemplateStringsArray, @@ -2116,6 +2239,7 @@ declare namespace Deno { * @returns MediaBundle * * @category Jupyter + * @tags unstable */ export function format(obj: unknown): MediaBundle; @@ -2138,7 +2262,9 @@ declare namespace Deno { * }); * ``` * - * @category Jupyter */ + * @category Jupyter + * @tags unstable + */ export function broadcast( msgType: string, content: Record, @@ -2156,7 +2282,7 @@ declare namespace Deno { * which also supports setting a {@linkcode Deno.HttpClient} which provides a * way to connect via proxies and use custom TLS certificates. * - * @tags allow-net, allow-read + * @tags allow-net, allow-read, unstable * @category Fetch API */ declare function fetch( @@ -2167,6 +2293,7 @@ declare function fetch( /** **UNSTABLE**: New API, yet to be vetted. * * @category Web Workers + * @tags unstable */ declare interface WorkerOptions { /** **UNSTABLE**: New API, yet to be vetted. @@ -2207,6 +2334,7 @@ declare interface WorkerOptions { /** **UNSTABLE**: New API, yet to be vetted. * * @category Web Sockets + * @tags unstable */ declare interface WebSocketStreamOptions { protocols?: string[]; @@ -2217,6 +2345,7 @@ declare interface WebSocketStreamOptions { /** **UNSTABLE**: New API, yet to be vetted. * * @category Web Sockets + * @tags unstable */ declare interface WebSocketConnection { readable: ReadableStream; @@ -2228,6 +2357,7 @@ declare interface WebSocketConnection { /** **UNSTABLE**: New API, yet to be vetted. * * @category Web Sockets + * @tags unstable */ declare interface WebSocketCloseInfo { code?: number; @@ -2236,7 +2366,7 @@ declare interface WebSocketCloseInfo { /** **UNSTABLE**: New API, yet to be vetted. * - * @tags allow-net + * @tags allow-net, unstable * @category Web Sockets */ declare interface WebSocketStream { @@ -2248,7 +2378,7 @@ declare interface WebSocketStream { /** **UNSTABLE**: New API, yet to be vetted. * - * @tags allow-net + * @tags allow-net, unstable * @category Web Sockets */ declare var WebSocketStream: { @@ -2258,7 +2388,7 @@ declare var WebSocketStream: { /** **UNSTABLE**: New API, yet to be vetted. * - * @tags allow-net + * @tags allow-net, unstable * @category Web Sockets */ declare interface WebSocketError extends DOMException { @@ -2268,7 +2398,7 @@ declare interface WebSocketError extends DOMException { /** **UNSTABLE**: New API, yet to be vetted. * - * @tags allow-net + * @tags allow-net, unstable * @category Web Sockets */ declare var WebSocketError: { @@ -2282,11 +2412,18 @@ declare var WebSocketError: { * [Specification](https://tc39.es/proposal-temporal/docs/index.html) * * @category Temporal + * @tags unstable */ declare namespace Temporal { - /** @category Temporal */ + /** + * @category Temporal + * @tags unstable + */ export type ComparisonResult = -1 | 0 | 1; - /** @category Temporal */ + /** + * @category Temporal + * @tags unstable + */ export type RoundingMode = | "ceil" | "floor" @@ -2303,6 +2440,7 @@ declare namespace Temporal { * `from()`. * * @category Temporal + * @tags unstable */ export type AssignmentOptions = { /** @@ -2324,6 +2462,7 @@ declare namespace Temporal { * `Duration.prototype.add()` and `Duration.prototype.subtract()`. * * @category Temporal + * @tags unstable */ export type DurationOptions = { /** @@ -2343,6 +2482,7 @@ declare namespace Temporal { * Options for conversions of `Temporal.PlainDateTime` to `Temporal.Instant` * * @category Temporal + * @tags unstable */ export type ToInstantOptions = { /** @@ -2370,8 +2510,11 @@ declare namespace Temporal { disambiguation?: "compatible" | "earlier" | "later" | "reject"; }; - /** @category Temporal */ - type OffsetDisambiguationOptions = { + /** + * @category Temporal + * @tags unstable + */ + export type OffsetDisambiguationOptions = { /** * Time zone definitions can change. If an application stores data about * events in the future, then stored data about future events may become @@ -2407,7 +2550,10 @@ declare namespace Temporal { offset?: "use" | "prefer" | "ignore" | "reject"; }; - /** @category Temporal */ + /** + * @category Temporal + * @tags unstable + */ export type ZonedDateTimeAssignmentOptions = Partial< AssignmentOptions & ToInstantOptions & OffsetDisambiguationOptions >; @@ -2416,6 +2562,7 @@ declare namespace Temporal { * Options for arithmetic operations like `add()` and `subtract()` * * @category Temporal + * @tags unstable */ export type ArithmeticOptions = { /** @@ -2429,9 +2576,15 @@ declare namespace Temporal { overflow?: "constrain" | "reject"; }; - /** @category Temporal */ + /** + * @category Temporal + * @tags unstable + */ export type DateUnit = "year" | "month" | "week" | "day"; - /** @category Temporal */ + /** + * @category Temporal + * @tags unstable + */ export type TimeUnit = | "hour" | "minute" @@ -2439,7 +2592,10 @@ declare namespace Temporal { | "millisecond" | "microsecond" | "nanosecond"; - /** @category Temporal */ + /** + * @category Temporal + * @tags unstable + */ export type DateTimeUnit = DateUnit | TimeUnit; /** @@ -2448,6 +2604,7 @@ declare namespace Temporal { * or 'hours' are aso accepted too. * * @category Temporal + * @tags unstable */ export type PluralUnit = { year: "years"; @@ -2462,17 +2619,27 @@ declare namespace Temporal { nanosecond: "nanoseconds"; }[T]; - /** @category Temporal */ + /** + * @category Temporal + * @tags unstable + */ export type LargestUnit = "auto" | T | PluralUnit; - /** @category Temporal */ + /** + * @category Temporal + * @tags unstable + */ export type SmallestUnit = T | PluralUnit; - /** @category Temporal */ + /** + * @category Temporal + * @tags unstable + */ export type TotalUnit = T | PluralUnit; /** * Options for outputting precision in toString() on types with seconds * * @category Temporal + * @tags unstable */ export type ToStringPrecisionOptions = { fractionalSecondDigits?: "auto" | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; @@ -2497,17 +2664,26 @@ declare namespace Temporal { roundingMode?: RoundingMode; }; - /** @category Temporal */ + /** + * @category Temporal + * @tags unstable + */ export type ShowCalendarOption = { calendarName?: "auto" | "always" | "never" | "critical"; }; - /** @category Temporal */ + /** + * @category Temporal + * @tags unstable + */ export type CalendarTypeToStringOptions = Partial< ToStringPrecisionOptions & ShowCalendarOption >; - /** @category Temporal */ + /** + * @category Temporal + * @tags unstable + */ export type ZonedDateTimeToStringOptions = Partial< CalendarTypeToStringOptions & { timeZoneName?: "auto" | "never" | "critical"; @@ -2515,7 +2691,10 @@ declare namespace Temporal { } >; - /** @category Temporal */ + /** + * @category Temporal + * @tags unstable + */ export type InstantToStringOptions = Partial< ToStringPrecisionOptions & { timeZone: TimeZoneLike; @@ -2527,6 +2706,7 @@ declare namespace Temporal { * `Temporal` types. * * @category Temporal + * @tags unstable */ export interface DifferenceOptions { /** @@ -2589,6 +2769,7 @@ declare namespace Temporal { * `smallestUnit` property value is that string. * * @category Temporal + * @tags unstable */ export type RoundTo = | SmallestUnit @@ -2634,6 +2815,7 @@ declare namespace Temporal { * object whose `smallestUnit` property value is that string. * * @category Temporal + * @tags unstable */ export type DurationRoundTo = | SmallestUnit @@ -2764,6 +2946,7 @@ declare namespace Temporal { * Options to control behavior of `Duration.prototype.total()` * * @category Temporal + * @tags unstable */ export type DurationTotalOf = | TotalUnit @@ -2808,6 +2991,7 @@ declare namespace Temporal { * `Duration.subtract()` * * @category Temporal + * @tags unstable */ export interface DurationArithmeticOptions { /** @@ -2838,7 +3022,10 @@ declare namespace Temporal { | string; } - /** @category Temporal */ + /** + * @category Temporal + * @tags unstable + */ export type DurationLike = { years?: number; months?: number; @@ -2859,6 +3046,7 @@ declare namespace Temporal { * See https://tc39.es/proposal-temporal/docs/duration.html for more details. * * @category Temporal + * @tags unstable */ export class Duration { static from( @@ -2931,6 +3119,7 @@ declare namespace Temporal { * See https://tc39.es/proposal-temporal/docs/instant.html for more details. * * @category Temporal + * @tags unstable */ export class Instant { static fromEpochSeconds(epochSeconds: number): Temporal.Instant; @@ -3010,18 +3199,32 @@ declare namespace Temporal { readonly [Symbol.toStringTag]: "Temporal.Instant"; } - /** @category Temporal */ - type YearOrEraAndEraYear = { era: string; eraYear: number } | { + /** + * @category Temporal + * @tags unstable + */ + export type YearOrEraAndEraYear = { era: string; eraYear: number } | { year: number; }; - /** @category Temporal */ - type MonthCodeOrMonthAndYear = (YearOrEraAndEraYear & { month: number }) | { - monthCode: string; - }; - /** @category Temporal */ - type MonthOrMonthCode = { month: number } | { monthCode: string }; + /** + * @category Temporal + * @tags unstable + */ + export type MonthCodeOrMonthAndYear = + | (YearOrEraAndEraYear & { month: number }) + | { + monthCode: string; + }; + /** + * @category Temporal + * @tags unstable + */ + export type MonthOrMonthCode = { month: number } | { monthCode: string }; - /** @category Temporal */ + /** + * @category Temporal + * @tags unstable + */ export interface CalendarProtocol { id: string; year( @@ -3174,6 +3377,7 @@ declare namespace Temporal { * Any of these types can be passed to Temporal methods instead of a Temporal.Calendar. * * @category Temporal + * @tags unstable */ export type CalendarLike = | string @@ -3193,6 +3397,7 @@ declare namespace Temporal { * See https://tc39.es/proposal-temporal/docs/calendar.html for more details. * * @category Temporal + * @tags unstable */ export class Calendar implements CalendarProtocol { static from(item: CalendarLike): Temporal.Calendar | CalendarProtocol; @@ -3345,7 +3550,10 @@ declare namespace Temporal { readonly [Symbol.toStringTag]: "Temporal.Calendar"; } - /** @category Temporal */ + /** + * @category Temporal + * @tags unstable + */ export type PlainDateLike = { era?: string | undefined; eraYear?: number | undefined; @@ -3356,8 +3564,11 @@ declare namespace Temporal { calendar?: CalendarLike; }; - /** @category Temporal */ - type PlainDateISOFields = { + /** + * @category Temporal + * @tags unstable + */ + export type PlainDateISOFields = { isoYear: number; isoMonth: number; isoDay: number; @@ -3374,6 +3585,7 @@ declare namespace Temporal { * See https://tc39.es/proposal-temporal/docs/date.html for more details. * * @category Temporal + * @tags unstable */ export class PlainDate { static from( @@ -3454,7 +3666,10 @@ declare namespace Temporal { readonly [Symbol.toStringTag]: "Temporal.PlainDate"; } - /** @category Temporal */ + /** + * @category Temporal + * @tags unstable + */ export type PlainDateTimeLike = { era?: string | undefined; eraYear?: number | undefined; @@ -3471,8 +3686,11 @@ declare namespace Temporal { calendar?: CalendarLike; }; - /** @category Temporal */ - type PlainDateTimeISOFields = { + /** + * @category Temporal + * @tags unstable + */ + export type PlainDateTimeISOFields = { isoYear: number; isoMonth: number; isoDay: number; @@ -3496,6 +3714,7 @@ declare namespace Temporal { * See https://tc39.es/proposal-temporal/docs/datetime.html for more details. * * @category Temporal + * @tags unstable */ export class PlainDateTime { static from( @@ -3621,7 +3840,10 @@ declare namespace Temporal { readonly [Symbol.toStringTag]: "Temporal.PlainDateTime"; } - /** @category Temporal */ + /** + * @category Temporal + * @tags unstable + */ export type PlainMonthDayLike = { era?: string | undefined; eraYear?: number | undefined; @@ -3640,6 +3862,7 @@ declare namespace Temporal { * See https://tc39.es/proposal-temporal/docs/monthday.html for more details. * * @category Temporal + * @tags unstable */ export class PlainMonthDay { static from( @@ -3673,7 +3896,10 @@ declare namespace Temporal { readonly [Symbol.toStringTag]: "Temporal.PlainMonthDay"; } - /** @category Temporal */ + /** + * @category Temporal + * @tags unstable + */ export type PlainTimeLike = { hour?: number; minute?: number; @@ -3683,8 +3909,11 @@ declare namespace Temporal { nanosecond?: number; }; - /** @category Temporal */ - type PlainTimeISOFields = { + /** + * @category Temporal + * @tags unstable + */ + export type PlainTimeISOFields = { isoHour: number; isoMinute: number; isoSecond: number; @@ -3709,6 +3938,7 @@ declare namespace Temporal { * See https://tc39.es/proposal-temporal/docs/time.html for more details. * * @category Temporal + * @tags unstable */ export class PlainTime { static from( @@ -3800,6 +4030,7 @@ declare namespace Temporal { * A plain object implementing the protocol for a custom time zone. * * @category Temporal + * @tags unstable */ export interface TimeZoneProtocol { id: string; @@ -3830,6 +4061,7 @@ declare namespace Temporal { * Any of these types can be passed to Temporal methods instead of a Temporal.TimeZone. * * @category Temporal + * @tags unstable */ export type TimeZoneLike = string | TimeZoneProtocol | ZonedDateTime; @@ -3848,6 +4080,7 @@ declare namespace Temporal { * See https://tc39.es/proposal-temporal/docs/timezone.html for more details. * * @category Temporal + * @tags unstable */ export class TimeZone implements TimeZoneProtocol { static from(timeZone: TimeZoneLike): Temporal.TimeZone | TimeZoneProtocol; @@ -3878,7 +4111,10 @@ declare namespace Temporal { readonly [Symbol.toStringTag]: "Temporal.TimeZone"; } - /** @category Temporal */ + /** + * @category Temporal + * @tags unstable + */ export type PlainYearMonthLike = { era?: string | undefined; eraYear?: number | undefined; @@ -3896,6 +4132,7 @@ declare namespace Temporal { * See https://tc39.es/proposal-temporal/docs/yearmonth.html for more details. * * @category Temporal + * @tags unstable */ export class PlainYearMonth { static from( @@ -3958,7 +4195,10 @@ declare namespace Temporal { readonly [Symbol.toStringTag]: "Temporal.PlainYearMonth"; } - /** @category Temporal */ + /** + * @category Temporal + * @tags unstable + */ export type ZonedDateTimeLike = { era?: string | undefined; eraYear?: number | undefined; @@ -3977,8 +4217,11 @@ declare namespace Temporal { calendar?: CalendarLike; }; - /** @category Temporal */ - type ZonedDateTimeISOFields = { + /** + * @category Temporal + * @tags unstable + */ + export type ZonedDateTimeISOFields = { isoYear: number; isoMonth: number; isoDay: number; @@ -3993,7 +4236,10 @@ declare namespace Temporal { calendar: string | CalendarProtocol; }; - /** @category Temporal */ + /** + * @category Temporal + * @tags unstable + */ export class ZonedDateTime { static from( item: Temporal.ZonedDateTime | ZonedDateTimeLike | string, @@ -4127,6 +4373,7 @@ declare namespace Temporal { * See https://tc39.es/proposal-temporal/docs/now.html for more details. * * @category Temporal + * @tags unstable */ export const Now: { /** @@ -4280,15 +4527,24 @@ declare namespace Temporal { }; } -interface Date { - /** @category Temporal */ +/** + * @category Temporal + * @tags unstable + */ +declare interface Date { toTemporalInstant(): Temporal.Instant; } -/** @category Intl */ +/** + * @category Intl + * @tags unstable + */ declare namespace Intl { - /** @category Intl */ - type Formattable = + /** + * @category Intl + * @tags unstable + */ + export type Formattable = | Date | Temporal.Instant | Temporal.ZonedDateTime @@ -4298,12 +4554,18 @@ declare namespace Intl { | Temporal.PlainYearMonth | Temporal.PlainMonthDay; - /** @category Intl */ - interface DateTimeFormatRangePart { + /** + * @category Intl + * @tags unstable + */ + export interface DateTimeFormatRangePart { source: "shared" | "startRange" | "endRange"; } - /** @category Intl */ + /** + * @category Intl + * @tags unstable + */ export interface DateTimeFormat { /** * Format a date into a string according to the locale and formatting @@ -4352,7 +4614,10 @@ declare namespace Intl { ): DateTimeFormatRangePart[]; } - /** @category Intl */ + /** + * @category Intl + * @tags unstable + */ export interface DateTimeFormatOptions { // TODO: remove the props below after TS lib declarations are updated dayPeriod?: "narrow" | "short" | "long"; @@ -4364,8 +4629,11 @@ declare namespace Intl { /** * A typed array of 16-bit float values. The contents are initialized to 0. If the requested number * of bytes could not be allocated an exception is raised. + * + * @category Web APIs + * @tags unstable */ -interface Float16Array { +declare interface Float16Array { /** * The size in bytes of each element in the array. */ @@ -4676,7 +4944,11 @@ interface Float16Array { [index: number]: number; } -interface Float16ArrayConstructor { +/** + * @category Web APIs + * @tags unstable + */ +declare interface Float16ArrayConstructor { readonly prototype: Float16Array; new (length: number): Float16Array; new (array: ArrayLike | ArrayBufferLike): Float16Array; @@ -4715,9 +4987,17 @@ interface Float16ArrayConstructor { thisArg?: any, ): Float16Array; } +/** + * @category Web APIs + * @tags unstable + */ declare var Float16Array: Float16ArrayConstructor; -interface Float16 { +/** + * @category Web APIs + * @tags unstable + */ +declare interface Float16 { [Symbol.iterator](): IterableIterator; /** * Returns an array of key, value pairs for every entry in the array @@ -4733,7 +5013,11 @@ interface Float16 { values(): IterableIterator; } -interface Float16Constructor { +/** + * @category Web APIs + * @tags unstable + */ +declare interface Float16Constructor { new (elements: Iterable): Float16; /** @@ -4749,11 +5033,19 @@ interface Float16Constructor { ): Float16; } -interface Float16Array { +/** + * @category Web APIs + * @tags unstable + */ +declare interface Float16Array { readonly [Symbol.toStringTag]: "Float16Array"; } -interface Float16Array { +/** + * @category Web APIs + * @tags unstable + */ +declare interface Float16Array { /** * Determines whether an array includes a certain element, returning true or false as appropriate. * @param searchElement The element to search for. @@ -4762,11 +5054,19 @@ interface Float16Array { includes(searchElement: number, fromIndex?: number): boolean; } -interface Float16ArrayConstructor { +/** + * @category Web APIs + * @tags unstable + */ +declare interface Float16ArrayConstructor { new (): Float16Array; } -interface Float16Array { +/** + * @category Web APIs + * @tags unstable + */ +declare interface Float16Array { /** * Returns the item located at the specified index. * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. @@ -4774,7 +5074,11 @@ interface Float16Array { at(index: number): number | undefined; } -interface Float16Array { +/** + * @category Web APIs + * @tags unstable + */ +declare interface Float16Array { /** * Returns the value of the last element in the array where predicate is true, and undefined * otherwise. @@ -4846,7 +5150,11 @@ interface Float16Array { with(index: number, value: number): Float16Array; } -interface DataView { +/** + * @category Web APIs + * @tags unstable + */ +declare interface DataView { /** * Gets the Float16 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. diff --git a/cli/tsc/dts/lib.deno.window.d.ts b/cli/tsc/dts/lib.deno.window.d.ts index 6e57174f86481..ed3ff6b6e7cbe 100644 --- a/cli/tsc/dts/lib.deno.window.d.ts +++ b/cli/tsc/dts/lib.deno.window.d.ts @@ -206,6 +206,7 @@ declare function removeEventListener< listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | EventListenerOptions, ): void; +/** @category DOM Events */ declare function removeEventListener( type: string, listener: EventListenerOrEventListenerObject, diff --git a/cli/tsc/dts/lib.deno_webgpu.d.ts b/cli/tsc/dts/lib.deno_webgpu.d.ts index 74fa7c9074151..1b5f92918ca5c 100644 --- a/cli/tsc/dts/lib.deno_webgpu.d.ts +++ b/cli/tsc/dts/lib.deno_webgpu.d.ts @@ -5,17 +5,26 @@ /// /// -/** @category WebGPU */ -interface GPUObjectBase { +/** + * @category WebGPU + * @tags unstable + */ +declare interface GPUObjectBase { label: string; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUObjectDescriptorBase { label?: string; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUSupportedLimits { maxTextureDimension1D?: number; maxTextureDimension2D?: number; @@ -47,7 +56,10 @@ declare class GPUSupportedLimits { maxComputeWorkgroupsPerDimension?: number; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUSupportedFeatures { forEach( callbackfn: ( @@ -65,7 +77,10 @@ declare class GPUSupportedFeatures { values(): IterableIterator; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUAdapterInfo { readonly vendor: string; readonly architecture: string; @@ -73,7 +88,10 @@ declare class GPUAdapterInfo { readonly description: string; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPU { requestAdapter( options?: GPURequestAdapterOptions, @@ -81,16 +99,25 @@ declare class GPU { getPreferredCanvasFormat(): GPUTextureFormat; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPURequestAdapterOptions { powerPreference?: GPUPowerPreference; forceFallbackAdapter?: boolean; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUPowerPreference = "low-power" | "high-performance"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUAdapter { readonly features: GPUSupportedFeatures; readonly limits: GPUSupportedLimits; @@ -100,13 +127,19 @@ declare class GPUAdapter { requestAdapterInfo(unmaskHints?: string[]): Promise; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUDeviceDescriptor extends GPUObjectDescriptorBase { requiredFeatures?: GPUFeatureName[]; requiredLimits?: Record; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUFeatureName = | "depth-clip-control" | "depth32float-stencil8" @@ -131,7 +164,10 @@ declare type GPUFeatureName = | "shader-float64" | "vertex-attribute-64bit"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUDevice extends EventTarget implements GPUObjectBase { label: string; @@ -181,7 +217,10 @@ declare class GPUDevice extends EventTarget implements GPUObjectBase { createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUBuffer implements GPUObjectBase { label: string; @@ -200,23 +239,38 @@ declare class GPUBuffer implements GPUObjectBase { destroy(): undefined; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUBufferMapState = "unmapped" | "pending" | "mapped"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUBufferDescriptor extends GPUObjectDescriptorBase { size: number; usage: GPUBufferUsageFlags; mappedAtCreation?: boolean; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUBufferUsageFlags = number; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUFlagsConstant = number; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUBufferUsage { static MAP_READ: 0x0001; static MAP_WRITE: 0x0002; @@ -230,16 +284,25 @@ declare class GPUBufferUsage { static QUERY_RESOLVE: 0x0200; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUMapModeFlags = number; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUMapMode { static READ: 0x0001; static WRITE: 0x0002; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUTexture implements GPUObjectBase { label: string; @@ -256,7 +319,10 @@ declare class GPUTexture implements GPUObjectBase { readonly usage: GPUFlagsConstant; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUTextureDescriptor extends GPUObjectDescriptorBase { size: GPUExtent3D; mipLevelCount?: number; @@ -267,13 +333,22 @@ declare interface GPUTextureDescriptor extends GPUObjectDescriptorBase { viewFormats?: GPUTextureFormat[]; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUTextureDimension = "1d" | "2d" | "3d"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUTextureUsageFlags = number; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUTextureUsage { static COPY_SRC: 0x01; static COPY_DST: 0x02; @@ -282,12 +357,18 @@ declare class GPUTextureUsage { static RENDER_ATTACHMENT: 0x10; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUTextureView implements GPUObjectBase { label: string; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase { format?: GPUTextureFormat; dimension?: GPUTextureViewDimension; @@ -298,7 +379,10 @@ declare interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase { arrayLayerCount?: number; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUTextureViewDimension = | "1d" | "2d" @@ -307,10 +391,16 @@ declare type GPUTextureViewDimension = | "cube-array" | "3d"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUTextureAspect = "all" | "stencil-only" | "depth-only"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUTextureFormat = | "r8unorm" | "r8snorm" @@ -407,12 +497,18 @@ declare type GPUTextureFormat = | "astc-12x12-unorm" | "astc-12x12-unorm-srgb"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUSampler implements GPUObjectBase { label: string; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUSamplerDescriptor extends GPUObjectDescriptorBase { addressModeU?: GPUAddressMode; addressModeV?: GPUAddressMode; @@ -426,16 +522,28 @@ declare interface GPUSamplerDescriptor extends GPUObjectDescriptorBase { maxAnisotropy?: number; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUFilterMode = "nearest" | "linear"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUMipmapFilterMode = "nearest" | "linear"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUCompareFunction = | "never" | "less" @@ -446,17 +554,26 @@ declare type GPUCompareFunction = | "greater-equal" | "always"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUBindGroupLayout implements GPUObjectBase { label: string; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUBindGroupLayoutDescriptor extends GPUObjectDescriptorBase { entries: GPUBindGroupLayoutEntry[]; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUBindGroupLayoutEntry { binding: number; visibility: GPUShaderStageFlags; @@ -467,45 +584,69 @@ declare interface GPUBindGroupLayoutEntry { storageTexture?: GPUStorageTextureBindingLayout; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUShaderStageFlags = number; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUShaderStage { static VERTEX: 0x1; static FRAGMENT: 0x2; static COMPUTE: 0x4; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUBufferBindingLayout { type?: GPUBufferBindingType; hasDynamicOffset?: boolean; minBindingSize?: number; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUBufferBindingType = "uniform" | "storage" | "read-only-storage"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUSamplerBindingLayout { type?: GPUSamplerBindingType; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUSamplerBindingType = | "filtering" | "non-filtering" | "comparison"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUTextureBindingLayout { sampleType?: GPUTextureSampleType; viewDimension?: GPUTextureViewDimension; multisampled?: boolean; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUTextureSampleType = | "float" | "unfilterable-float" @@ -513,60 +654,93 @@ declare type GPUTextureSampleType = | "sint" | "uint"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUStorageTextureAccess = "write-only"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUStorageTextureBindingLayout { access: GPUStorageTextureAccess; format: GPUTextureFormat; viewDimension?: GPUTextureViewDimension; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUBindGroup implements GPUObjectBase { label: string; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase { layout: GPUBindGroupLayout; entries: GPUBindGroupEntry[]; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUBindingResource = | GPUSampler | GPUTextureView | GPUBufferBinding; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUBindGroupEntry { binding: number; resource: GPUBindingResource; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUBufferBinding { buffer: GPUBuffer; offset?: number; size?: number; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUPipelineLayout implements GPUObjectBase { label: string; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase { bindGroupLayouts: GPUBindGroupLayout[]; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUCompilationMessageType = "error" | "warning" | "info"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUCompilationMessage { readonly message: string; readonly type: GPUCompilationMessageType; @@ -574,62 +748,95 @@ declare interface GPUCompilationMessage { readonly linePos: number; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUCompilationInfo { readonly messages: ReadonlyArray; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUShaderModule implements GPUObjectBase { label: string; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase { code: string; sourceMap?: any; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUAutoLayoutMode = "auto"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUPipelineDescriptorBase extends GPUObjectDescriptorBase { layout: GPUPipelineLayout | GPUAutoLayoutMode; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUPipelineBase { getBindGroupLayout(index: number): GPUBindGroupLayout; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUProgrammableStage { module: GPUShaderModule; entryPoint: string; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUComputePipeline implements GPUObjectBase, GPUPipelineBase { label: string; getBindGroupLayout(index: number): GPUBindGroupLayout; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUComputePipelineDescriptor extends GPUPipelineDescriptorBase { compute: GPUProgrammableStage; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPURenderPipeline implements GPUObjectBase, GPUPipelineBase { label: string; getBindGroupLayout(index: number): GPUBindGroupLayout; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPURenderPipelineDescriptor extends GPUPipelineDescriptorBase { vertex: GPUVertexState; @@ -639,7 +846,10 @@ declare interface GPURenderPipelineDescriptor fragment?: GPUFragmentState; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUPrimitiveState { topology?: GPUPrimitiveTopology; stripIndexFormat?: GPUIndexFormat; @@ -648,7 +858,10 @@ declare interface GPUPrimitiveState { unclippedDepth?: boolean; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUPrimitiveTopology = | "point-list" | "line-list" @@ -656,25 +869,40 @@ declare type GPUPrimitiveTopology = | "triangle-list" | "triangle-strip"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUFrontFace = "ccw" | "cw"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUCullMode = "none" | "front" | "back"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUMultisampleState { count?: number; mask?: number; alphaToCoverageEnabled?: boolean; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUFragmentState extends GPUProgrammableStage { targets: (GPUColorTargetState | null)[]; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUColorTargetState { format: GPUTextureFormat; @@ -682,16 +910,25 @@ declare interface GPUColorTargetState { writeMask?: GPUColorWriteFlags; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUBlendState { color: GPUBlendComponent; alpha: GPUBlendComponent; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUColorWriteFlags = number; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUColorWrite { static RED: 0x1; static GREEN: 0x2; @@ -700,14 +937,20 @@ declare class GPUColorWrite { static ALL: 0xF; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUBlendComponent { operation?: GPUBlendOperation; srcFactor?: GPUBlendFactor; dstFactor?: GPUBlendFactor; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUBlendFactor = | "zero" | "one" @@ -723,7 +966,10 @@ declare type GPUBlendFactor = | "constant" | "one-minus-constant"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUBlendOperation = | "add" | "subtract" @@ -731,7 +977,10 @@ declare type GPUBlendOperation = | "min" | "max"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUDepthStencilState { format: GPUTextureFormat; @@ -749,7 +998,10 @@ declare interface GPUDepthStencilState { depthBiasClamp?: number; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUStencilFaceState { compare?: GPUCompareFunction; failOp?: GPUStencilOperation; @@ -757,7 +1009,10 @@ declare interface GPUStencilFaceState { passOp?: GPUStencilOperation; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUStencilOperation = | "keep" | "zero" @@ -768,10 +1023,16 @@ declare type GPUStencilOperation = | "increment-wrap" | "decrement-wrap"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUIndexFormat = "uint16" | "uint32"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUVertexFormat = | "uint8x2" | "uint8x4" @@ -804,22 +1065,34 @@ declare type GPUVertexFormat = | "sint32x3" | "sint32x4"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUVertexStepMode = "vertex" | "instance"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUVertexState extends GPUProgrammableStage { buffers?: (GPUVertexBufferLayout | null)[]; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUVertexBufferLayout { arrayStride: number; stepMode?: GPUVertexStepMode; attributes: GPUVertexAttribute[]; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUVertexAttribute { format: GPUVertexFormat; offset: number; @@ -827,22 +1100,34 @@ declare interface GPUVertexAttribute { shaderLocation: number; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUImageDataLayout { offset?: number; bytesPerRow?: number; rowsPerImage?: number; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUCommandBuffer implements GPUObjectBase { label: string; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase {} -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUCommandEncoder implements GPUObjectBase { label: string; @@ -900,15 +1185,24 @@ declare class GPUCommandEncoder implements GPUObjectBase { finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {} -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUImageCopyBuffer extends GPUImageDataLayout { buffer: GPUBuffer; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUImageCopyTexture { texture: GPUTexture; mipLevel?: number; @@ -916,8 +1210,11 @@ declare interface GPUImageCopyTexture { aspect?: GPUTextureAspect; } -/** @category WebGPU */ -interface GPUProgrammablePassEncoder { +/** + * @category WebGPU + * @tags unstable + */ +declare interface GPUProgrammablePassEncoder { setBindGroup( index: number, bindGroup: GPUBindGroup, @@ -937,7 +1234,10 @@ interface GPUProgrammablePassEncoder { insertDebugMarker(markerLabel: string): undefined; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder { label: string; @@ -966,20 +1266,29 @@ declare class GPUComputePassEncoder end(): undefined; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUComputePassTimestampWrites { querySet: GPUQuerySet; beginningOfPassWriteIndex?: number; endOfPassWriteIndex?: number; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { timestampWrites?: GPUComputePassTimestampWrites; } -/** @category WebGPU */ -interface GPURenderEncoderBase { +/** + * @category WebGPU + * @tags unstable + */ +declare interface GPURenderEncoderBase { setPipeline(pipeline: GPURenderPipeline): undefined; setIndexBuffer( @@ -1016,7 +1325,10 @@ interface GPURenderEncoderBase { ): undefined; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase { label: string; @@ -1093,14 +1405,20 @@ declare class GPURenderPassEncoder end(): undefined; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPURenderPassTimestampWrites { querySet: GPUQuerySet; beginningOfPassWriteIndex?: number; endOfPassWriteIndex?: number; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPURenderPassDescriptor extends GPUObjectDescriptorBase { colorAttachments: (GPURenderPassColorAttachment | null)[]; depthStencilAttachment?: GPURenderPassDepthStencilAttachment; @@ -1108,7 +1426,10 @@ declare interface GPURenderPassDescriptor extends GPUObjectDescriptorBase { timestampWrites?: GPURenderPassTimestampWrites; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPURenderPassColorAttachment { view: GPUTextureView; resolveTarget?: GPUTextureView; @@ -1118,7 +1439,10 @@ declare interface GPURenderPassColorAttachment { storeOp: GPUStoreOp; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPURenderPassDepthStencilAttachment { view: GPUTextureView; @@ -1133,21 +1457,36 @@ declare interface GPURenderPassDepthStencilAttachment { stencilReadOnly?: boolean; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPULoadOp = "load" | "clear"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUStoreOp = "store" | "discard"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPURenderBundle implements GPUObjectBase { label: string; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase {} -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPURenderBundleEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase { label: string; @@ -1201,20 +1540,29 @@ declare class GPURenderBundleEncoder finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPURenderPassLayout extends GPUObjectDescriptorBase { colorFormats: (GPUTextureFormat | null)[]; depthStencilFormat?: GPUTextureFormat; sampleCount?: number; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPURenderBundleEncoderDescriptor extends GPURenderPassLayout { depthReadOnly?: boolean; stencilReadOnly?: boolean; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUQueue implements GPUObjectBase { label: string; @@ -1238,7 +1586,10 @@ declare class GPUQueue implements GPUObjectBase { ): undefined; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUQuerySet implements GPUObjectBase { label: string; @@ -1248,43 +1599,70 @@ declare class GPUQuerySet implements GPUObjectBase { readonly count: number; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase { type: GPUQueryType; count: number; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUQueryType = "occlusion" | "timestamp"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUDeviceLostReason = "destroyed"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUDeviceLostInfo { readonly reason: GPUDeviceLostReason; readonly message: string; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUError { readonly message: string; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUOutOfMemoryError extends GPUError { constructor(message: string); } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare class GPUValidationError extends GPUError { constructor(message: string); } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUErrorFilter = "out-of-memory" | "validation"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUColorDict { r: number; g: number; @@ -1292,33 +1670,54 @@ declare interface GPUColorDict { a: number; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUColor = number[] | GPUColorDict; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUOrigin3DDict { x?: number; y?: number; z?: number; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUOrigin3D = number[] | GPUOrigin3DDict; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUExtent3DDict { width: number; height?: number; depthOrArrayLayers?: number; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUExtent3D = number[] | GPUExtent3DDict; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare type GPUCanvasAlphaMode = "opaque" | "premultiplied"; -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUCanvasConfiguration { device: GPUDevice; format: GPUTextureFormat; @@ -1329,7 +1728,10 @@ declare interface GPUCanvasConfiguration { width: number; height: number; } -/** @category WebGPU */ +/** + * @category WebGPU + * @tags unstable + */ declare interface GPUCanvasContext { configure(configuration: GPUCanvasConfiguration): undefined; unconfigure(): undefined; diff --git a/ext/broadcast_channel/lib.deno_broadcast_channel.d.ts b/ext/broadcast_channel/lib.deno_broadcast_channel.d.ts index 8eab8bc2da779..a3d74c07bb33d 100644 --- a/ext/broadcast_channel/lib.deno_broadcast_channel.d.ts +++ b/ext/broadcast_channel/lib.deno_broadcast_channel.d.ts @@ -5,13 +5,19 @@ /// /// -/** @category Broadcast Channel */ +/** + * @category Broadcast Channel + * @tags unstable + */ declare interface BroadcastChannelEventMap { "message": MessageEvent; "messageerror": MessageEvent; } -/** @category Broadcast Channel */ +/** + * @category Broadcast Channel + * @tags unstable + */ declare interface BroadcastChannel extends EventTarget { /** * Returns the channel name (as passed to the constructor). @@ -51,7 +57,10 @@ declare interface BroadcastChannel extends EventTarget { ): void; } -/** @category Broadcast Channel */ +/** + * @category Broadcast Channel + * @tags unstable + */ declare var BroadcastChannel: { readonly prototype: BroadcastChannel; new (name: string): BroadcastChannel; diff --git a/ext/canvas/lib.deno_canvas.d.ts b/ext/canvas/lib.deno_canvas.d.ts index 7498429c6ee39..da72ae94627e4 100644 --- a/ext/canvas/lib.deno_canvas.d.ts +++ b/ext/canvas/lib.deno_canvas.d.ts @@ -21,7 +21,7 @@ declare type ResizeQuality = "high" | "low" | "medium" | "pixelated"; declare type ImageBitmapSource = Blob | ImageData; /** @category Web APIs */ -interface ImageBitmapOptions { +declare interface ImageBitmapOptions { colorSpaceConversion?: ColorSpaceConversion; imageOrientation?: ImageOrientation; premultiplyAlpha?: PremultiplyAlpha; @@ -46,7 +46,7 @@ declare function createImageBitmap( ): Promise; /** @category Web APIs */ -interface ImageBitmap { +declare interface ImageBitmap { readonly height: number; readonly width: number; close(): void; diff --git a/ext/fetch/23_request.js b/ext/fetch/23_request.js index 70e00a874eda8..873d05a2b5a11 100644 --- a/ext/fetch/23_request.js +++ b/ext/fetch/23_request.js @@ -9,7 +9,7 @@ /// /// -import { core, primordials } from "ext:core/mod.js"; +import { core, internals, primordials } from "ext:core/mod.js"; const { ArrayPrototypeMap, ArrayPrototypeSlice, @@ -269,10 +269,20 @@ class Request { /** @type {AbortSignal} */ get [_signal]() { const signal = this[_signalCache]; - if (signal !== undefined) { + // This signal not been created yet, and the request is still in progress + if (signal === undefined) { + const signal = newSignal(); + this[_signalCache] = signal; return signal; } - return (this[_signalCache] = newSignal()); + // This signal has not been created yet, but the request has already completed + if (signal === false) { + const signal = newSignal(); + this[_signalCache] = signal; + signal[signalAbort](signalAbortError); + return signal; + } + return signal; } get [_mimeType]() { const values = getDecodeSplitHeader( @@ -593,11 +603,20 @@ const signalAbortError = new DOMException( ObjectFreeze(signalAbortError); function abortRequest(request) { - if (request[_signal]) { + if (request[_signalCache] !== undefined) { request[_signal][signalAbort](signalAbortError); + } else { + request[_signalCache] = false; } } +function getCachedAbortSignal(request) { + return request[_signalCache]; +} + +// For testing +internals.getCachedAbortSignal = getCachedAbortSignal; + export { abortRequest, fromInnerRequest, diff --git a/ext/io/12_io.js b/ext/io/12_io.js index c43117cef2134..094868371e00b 100644 --- a/ext/io/12_io.js +++ b/ext/io/12_io.js @@ -9,6 +9,7 @@ import { op_set_raw } from "ext:core/ops"; const { Uint8Array, ArrayPrototypePush, + Symbol, TypedArrayPrototypeSubarray, TypedArrayPrototypeSet, TypedArrayPrototypeGetByteLength, @@ -181,9 +182,14 @@ const STDIN_RID = 0; const STDOUT_RID = 1; const STDERR_RID = 2; +const REF = Symbol("REF"); +const UNREF = Symbol("UNREF"); + class Stdin { #rid = STDIN_RID; + #ref = true; #readable; + #opPromise; constructor() { } @@ -197,8 +203,14 @@ class Stdin { return this.#rid; } - read(p) { - return read(this.#rid, p); + async read(p) { + if (p.length === 0) return 0; + this.#opPromise = core.read(this.#rid, p); + if (!this.#ref) { + core.unrefOpPromise(this.#opPromise); + } + const nread = await this.#opPromise; + return nread === 0 ? null : nread; } readSync(p) { @@ -224,6 +236,20 @@ class Stdin { isTerminal() { return core.isTerminal(this.#rid); } + + [REF]() { + this.#ref = true; + if (this.#opPromise) { + core.refOpPromise(this.#opPromise); + } + } + + [UNREF]() { + this.#ref = false; + if (this.#opPromise) { + core.unrefOpPromise(this.#opPromise); + } + } } class Stdout { @@ -318,6 +344,7 @@ export { readAll, readAllSync, readSync, + REF, SeekMode, Stderr, stderr, @@ -327,6 +354,7 @@ export { Stdout, stdout, STDOUT_RID, + UNREF, write, writeSync, }; diff --git a/ext/node/lib.rs b/ext/node/lib.rs index c99467d239121..43a5b158e30e4 100644 --- a/ext/node/lib.rs +++ b/ext/node/lib.rs @@ -241,6 +241,8 @@ deno_core::extension!(deno_node, ops::crypto::op_node_ecdh_compute_secret, ops::crypto::op_node_ecdh_compute_public_key, ops::crypto::op_node_ecdh_encode_pubkey, + ops::crypto::op_node_export_rsa_public_pem, + ops::crypto::op_node_export_rsa_spki_der, ops::crypto::x509::op_node_x509_parse, ops::crypto::x509::op_node_x509_ca, ops::crypto::x509::op_node_x509_check_email, diff --git a/ext/node/ops/crypto/mod.rs b/ext/node/ops/crypto/mod.rs index ed1b7fc7571d6..f39fb6d10f5dd 100644 --- a/ext/node/ops/crypto/mod.rs +++ b/ext/node/ops/crypto/mod.rs @@ -42,6 +42,7 @@ use rsa::Oaep; use rsa::Pkcs1v15Encrypt; use rsa::RsaPrivateKey; use rsa::RsaPublicKey; +use spki::EncodePublicKey; mod cipher; mod dh; @@ -681,13 +682,32 @@ pub async fn op_node_generate_rsa_async( spawn_blocking(move || generate_rsa(modulus_length, public_exponent)).await? } +#[op2] +#[string] +pub fn op_node_export_rsa_public_pem( + #[buffer] pkcs1_der: &[u8], +) -> Result { + let public_key = RsaPublicKey::from_pkcs1_der(pkcs1_der)?; + let export = public_key.to_public_key_pem(Default::default())?; + Ok(export) +} + +#[op2] +#[serde] +pub fn op_node_export_rsa_spki_der( + #[buffer] pkcs1_der: &[u8], +) -> Result { + let public_key = RsaPublicKey::from_pkcs1_der(pkcs1_der)?; + let export = public_key.to_public_key_der()?.to_vec(); + Ok(export.into()) +} + fn dsa_generate( modulus_length: usize, divisor_length: usize, ) -> Result<(ToJsBuffer, ToJsBuffer), AnyError> { let mut rng = rand::thread_rng(); use dsa::pkcs8::EncodePrivateKey; - use dsa::pkcs8::EncodePublicKey; use dsa::Components; use dsa::KeySize; use dsa::SigningKey; diff --git a/ext/node/polyfills/02_init.js b/ext/node/polyfills/02_init.js index 752f518bf2ef0..71eebbc81acc0 100644 --- a/ext/node/polyfills/02_init.js +++ b/ext/node/polyfills/02_init.js @@ -29,7 +29,12 @@ function initialize( // FIXME(bartlomieju): not nice to depend on `Deno` namespace here // but it's the only way to get `args` and `version` and this point. - internals.__bootstrapNodeProcess(argv0, Deno.args, Deno.version); + internals.__bootstrapNodeProcess( + argv0, + Deno.args, + Deno.version, + Deno.env.get("NODE_DEBUG") ?? "", + ); internals.__initWorkerThreads( runningOnMainThread, workerId, @@ -40,7 +45,13 @@ function initialize( delete internals.requireImpl; } else { // Warm up the process module - internals.__bootstrapNodeProcess(undefined, undefined, undefined, true); + internals.__bootstrapNodeProcess( + undefined, + undefined, + undefined, + undefined, + true, + ); } } diff --git a/ext/node/polyfills/internal/crypto/keygen.ts b/ext/node/polyfills/internal/crypto/keygen.ts index f3263aecf1228..dd5d5ad7e44bf 100644 --- a/ext/node/polyfills/internal/crypto/keygen.ts +++ b/ext/node/polyfills/internal/crypto/keygen.ts @@ -7,6 +7,8 @@ import { KeyObject } from "ext:deno_node/internal/crypto/keys.ts"; import { kAesKeyLengths } from "ext:deno_node/internal/crypto/util.ts"; import { + PrivateKeyObject, + PublicKeyObject, SecretKeyObject, setOwnedKey, } from "ext:deno_node/internal/crypto/keys.ts"; @@ -564,8 +566,8 @@ export function generateKeyPair( ) => void, ) { createJob(kAsync, type, options).then(([privateKey, publicKey]) => { - privateKey = new KeyObject("private", setOwnedKey(privateKey)); - publicKey = new KeyObject("public", setOwnedKey(publicKey)); + privateKey = new PrivateKeyObject(setOwnedKey(privateKey), { type }); + publicKey = new PublicKeyObject(setOwnedKey(publicKey), { type }); if (typeof options === "object" && options !== null) { const { publicKeyEncoding, privateKeyEncoding } = options as any; @@ -766,8 +768,8 @@ export function generateKeyPairSync( | KeyPairSyncResult { let [privateKey, publicKey] = createJob(kSync, type, options); - privateKey = new KeyObject("private", setOwnedKey(privateKey)); - publicKey = new KeyObject("public", setOwnedKey(publicKey)); + privateKey = new PrivateKeyObject(setOwnedKey(privateKey), { type }); + publicKey = new PublicKeyObject(setOwnedKey(publicKey), { type }); if (typeof options === "object" && options !== null) { const { publicKeyEncoding, privateKeyEncoding } = options as any; diff --git a/ext/node/polyfills/internal/crypto/keys.ts b/ext/node/polyfills/internal/crypto/keys.ts index 4ab8cac4f6572..8cb9ab6906f11 100644 --- a/ext/node/polyfills/internal/crypto/keys.ts +++ b/ext/node/polyfills/internal/crypto/keys.ts @@ -7,6 +7,8 @@ import { op_node_create_private_key, op_node_create_public_key, + op_node_export_rsa_public_pem, + op_node_export_rsa_spki_der, } from "ext:core/ops"; import { @@ -360,7 +362,7 @@ class AsymmetricKeyObject extends KeyObject { } } -class PrivateKeyObject extends AsymmetricKeyObject { +export class PrivateKeyObject extends AsymmetricKeyObject { constructor(handle: unknown, details: unknown) { super("private", handle, details); } @@ -370,13 +372,35 @@ class PrivateKeyObject extends AsymmetricKeyObject { } } -class PublicKeyObject extends AsymmetricKeyObject { +export class PublicKeyObject extends AsymmetricKeyObject { constructor(handle: unknown, details: unknown) { super("public", handle, details); } - export(_options: unknown) { - notImplemented("crypto.PublicKeyObject.prototype.export"); + export(options: unknown) { + const key = KEY_STORE.get(this[kHandle]); + switch (this.asymmetricKeyType) { + case "rsa": + case "rsa-pss": { + switch (options.format) { + case "pem": + return op_node_export_rsa_public_pem(key); + case "der": { + if (options.type == "pkcs1") { + return key; + } else { + return op_node_export_rsa_spki_der(key); + } + } + default: + throw new TypeError(`exporting ${options.type} is not implemented`); + } + } + default: + throw new TypeError( + `exporting ${this.asymmetricKeyType} is not implemented`, + ); + } } } @@ -414,4 +438,6 @@ export default { prepareSecretKey, setOwnedKey, SecretKeyObject, + PrivateKeyObject, + PublicKeyObject, }; diff --git a/ext/node/polyfills/internal/streams/destroy.mjs b/ext/node/polyfills/internal/streams/destroy.mjs index 74e6687db8877..06c4a2ed8bcbb 100644 --- a/ext/node/polyfills/internal/streams/destroy.mjs +++ b/ext/node/polyfills/internal/streams/destroy.mjs @@ -2,14 +2,10 @@ // Copyright Joyent and Node contributors. All rights reserved. MIT license. // deno-lint-ignore-file -import { - aggregateTwoErrors, - ERR_MULTIPLE_CALLBACK, -} from "ext:deno_node/internal/errors.ts"; +import { aggregateTwoErrors } from "ext:deno_node/internal/errors.ts"; import * as process from "ext:deno_node/_process/process.ts"; const kDestroy = Symbol("kDestroy"); -const kConstruct = Symbol("kConstruct"); function checkError(err, w, r) { if (err) { @@ -155,37 +151,6 @@ function emitErrorNT(self, err) { self.emit("error", err); } -function undestroy() { - const r = this._readableState; - const w = this._writableState; - - if (r) { - r.constructed = true; - r.closed = false; - r.closeEmitted = false; - r.destroyed = false; - r.errored = null; - r.errorEmitted = false; - r.reading = false; - r.ended = false; - r.endEmitted = false; - } - - if (w) { - w.constructed = true; - w.destroyed = false; - w.closed = false; - w.closeEmitted = false; - w.errored = null; - w.errorEmitted = false; - w.ended = false; - w.ending = false; - w.finalCalled = false; - w.prefinished = false; - w.finished = false; - } -} - function errorOrDestroy(stream, err, sync) { // We have tests that rely on errors being emitted // in the same tick, so changing this is semver major. @@ -220,104 +185,5 @@ function errorOrDestroy(stream, err, sync) { } } -function construct(stream, cb) { - if (typeof stream._construct !== "function") { - return; - } - - const r = stream._readableState; - const w = stream._writableState; - - if (r) { - r.constructed = false; - } - if (w) { - w.constructed = false; - } - - stream.once(kConstruct, cb); - - if (stream.listenerCount(kConstruct) > 1) { - // Duplex - return; - } - - process.nextTick(constructNT, stream); -} - -function constructNT(stream) { - let called = false; - - function onConstruct(err) { - if (called) { - errorOrDestroy(stream, err ?? new ERR_MULTIPLE_CALLBACK()); - return; - } - called = true; - - const r = stream._readableState; - const w = stream._writableState; - const s = w || r; - - if (r) { - r.constructed = true; - } - if (w) { - w.constructed = true; - } - - if (s.destroyed) { - stream.emit(kDestroy, err); - } else if (err) { - errorOrDestroy(stream, err, true); - } else { - process.nextTick(emitConstructNT, stream); - } - } - - try { - const result = stream._construct(onConstruct); - if (result != null) { - const then = result.then; - if (typeof then === "function") { - then.call( - result, - function () { - process.nextTick(onConstruct, null); - }, - function (err) { - process.nextTick(onConstruct, err); - }, - ); - } - } - } catch (err) { - onConstruct(err); - } -} - -function emitConstructNT(stream) { - stream.emit(kConstruct); -} - -function isRequest(stream) { - return stream && stream.setHeader && typeof stream.abort === "function"; -} - -// Normalize destroy for legacy. -function destroyer(stream, err) { - if (!stream) return; - if (isRequest(stream)) return stream.abort(); - if (isRequest(stream.req)) return stream.req.abort(); - if (typeof stream.destroy === "function") return stream.destroy(err); - if (typeof stream.close === "function") return stream.close(); -} - -export default { - construct, - destroyer, - destroy, - undestroy, - errorOrDestroy, -}; -export { construct, destroy, destroyer, errorOrDestroy, undestroy }; +export default { destroy, errorOrDestroy }; +export { destroy, errorOrDestroy }; diff --git a/ext/node/polyfills/internal/util/debuglog.ts b/ext/node/polyfills/internal/util/debuglog.ts index 3cbcf2c5c5154..9bbaed606fa3a 100644 --- a/ext/node/polyfills/internal/util/debuglog.ts +++ b/ext/node/polyfills/internal/util/debuglog.ts @@ -12,7 +12,7 @@ let debugImpls: Record void>; let testEnabled: (str: string) => boolean; // `debugEnv` is initial value of process.env.NODE_DEBUG -function initializeDebugEnv(debugEnv: string) { +export function initializeDebugEnv(debugEnv: string) { debugImpls = Object.create(null); if (debugEnv) { // This is run before any user code, it's OK not to use primordials. @@ -106,20 +106,4 @@ export function debuglog( return logger; } -let debugEnv; -/* TODO(kt3k): enable initializing debugEnv. -It's not possible to access env var when snapshotting. - -try { - debugEnv = Deno.env.get("NODE_DEBUG") ?? ""; -} catch (error) { - if (error instanceof Deno.errors.PermissionDenied) { - debugEnv = ""; - } else { - throw error; - } -} -*/ -initializeDebugEnv(debugEnv); - export default { debuglog }; diff --git a/ext/node/polyfills/process.ts b/ext/node/polyfills/process.ts index 7f522386cc336..b24bf6a8e4b9e 100644 --- a/ext/node/polyfills/process.ts +++ b/ext/node/polyfills/process.ts @@ -5,6 +5,7 @@ // deno-lint-ignore-file prefer-primordials import { core, internals } from "ext:core/mod.js"; +import { initializeDebugEnv } from "ext:deno_node/internal/util/debuglog.ts"; import { op_geteuid, op_node_process_kill, @@ -845,6 +846,7 @@ internals.__bootstrapNodeProcess = function ( argv0Val: string | undefined, args: string[], denoVersions: Record, + nodeDebug: string, warmup = false, ) { if (!warmup) { @@ -891,6 +893,8 @@ internals.__bootstrapNodeProcess = function ( platform = isWindows ? "win32" : Deno.build.os; pid = Deno.pid; + initializeDebugEnv(nodeDebug); + // @ts-ignore Remove setStartTime and #startTime is not modifiable delete process.setStartTime; delete internals.__bootstrapNodeProcess; diff --git a/ext/node/polyfills/tty.js b/ext/node/polyfills/tty.js index c44f7e946c89c..3a84a1f948d42 100644 --- a/ext/node/polyfills/tty.js +++ b/ext/node/polyfills/tty.js @@ -9,7 +9,10 @@ const { } = core; import { ERR_INVALID_FD } from "ext:deno_node/internal/errors.ts"; -import { LibuvStreamWrap } from "ext:deno_node/internal_binding/stream_wrap.ts"; +import { + kStreamBaseField, + LibuvStreamWrap, +} from "ext:deno_node/internal_binding/stream_wrap.ts"; import { providerType } from "ext:deno_node/internal_binding/async_wrap.ts"; import { Socket } from "node:net"; import { setReadStream } from "ext:deno_node/_process/streams.mjs"; @@ -36,6 +39,14 @@ class TTY extends LibuvStreamWrap { constructor(handle) { super(providerType.TTYWRAP, handle); } + + ref() { + this[kStreamBaseField][io.REF](); + } + + unref() { + this[kStreamBaseField][io.UNREF](); + } } export class ReadStream extends Socket { diff --git a/ext/node/polyfills/worker_threads.ts b/ext/node/polyfills/worker_threads.ts index 8f531368ae616..e88e6368b5535 100644 --- a/ext/node/polyfills/worker_threads.ts +++ b/ext/node/polyfills/worker_threads.ts @@ -473,6 +473,12 @@ class NodeMessageChannel { } } +const listeners = new SafeWeakMap< + // deno-lint-ignore no-explicit-any + (...args: any[]) => void, + // deno-lint-ignore no-explicit-any + (ev: any) => any +>(); function webMessagePortToNodeMessagePort(port: MessagePort) { port.on = port.addListener = function (this: MessagePort, name, listener) { // deno-lint-ignore no-explicit-any @@ -486,6 +492,24 @@ function webMessagePortToNodeMessagePort(port: MessagePort) { } else { throw new Error(`Unknown event: "${name}"`); } + listeners.set(listener, _listener); + return this; + }; + port.off = port.removeListener = function ( + this: MessagePort, + name, + listener, + ) { + if (name == "message") { + port.removeEventListener("message", listeners.get(listener)!); + } else if (name == "messageerror") { + port.removeEventListener("messageerror", listeners.get(listener)!); + } else if (name == "close") { + port.removeEventListener("close", listeners.get(listener)!); + } else { + throw new Error(`Unknown event: "${name}"`); + } + listeners.delete(listener); return this; }; port[nodeWorkerThreadCloseCb] = () => { diff --git a/ext/web/13_message_port.js b/ext/web/13_message_port.js index 4e4184f2a3e69..93145e8f74c6f 100644 --- a/ext/web/13_message_port.js +++ b/ext/web/13_message_port.js @@ -190,6 +190,11 @@ class MessagePort extends EventTarget { this[_enabled] = true; while (true) { if (this[_id] === null) break; + // Exit if no message event listeners are present in Node compat mode. + if ( + typeof this[nodeWorkerThreadCloseCb] == "function" && + messageEventListenerCount === 0 + ) break; let data; try { data = await op_message_port_recv_message( diff --git a/ext/websocket/lib.deno_websocket.d.ts b/ext/websocket/lib.deno_websocket.d.ts index b7227c255d473..311bf2b24d226 100644 --- a/ext/websocket/lib.deno_websocket.d.ts +++ b/ext/websocket/lib.deno_websocket.d.ts @@ -28,6 +28,7 @@ declare interface CloseEvent extends Event { readonly wasClean: boolean; } +/** @category Web Sockets */ declare var CloseEvent: { readonly prototype: CloseEvent; new (type: string, eventInitDict?: CloseEventInit): CloseEvent; diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 5552f6f315054..5393d15893e72 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -43,7 +43,7 @@ deno_lockfile.workspace = true deno_terminal.workspace = true deno_tls.workspace = true fastwebsockets = { workspace = true, features = ["upgrade", "unstable-split"] } -file_test_runner = "0.4.0" +file_test_runner = "0.4.1" flaky_test = "=0.1.0" http.workspace = true http-body-util.workspace = true diff --git a/tests/integration/bench_tests.rs b/tests/integration/bench_tests.rs index 3306a0f968fd5..d588f5b43797b 100644 --- a/tests/integration/bench_tests.rs +++ b/tests/integration/bench_tests.rs @@ -3,223 +3,11 @@ use deno_core::serde_json::json; use deno_core::url::Url; use test_util as util; -use test_util::itest; -use test_util::itest_flaky; use util::assert_contains; use util::assert_not_contains; -use util::env_vars_for_npm_tests; use util::TestContext; use util::TestContextBuilder; -itest!(overloads { - args: "bench bench/overloads.ts", - exit_code: 0, - output: "bench/overloads.out", -}); - -itest!(meta { - args: "bench bench/meta.ts", - exit_code: 0, - output: "bench/meta.out", -}); - -itest!(pass { - args: "bench bench/pass.ts", - exit_code: 0, - output: "bench/pass.out", -}); - -itest!(ignore { - args: "bench bench/ignore.ts", - exit_code: 0, - output: "bench/ignore.out", -}); - -itest!(ignore_permissions { - args: "bench bench/ignore_permissions.ts", - exit_code: 0, - output: "bench/ignore_permissions.out", -}); - -itest!(fail { - args: "bench bench/fail.ts", - exit_code: 1, - output: "bench/fail.out", -}); - -itest!(bench_formatting { - args: "bench bench/bench_formatting.ts", - exit_code: 0, - output: "bench/bench_formatting.out", -}); - -itest!(collect { - args: "bench --ignore=bench/collect/ignore bench/collect", - exit_code: 0, - output: "bench/collect.out", -}); - -itest!(load_unload { - args: "bench bench/load_unload.ts", - exit_code: 0, - output: "bench/load_unload.out", -}); - -itest!(interval { - args: "bench bench/interval.ts", - exit_code: 0, - output: "bench/interval.out", -}); - -itest!(quiet { - args: "bench --quiet bench/quiet.ts", - exit_code: 0, - output: "bench/quiet.out", -}); - -itest!(only { - args: "bench bench/only.ts", - exit_code: 1, - output: "bench/only.out", -}); - -itest!(multifile_summary { - args: "bench bench/group_baseline.ts bench/pass.ts bench/multiple_group.ts", - exit_code: 0, - output: "bench/multifile_summary.out", -}); - -itest!(no_check { - args: "bench --no-check bench/no_check.ts", - exit_code: 1, - output: "bench/no_check.out", -}); - -itest!(allow_all { - args: "bench --allow-all bench/allow_all.ts", - exit_code: 0, - output: "bench/allow_all.out", -}); - -itest!(allow_none { - args: "bench bench/allow_none.ts", - exit_code: 1, - output: "bench/allow_none.out", -}); - -itest!(exit_sanitizer { - args: "bench bench/exit_sanitizer.ts", - output: "bench/exit_sanitizer.out", - exit_code: 1, -}); - -itest!(clear_timeout { - args: "bench bench/clear_timeout.ts", - exit_code: 0, - output: "bench/clear_timeout.out", -}); - -itest!(finally_timeout { - args: "bench bench/finally_timeout.ts", - exit_code: 1, - output: "bench/finally_timeout.out", -}); - -itest!(before_unload_prevent_default { - args: "bench --quiet bench/before_unload_prevent_default.ts", - output: "bench/before_unload_prevent_default.out", -}); - -itest!(group_baseline { - args: "bench bench/group_baseline.ts", - exit_code: 0, - output: "bench/group_baseline.out", -}); - -itest!(unresolved_promise { - args: "bench bench/unresolved_promise.ts", - exit_code: 1, - output: "bench/unresolved_promise.out", -}); - -itest!(unhandled_rejection { - args: "bench bench/unhandled_rejection.ts", - exit_code: 1, - output: "bench/unhandled_rejection.out", -}); - -itest!(filter { - args: "bench --filter=foo bench/filter", - exit_code: 0, - output: "bench/filter.out", -}); - -itest!(no_run { - args: "bench --no-run bench/no_run.ts", - output: "bench/no_run.out", - exit_code: 1, -}); - -itest!(no_prompt_by_default { - args: "bench --quiet bench/no_prompt_by_default.ts", - exit_code: 1, - output: "bench/no_prompt_by_default.out", -}); - -itest!(no_prompt_with_denied_perms { - args: "bench --quiet --allow-read bench/no_prompt_with_denied_perms.ts", - exit_code: 1, - output: "bench/no_prompt_with_denied_perms.out", -}); - -itest!(check_local_by_default { - args: "bench --quiet bench/check_local_by_default.ts", - output: "bench/check_local_by_default.out", - http_server: true, -}); - -itest!(check_local_by_default2 { - args: "bench --quiet bench/check_local_by_default2.ts", - output: "bench/check_local_by_default2.out", - http_server: true, - exit_code: 1, -}); - -itest!(bench_explicit_start_end { - args: "bench --quiet -A bench/explicit_start_and_end.ts", - output: "bench/explicit_start_and_end.out", - exit_code: 1, -}); - -itest_flaky!(bench_explicit_start_end_low_precision { - args: "bench --quiet -A bench/explicit_start_and_end_low_precision.ts", - output: "bench/explicit_start_and_end_low_precision.out", -}); - -itest!(bench_with_config { - args: "bench --config bench/collect/deno.jsonc bench/collect", - exit_code: 0, - output: "bench/collect.out", -}); - -itest!(bench_with_config2 { - args: "bench --config bench/collect/deno2.jsonc bench/collect", - exit_code: 0, - output: "bench/collect2.out", -}); - -itest!(bench_with_malformed_config { - args: "bench --config bench/collect/deno.malformed.jsonc", - exit_code: 1, - output: "bench/collect_with_malformed_config.out", -}); - -itest!(json_output { - args: "bench --json bench/pass.ts", - exit_code: 0, - output: "bench/pass.json.out", -}); - #[test] fn recursive_permissions_pledge() { let context = TestContext::default(); @@ -248,31 +36,6 @@ fn file_protocol() { .assert_matches_file("bench/file_protocol.out"); } -itest!(package_json_basic { - args: "bench", - output: "package_json/basic/lib.bench.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!(bench_lock { - args: "bench", - http_server: true, - cwd: Some("lockfile/basic"), - exit_code: 10, - output: "lockfile/basic/fail.out", -}); - -itest!(bench_no_lock { - args: "bench --no-lock", - http_server: true, - cwd: Some("lockfile/basic"), - output: "lockfile/basic/bench.nolock.out", -}); - #[test] fn conditionally_loads_type_graph() { let context = TestContext::default(); diff --git a/tests/integration/cache_tests.rs b/tests/integration/cache_tests.rs index ff206c654f2c6..5711b0f2eb304 100644 --- a/tests/integration/cache_tests.rs +++ b/tests/integration/cache_tests.rs @@ -1,53 +1,8 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -use test_util::env_vars_for_npm_tests; -use test_util::itest; use test_util::TestContext; use test_util::TestContextBuilder; -itest!(_037_fetch_multiple { - args: "cache --reload --check=all run/fetch/test.ts run/fetch/other.ts", - http_server: true, - output: "cache/037_fetch_multiple.out", -}); - -itest!(_095_cache_with_bare_import { - args: "cache cache/095_cache_with_bare_import.ts", - output: "cache/095_cache_with_bare_import.ts.out", - exit_code: 1, -}); - -itest!(cache_extensionless { - args: "cache --reload --check=all http://localhost:4545/subdir/no_js_ext", - output: "cache/cache_extensionless.out", - http_server: true, -}); - -itest!(cache_random_extension { - args: - "cache --reload --check=all http://localhost:4545/subdir/no_js_ext@1.0.0", - output: "cache/cache_random_extension.out", - http_server: true, -}); - -itest!(performance_stats { - args: "cache --reload --check=all --log-level debug run/002_hello.ts", - output: "cache/performance_stats.out", -}); - -itest!(redirect_cache { - http_server: true, - args: - "cache --reload --check=all http://localhost:4548/subdir/redirects/a.ts", - output: "cache/redirect_cache.out", -}); - -itest!(ignore_require { - args: "cache --reload --no-check cache/ignore_require.js", - output_str: Some(""), - exit_code: 0, -}); - // This test only runs on linux, because it hardcodes the XDG_CACHE_HOME env var // which is only used on linux. #[cfg(target_os = "linux")] @@ -71,33 +26,6 @@ fn xdg_cache_home_dir() { assert!(xdg_cache_home.read_dir().count() > 0); } -itest!(check_local_by_default { - args: "cache --quiet cache/check_local_by_default.ts", - output: "cache/check_local_by_default.out", - http_server: true, -}); - -itest!(check_local_by_default2 { - args: "cache --quiet cache/check_local_by_default2.ts", - output: "cache/check_local_by_default2.out", - http_server: true, -}); - -itest!(json_import { - // should not error - args: "cache --quiet cache/json_import/main.ts", -}); - -itest!(package_json_basic { - args: "cache main.ts", - output: "package_json/basic/main.cache.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, -}); - #[test] fn cache_matching_package_json_dep_should_not_install_all() { let context = TestContextBuilder::for_npm().use_temp_cwd().build(); diff --git a/tests/integration/check_tests.rs b/tests/integration/check_tests.rs index 72fb2d9b726fb..78ab859f925e7 100644 --- a/tests/integration/check_tests.rs +++ b/tests/integration/check_tests.rs @@ -6,24 +6,6 @@ use util::env_vars_for_npm_tests; use util::TestContext; use util::TestContextBuilder; -itest!(_095_check_with_bare_import { - args: "check cache/095_cache_with_bare_import.ts", - output: "cache/095_cache_with_bare_import.ts.out", - exit_code: 1, -}); - -itest!(check_extensionless { - args: "check --reload http://localhost:4545/subdir/no_js_ext", - output: "cache/cache_extensionless.out", - http_server: true, -}); - -itest!(check_random_extension { - args: "check --reload http://localhost:4545/subdir/no_js_ext@1.0.0", - output: "cache/cache_random_extension.out", - http_server: true, -}); - itest!(check_all { args: "check --quiet --all check/all/check_all.ts", output: "check/all/check_all.out", @@ -145,12 +127,6 @@ itest!(check_imported_files_listed_in_exclude_option { exit_code: 1, }); -itest!(check_with_excluded_file_specified { - args: "check lib/types.d.ts", - cwd: Some("check/excluded_file_specified/"), - output: "check/excluded_file_specified/check.out", -}); - #[test] fn cache_switching_config_then_no_config() { let context = TestContext::default(); @@ -279,13 +255,6 @@ itest!(check_dts { exit_code: 1, }); -itest!(check_types_dts { - args: "check main.ts", - cwd: Some("check/types_dts/"), - output: "check/types_dts/main.out", - exit_code: 0, -}); - itest!(package_json_basic { args: "check main.ts", output: "package_json/basic/main.check.out", diff --git a/tests/integration/doc_tests.rs b/tests/integration/doc_tests.rs index 8ebc46f32c438..605166ac20278 100644 --- a/tests/integration/doc_tests.rs +++ b/tests/integration/doc_tests.rs @@ -106,21 +106,6 @@ itest!(deno_doc_invalid_url { exit_code: 1, }); -itest!(doc_lock { - args: "doc main.ts", - http_server: true, - cwd: Some("lockfile/basic"), - exit_code: 10, - output: "lockfile/basic/fail.out", -}); - -itest!(doc_no_lock { - args: "doc --no-lock main.ts", - http_server: true, - cwd: Some("lockfile/basic"), - output: "lockfile/basic/doc.nolock.out", -}); - #[test] fn deno_doc_html() { let context = TestContext::default(); diff --git a/tests/integration/info_tests.rs b/tests/integration/info_tests.rs index 4697cc2b8c4f0..a2e3c2d4f17ff 100644 --- a/tests/integration/info_tests.rs +++ b/tests/integration/info_tests.rs @@ -100,21 +100,6 @@ itest!(info_missing_module { output: "info/info_missing_module.out", }); -itest!(info_lock { - args: "info main.ts", - http_server: true, - cwd: Some("lockfile/basic"), - exit_code: 10, - output: "lockfile/basic/fail.out", -}); - -itest!(info_no_lock { - args: "info --no-lock main.ts", - http_server: true, - cwd: Some("lockfile/basic"), - output: "lockfile/basic/info.nolock.out", -}); - itest!(info_recursive_modules { args: "info --quiet info/info_recursive_imports_test.ts", output: "info/info_recursive_imports_test.out", diff --git a/tests/integration/jsr_tests.rs b/tests/integration/jsr_tests.rs index 307398fc5475d..83d696093d5f8 100644 --- a/tests/integration/jsr_tests.rs +++ b/tests/integration/jsr_tests.rs @@ -128,7 +128,7 @@ fn specifiers_in_lockfile() { temp_dir.write( "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);"#, ); @@ -146,8 +146,8 @@ console.log(version);"#, .content .packages .specifiers - .get_mut("jsr:@denotest/no_module_graph@0.1") - .unwrap() = "jsr:@denotest/no_module_graph@0.1.0".to_string(); + .get_mut("jsr:@denotest/no-module-graph@0.1") + .unwrap() = "jsr:@denotest/no-module-graph@0.1.0".to_string(); lockfile_path.write(lockfile.as_json_string()); test_context @@ -238,7 +238,7 @@ fn lockfile_bad_package_integrity() { temp_dir.write( "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);"#, ); @@ -252,14 +252,14 @@ console.log(version);"#, let lockfile_path = temp_dir.path().join("deno.lock"); 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); set_lockfile_pkg_integrity(&mut lockfile, pkg_name, "bad_integrity"); lockfile_path.write(lockfile.as_json_string()); let actual_integrity = - 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 + 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 Actual: {} Expected: bad_integrity diff --git a/tests/integration/lint_tests.rs b/tests/integration/lint_tests.rs index a55fb1ef4b231..c0b1b4286e251 100644 --- a/tests/integration/lint_tests.rs +++ b/tests/integration/lint_tests.rs @@ -213,48 +213,6 @@ fn lint_with_glob_config_and_flags() { assert_contains!(output, "Checked 2 files"); } -itest!(no_slow_types { - args: "lint", - output: "lint/no_slow_types/no_slow_types.out", - cwd: Some("lint/no_slow_types"), - exit_code: 1, -}); - -itest!(no_slow_types_entrypoint { - args: "lint a.ts", - output: "lint/no_slow_types/no_slow_types_entrypoint.out", - cwd: Some("lint/no_slow_types"), - exit_code: 1, -}); - -itest!(no_slow_types_non_entrypoint { - args: "lint d.ts", - output_str: Some("Checked 1 file\n"), - cwd: Some("lint/no_slow_types"), - exit_code: 0, -}); - -itest!(no_slow_types_excluded { - args: "lint --rules-exclude=no-slow-types", - output_str: Some("Checked 4 files\n"), - cwd: Some("lint/no_slow_types"), - exit_code: 0, -}); - -itest!(no_slow_types_non_package { - args: "lint --config=deno.non-package.json", - output_str: Some("Checked 4 files\n"), - cwd: Some("lint/no_slow_types"), - exit_code: 0, -}); - -itest!(no_slow_types_workspace { - args: "lint", - output: "lint/no_slow_types_workspace/output.out", - cwd: Some("lint/no_slow_types_workspace"), - exit_code: 1, -}); - #[test] fn opt_out_top_level_exclude_via_lint_unexclude() { let context = TestContextBuilder::new().use_temp_cwd().build(); diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs index 1c5cc31f22ed5..2e4b6da3080fe 100644 --- a/tests/integration/lsp_tests.rs +++ b/tests/integration/lsp_tests.rs @@ -1459,7 +1459,8 @@ fn lsp_hover_asset() { "language": "typescript", "value": "interface Date", }, - "Enables basic storage and retrieval of dates and times." + "Enables basic storage and retrieval of dates and times.", + "\n\n*@category* - Temporal \n\n*@tags* - unstable" ], "range": { "start": { "line": 111, "character": 10, }, @@ -2035,7 +2036,7 @@ fn lsp_hover_unstable_always_enabled() { "value":"interface Deno.ForeignLibraryInterface" }, "**UNSTABLE**: New API, yet to be vetted.\n\nA foreign library interface descriptor.", - "\n\n*@category* - FFI", + "\n\n*@category* - FFI \n\n*@tags* - unstable", ], "range":{ "start":{ "line":0, "character":14 }, @@ -2080,7 +2081,7 @@ fn lsp_hover_unstable_enabled() { "value":"interface Deno.ForeignLibraryInterface" }, "**UNSTABLE**: New API, yet to be vetted.\n\nA foreign library interface descriptor.", - "\n\n*@category* - FFI", + "\n\n*@category* - FFI \n\n*@tags* - unstable", ], "range":{ "start":{ "line":0, "character":14 }, diff --git a/tests/integration/publish_tests.rs b/tests/integration/publish_tests.rs index a033f5d070d23..26acbd24491a3 100644 --- a/tests/integration/publish_tests.rs +++ b/tests/integration/publish_tests.rs @@ -5,81 +5,11 @@ use std::process::Command; use deno_core::serde_json::json; use test_util::assert_contains; use test_util::assert_not_contains; -use test_util::env_vars_for_jsr_npm_tests; use test_util::env_vars_for_jsr_provenance_tests; use test_util::env_vars_for_jsr_tests; use test_util::env_vars_for_jsr_tests_with_git_check; -use test_util::env_vars_for_npm_tests; -use test_util::itest; use test_util::TestContextBuilder; -itest!(no_token { - args: "publish", - cwd: Some("publish/missing_deno_json"), - output: "publish/no_token.out", - envs: env_vars_for_jsr_tests(), - exit_code: 1, -}); - -itest!(missing_deno_json { - args: "publish --token 'sadfasdf'", - output: "publish/missing_deno_json.out", - cwd: Some("publish/missing_deno_json"), - envs: env_vars_for_jsr_tests(), - exit_code: 1, -}); - -itest!(has_slow_types { - args: "publish --token 'sadfasdf'", - output: "publish/has_slow_types.out", - cwd: Some("publish/has_slow_types"), - envs: env_vars_for_jsr_tests(), - exit_code: 1, -}); - -itest!(allow_slow_types { - args: "publish --allow-slow-types --token 'sadfasdf'", - output: "publish/allow_slow_types.out", - cwd: Some("publish/has_slow_types"), - envs: env_vars_for_jsr_tests(), - http_server: true, - exit_code: 0, -}); - -itest!(invalid_path { - args: "publish --token 'sadfasdf'", - output: "publish/invalid_path.out", - cwd: Some("publish/invalid_path"), - envs: env_vars_for_jsr_tests(), - exit_code: 1, -}); - -itest!(symlink { - args: "publish --token 'sadfasdf' --dry-run", - output: "publish/symlink.out", - cwd: Some("publish/symlink"), - envs: env_vars_for_jsr_tests(), - exit_code: 0, -}); - -itest!(invalid_import { - args: "publish --token 'sadfasdf' --dry-run", - output: "publish/invalid_import.out", - cwd: Some("publish/invalid_import"), - envs: env_vars_for_jsr_npm_tests(), - exit_code: 1, - http_server: true, -}); - -itest!(invalid_import_esm_sh_suggestion { - args: "publish --token 'sadfasdf' --dry-run", - output: "publish/invalid_import_esm_sh_suggestion.out", - cwd: Some("publish/invalid_import_esm_sh_suggestion"), - envs: env_vars_for_jsr_npm_tests(), - exit_code: 1, - http_server: true, -}); - #[test] fn publish_non_exported_files_using_import_map() { let context = publish_context_builder().build(); @@ -139,191 +69,19 @@ fn publish_warning_not_in_graph() { ); } -itest!(javascript_missing_decl_file { - args: "publish --token 'sadfasdf'", - output: "publish/javascript_missing_decl_file.out", - cwd: Some("publish/javascript_missing_decl_file"), - envs: env_vars_for_jsr_tests(), - exit_code: 0, - http_server: true, -}); - -itest!(unanalyzable_dynamic_import { - args: "publish --token 'sadfasdf'", - output: "publish/unanalyzable_dynamic_import.out", - cwd: Some("publish/unanalyzable_dynamic_import"), - envs: env_vars_for_jsr_tests(), - exit_code: 0, - http_server: true, -}); - -itest!(javascript_decl_file { - args: "publish --token 'sadfasdf'", - output: "publish/javascript_decl_file.out", - cwd: Some("publish/javascript_decl_file"), - envs: env_vars_for_jsr_tests(), - http_server: true, - exit_code: 0, -}); - -itest!(package_json { - args: "publish --token 'sadfasdf'", - output: "publish/package_json.out", - cwd: Some("publish/package_json"), - envs: env_vars_for_jsr_npm_tests(), - http_server: true, -}); - -itest!(successful { - args: "publish --token 'sadfasdf'", - output: "publish/successful.out", - cwd: Some("publish/successful"), - envs: env_vars_for_jsr_tests(), - http_server: true, -}); - -itest!(provenance { - args: "publish", - output: "publish/successful_provenance.out", - cwd: Some("publish/successful"), - envs: env_vars_for_jsr_provenance_tests(), - http_server: true, -}); - -itest!(no_check { - args: "publish --token 'sadfasdf' --no-check", - // still type checks the slow types output though - output: "publish/successful_no_check.out", - cwd: Some("publish/successful"), - envs: env_vars_for_jsr_tests(), - http_server: true, -}); - -itest!(node_specifier { - args: "publish --token 'sadfasdf'", - output: "publish/node_specifier.out", - cwd: Some("publish/node_specifier"), - envs: env_vars_for_jsr_tests() - .into_iter() - .chain(env_vars_for_npm_tests().into_iter()) - .collect(), - http_server: true, -}); - -itest!(config_file_jsonc { - args: "publish --token 'sadfasdf'", - output: "publish/deno_jsonc.out", - cwd: Some("publish/deno_jsonc"), - envs: env_vars_for_jsr_tests(), - http_server: true, -}); - -itest!(workspace_all { - args: "publish --token 'sadfasdf'", - output: "publish/workspace.out", - cwd: Some("publish/workspace"), - envs: env_vars_for_jsr_tests(), - http_server: true, -}); - -itest!(workspace_individual { - args: "publish --token 'sadfasdf'", - output: "publish/workspace_individual.out", - cwd: Some("publish/workspace/bar"), - envs: env_vars_for_jsr_tests(), - http_server: true, -}); - -itest!(dry_run { - args: "publish --token 'sadfasdf' --dry-run", - cwd: Some("publish/successful"), - output: "publish/dry_run.out", - envs: env_vars_for_jsr_tests(), - http_server: true, -}); - -itest!(config_flag { - args: "publish --token 'sadfasdf' --config=successful/deno.json", - output: "publish/successful.out", - cwd: Some("publish"), - envs: env_vars_for_jsr_tests(), - http_server: true, -}); - -itest!(bare_node_builtins { - args: "publish --token 'sadfasdf' --dry-run --unstable-bare-node-builtins", - output: "publish/bare_node_builtins.out", - cwd: Some("publish/bare_node_builtins"), - envs: env_vars_for_jsr_npm_tests(), - http_server: true, -}); - -itest!(bare_node_builtins_warning_no_warnings { - args: "publish --token 'sadfasdf' --dry-run --unstable-bare-node-builtins", - output: "publish/bare_node_builtins_no_warnings.out", - cwd: Some("publish/bare_node_builtins"), - envs: env_vars_for_jsr_npm_tests() - .into_iter() - .chain( - vec![( - "DENO_DISABLE_PEDANTIC_NODE_WARNINGS".to_string(), - "1".to_string() - )] - .into_iter() - ) - .collect(), - http_server: true, -}); - -itest!(sloppy_imports { - args: "publish --token 'sadfasdf' --dry-run --unstable-sloppy-imports", - output: "publish/sloppy_imports.out", - cwd: Some("publish/sloppy_imports"), - envs: env_vars_for_jsr_tests(), - http_server: true, -}); - -itest!(sloppy_imports_not_enabled { - args: "publish --token 'sadfasdf' --dry-run", - output: "publish/sloppy_imports_not_enabled.out", - cwd: Some("publish/sloppy_imports"), - envs: env_vars_for_jsr_tests(), - http_server: true, - exit_code: 1, -}); - -itest!(sloppy_imports_no_warnings { - args: "publish --token 'sadfasdf' --dry-run --unstable-sloppy-imports", - output: "publish/sloppy_imports_no_warnings.out", - cwd: Some("publish/sloppy_imports"), - envs: env_vars_for_jsr_tests() - .into_iter() - .chain( - vec![( - "DENO_DISABLE_PEDANTIC_NODE_WARNINGS".to_string(), - "1".to_string() - )] - .into_iter() - ) - .collect(), - http_server: true, -}); - -itest!(jsr_jsonc { - args: "publish --token 'sadfasdf'", - cwd: Some("publish/jsr_jsonc"), - output: "publish/jsr_jsonc/mod.out", - envs: env_vars_for_jsr_tests(), - http_server: true, -}); - -itest!(unsupported_jsx_tsx { - args: "publish --token 'sadfasdf'", - cwd: Some("publish/unsupported_jsx_tsx"), - output: "publish/unsupported_jsx_tsx/mod.out", - envs: env_vars_for_jsr_npm_tests(), - http_server: true, -}); +#[test] +fn provenance() { + TestContextBuilder::new() + .use_http_server() + .envs(env_vars_for_jsr_provenance_tests()) + .cwd("publish/successful") + .build() + .new_command() + .args("publish") + .run() + .assert_exit_code(0) + .assert_matches_file("publish/successful_provenance.out"); +} #[test] fn ignores_gitignore() { @@ -629,20 +387,6 @@ fn not_includes_vendor_dir_only_when_vendor_true() { } } -fn publish_context_builder() -> TestContextBuilder { - TestContextBuilder::new() - .use_http_server() - .envs(env_vars_for_jsr_tests()) - .use_temp_cwd() -} - -fn publish_context_builder_with_git_checks() -> TestContextBuilder { - TestContextBuilder::new() - .use_http_server() - .envs(env_vars_for_jsr_tests_with_git_check()) - .use_temp_cwd() -} - #[test] fn allow_dirty() { let context = publish_context_builder_with_git_checks().build(); @@ -739,3 +483,17 @@ fn allow_dirty_dry_run() { let output = output.combined_output(); assert_contains!(output, "Aborting due to uncommitted changes. Check in source code or run with --allow-dirty"); } + +fn publish_context_builder() -> TestContextBuilder { + TestContextBuilder::new() + .use_http_server() + .envs(env_vars_for_jsr_tests()) + .use_temp_cwd() +} + +fn publish_context_builder_with_git_checks() -> TestContextBuilder { + TestContextBuilder::new() + .use_http_server() + .envs(env_vars_for_jsr_tests_with_git_check()) + .use_temp_cwd() +} diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs index 6419f6ff0f01a..e28251b23d4d0 100644 --- a/tests/integration/run_tests.rs +++ b/tests/integration/run_tests.rs @@ -1018,7 +1018,7 @@ fn lock_deno_json_package_json_deps() { deno_json.write_json(&json!({ "imports": { "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"); @@ -1035,11 +1035,11 @@ fn lock_deno_json_package_json_deps() { "version": "3", "packages": { "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" }, "jsr": { - "@denotest/module_graph@1.4.0": { + "@denotest/module-graph@1.4.0": { "integrity": "32de0973c5fa55772326fcd504a757f386d2b010db3e13e78f3bcf851e69473d" } }, @@ -1053,7 +1053,7 @@ fn lock_deno_json_package_json_deps() { "remote": {}, "workspace": { "dependencies": [ - "jsr:@denotest/module_graph@1.4", + "jsr:@denotest/module-graph@1.4", "npm:@denotest/esm-basic" ] } @@ -1063,7 +1063,7 @@ fn lock_deno_json_package_json_deps() { // it to a package.json that uses an alias deno_json.write_json(&json!({ "imports": { - "module_graph": "jsr:@denotest/module_graph@1.4", + "module_graph": "jsr:@denotest/module-graph@1.4", } })); package_json.write_json(&json!({ @@ -1087,11 +1087,11 @@ fn lock_deno_json_package_json_deps() { "version": "3", "packages": { "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" }, "jsr": { - "@denotest/module_graph@1.4.0": { + "@denotest/module-graph@1.4.0": { "integrity": "32de0973c5fa55772326fcd504a757f386d2b010db3e13e78f3bcf851e69473d" } }, @@ -1105,7 +1105,7 @@ fn lock_deno_json_package_json_deps() { "remote": {}, "workspace": { "dependencies": [ - "jsr:@denotest/module_graph@1.4" + "jsr:@denotest/module-graph@1.4" ], "packageJson": { "dependencies": [ @@ -1128,10 +1128,10 @@ fn lock_deno_json_package_json_deps() { "version": "3", "packages": { "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": { - "@denotest/module_graph@1.4.0": { + "@denotest/module-graph@1.4.0": { "integrity": "32de0973c5fa55772326fcd504a757f386d2b010db3e13e78f3bcf851e69473d" } } @@ -1139,7 +1139,7 @@ fn lock_deno_json_package_json_deps() { "remote": {}, "workspace": { "dependencies": [ - "jsr:@denotest/module_graph@1.4" + "jsr:@denotest/module-graph@1.4" ] } })); @@ -3439,17 +3439,6 @@ itest!(config_not_auto_discovered_for_remote_script { http_server: true, }); -itest!(package_json_auto_discovered_for_local_script_arg { - args: "run -L debug -A no_deno_json/main.ts", - output: "run/with_package_json/no_deno_json/main.out", - // notice this is not in no_deno_json - cwd: Some("run/with_package_json/"), - // prevent creating a node_modules dir in the code directory - copy_temp_dir: Some("run/with_package_json/"), - envs: env_vars_for_npm_tests(), - http_server: true, -}); - // In this case we shouldn't discover `package.json` file, because it's in a // directory that is above the directory containing `deno.json` file. itest!( @@ -3464,36 +3453,6 @@ itest!( } ); -itest!(package_json_not_auto_discovered_no_config { - args: "run -L debug -A --no-config noconfig.ts", - output: "run/with_package_json/no_deno_json/noconfig.out", - cwd: Some("run/with_package_json/no_deno_json/"), -}); - -itest!(package_json_not_auto_discovered_no_npm { - args: "run -L debug -A --no-npm noconfig.ts", - output: "run/with_package_json/no_deno_json/noconfig.out", - cwd: Some("run/with_package_json/no_deno_json/"), -}); - -itest!(package_json_not_auto_discovered_env_var { - args: "run -L debug -A noconfig.ts", - output: "run/with_package_json/no_deno_json/noconfig.out", - cwd: Some("run/with_package_json/no_deno_json/"), - envs: vec![("DENO_NO_PACKAGE_JSON".to_string(), "1".to_string())], -}); - -itest!( - package_json_auto_discovered_node_modules_relative_package_json { - args: "run -A main.js", - output: "run/with_package_json/no_deno_json/sub_dir/main.out", - cwd: Some("run/with_package_json/no_deno_json/sub_dir"), - copy_temp_dir: Some("run/with_package_json/no_deno_json/"), - envs: env_vars_for_npm_tests(), - http_server: true, - } -); - 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", @@ -3503,14 +3462,6 @@ itest!(package_json_auto_discovered_for_npm_binary { http_server: true, }); -itest!(package_json_auto_discovered_no_package_json_imports { - // this should not use --quiet because we should ensure no package.json install occurs - args: "run -A no_package_json_imports.ts", - output: "run/with_package_json/no_deno_json/no_package_json_imports.out", - cwd: Some("run/with_package_json/no_deno_json"), - copy_temp_dir: Some("run/with_package_json/no_deno_json"), -}); - #[test] fn package_json_with_deno_json() { let context = TestContextBuilder::for_npm() @@ -5359,3 +5310,32 @@ fn code_cache_npm_with_require_test() { assert!(!output.stderr().contains("Updating V8 code cache")); } } + +#[test] +fn node_process_stdin_unref_with_pty() { + TestContext::default() + .new_command() + .args_vec(["run", "--quiet", "run/node_process_stdin_unref_with_pty.js"]) + .with_pty(|mut console| { + console.expect("START\r\n"); + console.write_line("foo"); + console.expect("foo\r\n"); + console.write_line("bar"); + console.expect("bar\r\n"); + console.write_line("baz"); + console.expect("baz\r\n"); + }); + + TestContext::default() + .new_command() + .args_vec([ + "run", + "--quiet", + "run/node_process_stdin_unref_with_pty.js", + "--unref", + ]) + .with_pty(|mut console| { + // if process.stdin.unref is called, the program immediately ends by skipping reading from stdin. + console.expect("START\r\nEND\r\n"); + }); +} diff --git a/tests/integration/test_tests.rs b/tests/integration/test_tests.rs index 2bf2b31099115..fe9eb83c54169 100644 --- a/tests/integration/test_tests.rs +++ b/tests/integration/test_tests.rs @@ -584,21 +584,6 @@ itest!(package_json_basic { exit_code: 0, }); -itest!(test_lock { - args: "test", - http_server: true, - cwd: Some("lockfile/basic"), - exit_code: 10, - output: "lockfile/basic/fail.out", -}); - -itest!(test_no_lock { - args: "test --no-lock", - http_server: true, - cwd: Some("lockfile/basic"), - output: "lockfile/basic/test.nolock.out", -}); - itest!(test_replace_timers { args: "test test/replace_timers.js", output: "test/replace_timers.js.out", @@ -676,12 +661,6 @@ fn conditionally_loads_type_graph() { assert_not_contains!(output.combined_output(), "type_reference.d.ts"); } -itest!(test_include_relative_pattern_dot_slash { - args: "test", - output: "test/relative_pattern_dot_slash/output.out", - cwd: Some("test/relative_pattern_dot_slash"), -}); - #[test] fn opt_out_top_level_exclude_via_test_unexclude() { let context = TestContextBuilder::new().use_temp_cwd().build(); diff --git a/tests/specs/README.md b/tests/specs/README.md index d9c620aa71a50..5711b41d5067d 100644 --- a/tests/specs/README.md +++ b/tests/specs/README.md @@ -78,6 +78,8 @@ a "steps" array. - `output` - Path to use to assert the output. - `cleanDenoDir` (boolean) - Whether to empty the deno_dir before running the step. +- `flaky` - Step should be repeated until success a maximum of 3 times. +- `if` (`"windows"`, `"linux"`, `"mac"`, `"unix"`) - Whether to run this step. - `exitCode` (number) - Expected exit code. ### Auto-complete diff --git a/tests/specs/bench/allow_all/__test__.jsonc b/tests/specs/bench/allow_all/__test__.jsonc new file mode 100644 index 0000000000000..dcc5cc421bf52 --- /dev/null +++ b/tests/specs/bench/allow_all/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench --allow-all allow_all.ts", + "output": "allow_all.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/allow_all/allow_all.out b/tests/specs/bench/allow_all/allow_all.out new file mode 100644 index 0000000000000..0c6a8a034bdcc --- /dev/null +++ b/tests/specs/bench/allow_all/allow_all.out @@ -0,0 +1,23 @@ +[WILDCARD] +Check [WILDLINE]/allow_all.ts +cpu: [WILDLINE] +runtime: deno [WILDLINE] ([WILDLINE]) + +[WILDLINE]/allow_all.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +------------------------------------------------------------------ ----------------------------- +read false [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +read true [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +write false [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +write true [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +net false [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +net true [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +env false [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +env true [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +run false [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +run true [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +ffi false [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +ffi true [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +hrtime false [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +hrtime true [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] + diff --git a/tests/testdata/bench/allow_all.ts b/tests/specs/bench/allow_all/allow_all.ts similarity index 92% rename from tests/testdata/bench/allow_all.ts rename to tests/specs/bench/allow_all/allow_all.ts index b31aaf397f3ac..9747fb414258c 100644 --- a/tests/testdata/bench/allow_all.ts +++ b/tests/specs/bench/allow_all/allow_all.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../../../tests/util/std/assert/mod.ts"; +import { assertEquals } from "jsr:@std/assert"; const permissions: Deno.PermissionName[] = [ "read", diff --git a/tests/specs/bench/allow_none/__test__.jsonc b/tests/specs/bench/allow_none/__test__.jsonc new file mode 100644 index 0000000000000..9ae51f75bc56a --- /dev/null +++ b/tests/specs/bench/allow_none/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench allow_none.ts", + "output": "allow_none.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/allow_none/allow_none.out b/tests/specs/bench/allow_none/allow_none.out new file mode 100644 index 0000000000000..cfe86adcbcb39 --- /dev/null +++ b/tests/specs/bench/allow_none/allow_none.out @@ -0,0 +1,22 @@ +Check [WILDLINE]/allow_none.ts +cpu: [WILDLINE] +runtime: deno [WILDLINE] ([WILDLINE]) + +[WILDLINE]/allow_none.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +read error: PermissionDenied: Can't escalate parent thread permissions +[WILDCARD] +write error: PermissionDenied: Can't escalate parent thread permissions +[WILDCARD] +net error: PermissionDenied: Can't escalate parent thread permissions +[WILDCARD] +env error: PermissionDenied: Can't escalate parent thread permissions +[WILDCARD] +run error: PermissionDenied: Can't escalate parent thread permissions +[WILDCARD] +ffi error: PermissionDenied: Can't escalate parent thread permissions +[WILDCARD] +hrtime error: PermissionDenied: Can't escalate parent thread permissions +[WILDCARD] +error: Bench failed diff --git a/tests/testdata/bench/allow_none.ts b/tests/specs/bench/allow_none/allow_none.ts similarity index 73% rename from tests/testdata/bench/allow_none.ts rename to tests/specs/bench/allow_none/allow_none.ts index 0cf3c27ef8f3e..77f86f2564b04 100644 --- a/tests/testdata/bench/allow_none.ts +++ b/tests/specs/bench/allow_none/allow_none.ts @@ -1,5 +1,3 @@ -import { unreachable } from "../../../tests/util/std/assert/mod.ts"; - const permissions: Deno.PermissionName[] = [ "read", "write", @@ -17,7 +15,7 @@ for (const name of permissions) { [name]: true, }, fn() { - unreachable(); + throw new Error("unreachable"); }, }); } diff --git a/tests/specs/bench/before_unload_prevent_default/__test__.jsonc b/tests/specs/bench/before_unload_prevent_default/__test__.jsonc new file mode 100644 index 0000000000000..5253af5dfe693 --- /dev/null +++ b/tests/specs/bench/before_unload_prevent_default/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "bench --quiet before_unload_prevent_default.ts", + "output": "before_unload_prevent_default.out" +} diff --git a/tests/specs/bench/before_unload_prevent_default/before_unload_prevent_default.out b/tests/specs/bench/before_unload_prevent_default/before_unload_prevent_default.out new file mode 100644 index 0000000000000..dcb6d819480eb --- /dev/null +++ b/tests/specs/bench/before_unload_prevent_default/before_unload_prevent_default.out @@ -0,0 +1,7 @@ +cpu: [WILDCARD] +runtime: deno [WILDCARD] + +[WILDCARD]/before_unload_prevent_default.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +foo [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/tests/testdata/bench/before_unload_prevent_default.ts b/tests/specs/bench/before_unload_prevent_default/before_unload_prevent_default.ts similarity index 100% rename from tests/testdata/bench/before_unload_prevent_default.ts rename to tests/specs/bench/before_unload_prevent_default/before_unload_prevent_default.ts diff --git a/tests/specs/bench/bench_explicit_start_end/__test__.jsonc b/tests/specs/bench/bench_explicit_start_end/__test__.jsonc new file mode 100644 index 0000000000000..e8e5bf8c2f9cf --- /dev/null +++ b/tests/specs/bench/bench_explicit_start_end/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench --quiet -A explicit_start_and_end.ts", + "output": "explicit_start_and_end.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/bench_explicit_start_end/explicit_start_and_end.out b/tests/specs/bench/bench_explicit_start_end/explicit_start_and_end.out new file mode 100644 index 0000000000000..fa118540c96b2 --- /dev/null +++ b/tests/specs/bench/bench_explicit_start_end/explicit_start_and_end.out @@ -0,0 +1,25 @@ +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/explicit_start_and_end.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +------------------------------------------------------------------- ----------------------------- +start and end [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +start only [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +end only [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +double start error: TypeError: BenchContext::start() has already been invoked. + t.start(); + ^ + at BenchContext.start ([WILDCARD]) + at [WILDCARD]/explicit_start_and_end.ts:[WILDCARD] +double end error: TypeError: BenchContext::end() has already been invoked. + t.end(); + ^ + at BenchContext.end ([WILDCARD]) + at [WILDCARD]/explicit_start_and_end.ts:[WILDCARD] +captured error: TypeError: The benchmark which this context belongs to is not being executed. + captured!.start(); + ^ + at BenchContext.start ([WILDCARD]) + at [WILDCARD]/explicit_start_and_end.ts:[WILDCARD] +error: Bench failed diff --git a/tests/testdata/bench/explicit_start_and_end.ts b/tests/specs/bench/bench_explicit_start_end/explicit_start_and_end.ts similarity index 100% rename from tests/testdata/bench/explicit_start_and_end.ts rename to tests/specs/bench/bench_explicit_start_end/explicit_start_and_end.ts diff --git a/tests/specs/bench/bench_formatting/__test__.jsonc b/tests/specs/bench/bench_formatting/__test__.jsonc new file mode 100644 index 0000000000000..1f1d89394003f --- /dev/null +++ b/tests/specs/bench/bench_formatting/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench bench_formatting.ts", + "output": "bench_formatting.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/bench_formatting/bench_formatting.out b/tests/specs/bench/bench_formatting/bench_formatting.out new file mode 100644 index 0000000000000..79617a32df77e --- /dev/null +++ b/tests/specs/bench/bench_formatting/bench_formatting.out @@ -0,0 +1,8 @@ +Check [WILDCARD]/bench_formatting.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/bench_formatting.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +[WILDCARD] [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] \ No newline at end of file diff --git a/tests/testdata/bench/bench_formatting.ts b/tests/specs/bench/bench_formatting/bench_formatting.ts similarity index 100% rename from tests/testdata/bench/bench_formatting.ts rename to tests/specs/bench/bench_formatting/bench_formatting.ts diff --git a/tests/specs/bench/check_local_by_default/__test__.jsonc b/tests/specs/bench/check_local_by_default/__test__.jsonc new file mode 100644 index 0000000000000..76dd80b7bd767 --- /dev/null +++ b/tests/specs/bench/check_local_by_default/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "bench --quiet check_local_by_default.ts", + "output": "check_local_by_default.out" +} diff --git a/tests/specs/bench/check_local_by_default/check_local_by_default.out b/tests/specs/bench/check_local_by_default/check_local_by_default.out new file mode 100644 index 0000000000000..63a6b5fa55b41 --- /dev/null +++ b/tests/specs/bench/check_local_by_default/check_local_by_default.out @@ -0,0 +1,6 @@ +[WILDCARD] + +[WILDCARD]/check_local_by_default.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- + diff --git a/tests/testdata/bench/check_local_by_default.ts b/tests/specs/bench/check_local_by_default/check_local_by_default.ts similarity index 100% rename from tests/testdata/bench/check_local_by_default.ts rename to tests/specs/bench/check_local_by_default/check_local_by_default.ts diff --git a/tests/specs/bench/check_local_by_default2/__test__.jsonc b/tests/specs/bench/check_local_by_default2/__test__.jsonc new file mode 100644 index 0000000000000..5f2366d1e1c04 --- /dev/null +++ b/tests/specs/bench/check_local_by_default2/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench --quiet check_local_by_default2.ts", + "output": "check_local_by_default2.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/check_local_by_default2/check_local_by_default2.out b/tests/specs/bench/check_local_by_default2/check_local_by_default2.out new file mode 100644 index 0000000000000..089b17f4b8c98 --- /dev/null +++ b/tests/specs/bench/check_local_by_default2/check_local_by_default2.out @@ -0,0 +1,4 @@ +error: TS2322 [ERROR]: Type '12' is not assignable to type '"b"'. +const b: "b" = 12; + ^ + at [WILDCARD]/check_local_by_default2.ts:3:7 diff --git a/tests/testdata/bench/check_local_by_default2.ts b/tests/specs/bench/check_local_by_default2/check_local_by_default2.ts similarity index 100% rename from tests/testdata/bench/check_local_by_default2.ts rename to tests/specs/bench/check_local_by_default2/check_local_by_default2.ts diff --git a/tests/specs/bench/clear_timeout/__test__.jsonc b/tests/specs/bench/clear_timeout/__test__.jsonc new file mode 100644 index 0000000000000..4535c931d97dd --- /dev/null +++ b/tests/specs/bench/clear_timeout/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench clear_timeout.ts", + "output": "clear_timeout.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/clear_timeout/clear_timeout.out b/tests/specs/bench/clear_timeout/clear_timeout.out new file mode 100644 index 0000000000000..48a31378b78bc --- /dev/null +++ b/tests/specs/bench/clear_timeout/clear_timeout.out @@ -0,0 +1,10 @@ +Check [WILDCARD]/clear_timeout.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/clear_timeout.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +bench1 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/tests/testdata/bench/clear_timeout.ts b/tests/specs/bench/clear_timeout/clear_timeout.ts similarity index 100% rename from tests/testdata/bench/clear_timeout.ts rename to tests/specs/bench/clear_timeout/clear_timeout.ts diff --git a/tests/specs/bench/collect/__test__.jsonc b/tests/specs/bench/collect/__test__.jsonc new file mode 100644 index 0000000000000..e5aabd82d7860 --- /dev/null +++ b/tests/specs/bench/collect/__test__.jsonc @@ -0,0 +1,19 @@ +{ + "steps": [{ + "args": "bench --ignore=collect/ignore collect", + "output": "collect.out" + }, { + "cleanDenoDir": true, + "args": "bench --config collect/deno.jsonc collect", + "output": "collect.out" + }, { + "cleanDenoDir": true, + "args": "bench --config collect/deno2.jsonc collect", + "output": "collect2.out" + }, { + "cleanDenoDir": true, + "args": "bench --config collect/deno.malformed.jsonc", + "exitCode": 1, + "output": "collect_with_malformed_config.out" + }] +} diff --git a/tests/testdata/bench/collect.out b/tests/specs/bench/collect/collect.out similarity index 70% rename from tests/testdata/bench/collect.out rename to tests/specs/bench/collect/collect.out index 03c75922b75a4..0d3f7a8ffe4a1 100644 --- a/tests/testdata/bench/collect.out +++ b/tests/specs/bench/collect/collect.out @@ -1,18 +1,18 @@ -Check [WILDCARD]/bench/collect/bench.ts -Check [WILDCARD]/bench/collect/include/2_bench.ts -Check [WILDCARD]/bench/collect/include/bench.ts +Check [WILDCARD]/collect/bench.ts +Check [WILDCARD]/collect/include/2_bench.ts +Check [WILDCARD]/collect/include/bench.ts cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) -[WILDCARD]/bench/collect/bench.ts +[WILDCARD]/collect/bench.ts benchmark time (avg) iter/s (min … max) p75 p99 p995 --------------------------------------------------------------- ----------------------------- -[WILDCARD]/bench/collect/include/2_bench.ts +[WILDCARD]/collect/include/2_bench.ts benchmark time (avg) iter/s (min … max) p75 p99 p995 --------------------------------------------------------------- ----------------------------- -[WILDCARD]/bench/collect/include/bench.ts +[WILDCARD]/collect/include/bench.ts benchmark time (avg) iter/s (min … max) p75 p99 p995 --------------------------------------------------------------- ----------------------------- diff --git a/tests/testdata/bench/collect/bench.ts b/tests/specs/bench/collect/collect/bench.ts similarity index 100% rename from tests/testdata/bench/collect/bench.ts rename to tests/specs/bench/collect/collect/bench.ts diff --git a/tests/testdata/bench/collect/deno.jsonc b/tests/specs/bench/collect/collect/deno.jsonc similarity index 100% rename from tests/testdata/bench/collect/deno.jsonc rename to tests/specs/bench/collect/collect/deno.jsonc diff --git a/tests/testdata/bench/collect/deno.malformed.jsonc b/tests/specs/bench/collect/collect/deno.malformed.jsonc similarity index 100% rename from tests/testdata/bench/collect/deno.malformed.jsonc rename to tests/specs/bench/collect/collect/deno.malformed.jsonc diff --git a/tests/testdata/bench/collect/deno2.jsonc b/tests/specs/bench/collect/collect/deno2.jsonc similarity index 100% rename from tests/testdata/bench/collect/deno2.jsonc rename to tests/specs/bench/collect/collect/deno2.jsonc diff --git a/tests/testdata/bench/collect/ignore/bench.ts b/tests/specs/bench/collect/collect/ignore/bench.ts similarity index 100% rename from tests/testdata/bench/collect/ignore/bench.ts rename to tests/specs/bench/collect/collect/ignore/bench.ts diff --git a/tests/testdata/bench/collect/include/2_bench.ts b/tests/specs/bench/collect/collect/include/2_bench.ts similarity index 100% rename from tests/testdata/bench/collect/include/2_bench.ts rename to tests/specs/bench/collect/collect/include/2_bench.ts diff --git a/tests/testdata/bench/collect/include/bench.ts b/tests/specs/bench/collect/collect/include/bench.ts similarity index 100% rename from tests/testdata/bench/collect/include/bench.ts rename to tests/specs/bench/collect/collect/include/bench.ts diff --git a/tests/testdata/bench/collect2.out b/tests/specs/bench/collect/collect2.out similarity index 72% rename from tests/testdata/bench/collect2.out rename to tests/specs/bench/collect/collect2.out index 00b8bfc0d3500..49ceee996854a 100644 --- a/tests/testdata/bench/collect2.out +++ b/tests/specs/bench/collect/collect2.out @@ -1,13 +1,13 @@ -Check [WILDCARD]/bench/collect/bench.ts -Check [WILDCARD]/bench/collect/include/bench.ts +Check [WILDCARD]/collect/bench.ts +Check [WILDCARD]/collect/include/bench.ts cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) -[WILDCARD]/bench/collect/bench.ts +[WILDCARD]/collect/bench.ts benchmark time (avg) iter/s (min … max) p75 p99 p995 --------------------------------------------------------------- ----------------------------- -[WILDCARD]/bench/collect/include/bench.ts +[WILDCARD]/collect/include/bench.ts benchmark time (avg) iter/s (min … max) p75 p99 p995 --------------------------------------------------------------- ----------------------------- diff --git a/tests/testdata/bench/collect_with_malformed_config.out b/tests/specs/bench/collect/collect_with_malformed_config.out similarity index 100% rename from tests/testdata/bench/collect_with_malformed_config.out rename to tests/specs/bench/collect/collect_with_malformed_config.out diff --git a/tests/specs/bench/exit_sanitizer/__test__.jsonc b/tests/specs/bench/exit_sanitizer/__test__.jsonc new file mode 100644 index 0000000000000..a14531651778c --- /dev/null +++ b/tests/specs/bench/exit_sanitizer/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench exit_sanitizer.ts", + "output": "exit_sanitizer.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/exit_sanitizer/exit_sanitizer.out b/tests/specs/bench/exit_sanitizer/exit_sanitizer.out new file mode 100644 index 0000000000000..eefc86e607052 --- /dev/null +++ b/tests/specs/bench/exit_sanitizer/exit_sanitizer.out @@ -0,0 +1,14 @@ +Check [WILDCARD]/exit_sanitizer.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/exit_sanitizer.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +exit(0) error: Error: Bench attempted to exit with exit code: 0 +[WILDCARD] +exit(1) error: Error: Bench attempted to exit with exit code: 1 +[WILDCARD] +exit(2) error: Error: Bench attempted to exit with exit code: 2 +[WILDCARD] +error: Bench failed diff --git a/tests/testdata/bench/exit_sanitizer.ts b/tests/specs/bench/exit_sanitizer/exit_sanitizer.ts similarity index 100% rename from tests/testdata/bench/exit_sanitizer.ts rename to tests/specs/bench/exit_sanitizer/exit_sanitizer.ts diff --git a/tests/specs/bench/explicit_start_and_end_low_precision/__test__.jsonc b/tests/specs/bench/explicit_start_and_end_low_precision/__test__.jsonc new file mode 100644 index 0000000000000..2cd093f3fd6d2 --- /dev/null +++ b/tests/specs/bench/explicit_start_and_end_low_precision/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench --quiet -A main.bench.ts", + "output": "main.bench.out", + "flaky": true +} diff --git a/tests/testdata/bench/explicit_start_and_end_low_precision.out b/tests/specs/bench/explicit_start_and_end_low_precision/main.bench.out similarity index 91% rename from tests/testdata/bench/explicit_start_and_end_low_precision.out rename to tests/specs/bench/explicit_start_and_end_low_precision/main.bench.out index 6dc66cfcc30fc..516c001b1aaef 100644 --- a/tests/testdata/bench/explicit_start_and_end_low_precision.out +++ b/tests/specs/bench/explicit_start_and_end_low_precision/main.bench.out @@ -1,7 +1,7 @@ cpu: [WILDCARD] runtime: deno [WILDCARD] ([WILDCARD]) -[WILDCARD]/explicit_start_and_end_low_precision.ts +[WILDCARD]/main.bench.ts benchmark time (avg) iter/s (min … max) p75 p99 p995 ----------------------------------------------------------------------------- ----------------------------- noop with start and end [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/tests/testdata/bench/explicit_start_and_end_low_precision.ts b/tests/specs/bench/explicit_start_and_end_low_precision/main.bench.ts similarity index 100% rename from tests/testdata/bench/explicit_start_and_end_low_precision.ts rename to tests/specs/bench/explicit_start_and_end_low_precision/main.bench.ts diff --git a/tests/specs/bench/fail/__test__.jsonc b/tests/specs/bench/fail/__test__.jsonc new file mode 100644 index 0000000000000..18748c31e86e1 --- /dev/null +++ b/tests/specs/bench/fail/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench fail.ts", + "output": "fail.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/fail/fail.out b/tests/specs/bench/fail/fail.out new file mode 100644 index 0000000000000..03f04cf4fb4d0 --- /dev/null +++ b/tests/specs/bench/fail/fail.out @@ -0,0 +1,28 @@ +Check [WILDCARD]/fail.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/fail.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +bench0 error: Error +[WILDCARD] +bench1 error: Error +[WILDCARD] +bench2 error: Error +[WILDCARD] +bench3 error: Error +[WILDCARD] +bench4 error: Error +[WILDCARD] +bench5 error: Error +[WILDCARD] +bench6 error: Error +[WILDCARD] +bench7 error: Error +[WILDCARD] +bench8 error: Error +[WILDCARD] +bench9 error: Error +[WILDCARD] +error: Bench failed diff --git a/tests/testdata/bench/fail.ts b/tests/specs/bench/fail/fail.ts similarity index 100% rename from tests/testdata/bench/fail.ts rename to tests/specs/bench/fail/fail.ts diff --git a/tests/specs/bench/filter/__test__.jsonc b/tests/specs/bench/filter/__test__.jsonc new file mode 100644 index 0000000000000..685ee9571bca8 --- /dev/null +++ b/tests/specs/bench/filter/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "bench --filter=foo", + "output": "filter.out" +} diff --git a/tests/testdata/bench/filter/a_bench.ts b/tests/specs/bench/filter/a_bench.ts similarity index 100% rename from tests/testdata/bench/filter/a_bench.ts rename to tests/specs/bench/filter/a_bench.ts diff --git a/tests/testdata/bench/filter/b_bench.ts b/tests/specs/bench/filter/b_bench.ts similarity index 100% rename from tests/testdata/bench/filter/b_bench.ts rename to tests/specs/bench/filter/b_bench.ts diff --git a/tests/testdata/bench/filter/c_bench.ts b/tests/specs/bench/filter/c_bench.ts similarity index 100% rename from tests/testdata/bench/filter/c_bench.ts rename to tests/specs/bench/filter/c_bench.ts diff --git a/tests/testdata/bench/filter.out b/tests/specs/bench/filter/filter.out similarity index 100% rename from tests/testdata/bench/filter.out rename to tests/specs/bench/filter/filter.out diff --git a/tests/specs/bench/filter_group_header/main.out b/tests/specs/bench/filter_group_header/main.out index efe157f6cbbb7..5791538fe4efe 100644 --- a/tests/specs/bench/filter_group_header/main.out +++ b/tests/specs/bench/filter_group_header/main.out @@ -7,7 +7,7 @@ benchmark time (avg) iter/s (min … max) p75 --------------------------------------------------------------- ----------------------------- group G1 -G1-B [WILDCARD] +G1-B [WILDCARD] group G2 -G2-B [WILDCARD] \ No newline at end of file +G2-B [WILDCARD] \ No newline at end of file diff --git a/tests/specs/bench/finally_timeout/__test__.jsonc b/tests/specs/bench/finally_timeout/__test__.jsonc new file mode 100644 index 0000000000000..6215372046491 --- /dev/null +++ b/tests/specs/bench/finally_timeout/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench finally_timeout.ts", + "output": "finally_timeout.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/finally_timeout/finally_timeout.out b/tests/specs/bench/finally_timeout/finally_timeout.out new file mode 100644 index 0000000000000..cefa187600155 --- /dev/null +++ b/tests/specs/bench/finally_timeout/finally_timeout.out @@ -0,0 +1,11 @@ +Check [WILDCARD]/finally_timeout.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/finally_timeout.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +error error: Error: fail +[WILDCARD] +success [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +error: Bench failed diff --git a/tests/testdata/bench/finally_timeout.ts b/tests/specs/bench/finally_timeout/finally_timeout.ts similarity index 100% rename from tests/testdata/bench/finally_timeout.ts rename to tests/specs/bench/finally_timeout/finally_timeout.ts diff --git a/tests/specs/bench/group_baseline/__test__.jsonc b/tests/specs/bench/group_baseline/__test__.jsonc new file mode 100644 index 0000000000000..5874b40c8d12b --- /dev/null +++ b/tests/specs/bench/group_baseline/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench group_baseline.ts", + "output": "group_baseline.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/group_baseline/group_baseline.out b/tests/specs/bench/group_baseline/group_baseline.out new file mode 100644 index 0000000000000..54a6cd3591e39 --- /dev/null +++ b/tests/specs/bench/group_baseline/group_baseline.out @@ -0,0 +1,20 @@ +[WILDCARD]/group_baseline.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +-------------------------------------------------------------------- ----------------------------- +noop [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +noop2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] + +summary + noo[WILDCARD] + [WILDCARD]x [WILDCARD] than noo[WILDCARD] + +group url +noop3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +parse url 2x [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +parse url 200x [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] + +summary + parse url 2x + [WILDCARD]x slower than noop3 + [WILDCARD]x faster than parse url 200x + diff --git a/tests/testdata/bench/group_baseline.ts b/tests/specs/bench/group_baseline/group_baseline.ts similarity index 100% rename from tests/testdata/bench/group_baseline.ts rename to tests/specs/bench/group_baseline/group_baseline.ts diff --git a/tests/specs/bench/ignore/__test__.jsonc b/tests/specs/bench/ignore/__test__.jsonc new file mode 100644 index 0000000000000..97053bb798a4b --- /dev/null +++ b/tests/specs/bench/ignore/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench ignore.ts", + "output": "ignore.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/ignore/ignore.out b/tests/specs/bench/ignore/ignore.out new file mode 100644 index 0000000000000..d74a0c181c5ae --- /dev/null +++ b/tests/specs/bench/ignore/ignore.out @@ -0,0 +1,8 @@ +Check [WILDCARD]/ignore.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/ignore.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- + diff --git a/tests/testdata/bench/ignore.ts b/tests/specs/bench/ignore/ignore.ts similarity index 100% rename from tests/testdata/bench/ignore.ts rename to tests/specs/bench/ignore/ignore.ts diff --git a/tests/specs/bench/ignore_permissions/__test__.jsonc b/tests/specs/bench/ignore_permissions/__test__.jsonc new file mode 100644 index 0000000000000..592ab024089ae --- /dev/null +++ b/tests/specs/bench/ignore_permissions/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench ignore_permissions.ts", + "output": "ignore_permissions.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/ignore_permissions/ignore_permissions.out b/tests/specs/bench/ignore_permissions/ignore_permissions.out new file mode 100644 index 0000000000000..eb577fecc7b93 --- /dev/null +++ b/tests/specs/bench/ignore_permissions/ignore_permissions.out @@ -0,0 +1,8 @@ +Check [WILDCARD]/ignore_permissions.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/ignore_permissions.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- + diff --git a/tests/testdata/bench/ignore_permissions.ts b/tests/specs/bench/ignore_permissions/ignore_permissions.ts similarity index 100% rename from tests/testdata/bench/ignore_permissions.ts rename to tests/specs/bench/ignore_permissions/ignore_permissions.ts diff --git a/tests/specs/bench/interval/__test__.jsonc b/tests/specs/bench/interval/__test__.jsonc new file mode 100644 index 0000000000000..f4e89c1b5d7f0 --- /dev/null +++ b/tests/specs/bench/interval/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench interval.ts", + "output": "interval.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/interval/interval.out b/tests/specs/bench/interval/interval.out new file mode 100644 index 0000000000000..11e440940a20b --- /dev/null +++ b/tests/specs/bench/interval/interval.out @@ -0,0 +1,8 @@ +Check [WILDCARD]/interval.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/interval.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- + diff --git a/tests/testdata/bench/interval.ts b/tests/specs/bench/interval/interval.ts similarity index 100% rename from tests/testdata/bench/interval.ts rename to tests/specs/bench/interval/interval.ts diff --git a/tests/specs/bench/json_output/__test__.jsonc b/tests/specs/bench/json_output/__test__.jsonc new file mode 100644 index 0000000000000..fa0dadcd0b7ed --- /dev/null +++ b/tests/specs/bench/json_output/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench --json pass.ts", + "output": "pass.json.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/json_output/pass.json.out b/tests/specs/bench/json_output/pass.json.out new file mode 100644 index 0000000000000..53259e758571d --- /dev/null +++ b/tests/specs/bench/json_output/pass.json.out @@ -0,0 +1,28 @@ +Check file:///[WILDCARD]/pass.ts +{ + "runtime": "Deno/[WILDCARD]", + "cpu": "[WILDCARD]", + "benches": [ + { + "origin": "file:///[WILDCARD]/pass.ts", + "group": null, + "name": "bench0", + "baseline": false, + "results": [ + { + "ok": { + "n": [WILDCARD], + "min": [WILDCARD], + "max": [WILDCARD], + "avg": [WILDCARD], + "p75": [WILDCARD], + "p99": [WILDCARD], + "p995": [WILDCARD], + "p999": [WILDCARD] + } + } + ] + }, +[WILDCARD] + ] +} diff --git a/tests/testdata/bench/pass.ts b/tests/specs/bench/json_output/pass.ts similarity index 100% rename from tests/testdata/bench/pass.ts rename to tests/specs/bench/json_output/pass.ts diff --git a/tests/specs/bench/load_unload/__test__.jsonc b/tests/specs/bench/load_unload/__test__.jsonc new file mode 100644 index 0000000000000..8837d3d80470f --- /dev/null +++ b/tests/specs/bench/load_unload/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench load_unload.ts", + "output": "load_unload.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/load_unload/load_unload.out b/tests/specs/bench/load_unload/load_unload.out new file mode 100644 index 0000000000000..99e4389ac89e8 --- /dev/null +++ b/tests/specs/bench/load_unload/load_unload.out @@ -0,0 +1,8 @@ +Check [WILDCARD]/load_unload.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/load_unload.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +bench [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/tests/testdata/bench/load_unload.ts b/tests/specs/bench/load_unload/load_unload.ts similarity index 100% rename from tests/testdata/bench/load_unload.ts rename to tests/specs/bench/load_unload/load_unload.ts diff --git a/tests/specs/bench/meta/__test__.jsonc b/tests/specs/bench/meta/__test__.jsonc new file mode 100644 index 0000000000000..10a4ff3a42f60 --- /dev/null +++ b/tests/specs/bench/meta/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench meta.ts", + "output": "meta.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/meta/meta.out b/tests/specs/bench/meta/meta.out new file mode 100644 index 0000000000000..75a75984efadf --- /dev/null +++ b/tests/specs/bench/meta/meta.out @@ -0,0 +1,10 @@ +Check [WILDCARD]/meta.ts +import.meta.main: false +import.meta.url: [WILDCARD]/meta.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/meta.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- + diff --git a/tests/testdata/bench/meta.ts b/tests/specs/bench/meta/meta.ts similarity index 100% rename from tests/testdata/bench/meta.ts rename to tests/specs/bench/meta/meta.ts diff --git a/tests/specs/bench/multifile_summary/__test__.jsonc b/tests/specs/bench/multifile_summary/__test__.jsonc new file mode 100644 index 0000000000000..757af150be9da --- /dev/null +++ b/tests/specs/bench/multifile_summary/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench group_baseline.ts pass.ts multiple_group.ts", + "output": "multifile_summary.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/multifile_summary/group_baseline.ts b/tests/specs/bench/multifile_summary/group_baseline.ts new file mode 100644 index 0000000000000..a86f6455ca81b --- /dev/null +++ b/tests/specs/bench/multifile_summary/group_baseline.ts @@ -0,0 +1,15 @@ +Deno.bench("noop", () => {}); +Deno.bench("noop2", { baseline: true }, () => {}); + +Deno.bench("noop3", { group: "url" }, () => {}); + +Deno.bench("parse url 2x", { group: "url", baseline: true }, () => { + new URL("https://deno.land/std/http/server.ts"); + new URL("https://deno.land/std/http/server.ts"); +}); + +Deno.bench("parse url 200x", { group: "url" }, () => { + for (let i = 0; i < 200; i++) { + new URL("https://deno.land/std/http/server.ts"); + } +}); diff --git a/tests/specs/bench/multifile_summary/multifile_summary.out b/tests/specs/bench/multifile_summary/multifile_summary.out new file mode 100644 index 0000000000000..c0439ebba86ef --- /dev/null +++ b/tests/specs/bench/multifile_summary/multifile_summary.out @@ -0,0 +1,64 @@ +Check [WILDCARD]/group_baseline.ts +Check [WILDCARD]/pass.ts +Check [WILDCARD]/multiple_group.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/group_baseline.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +-------------------------------------------------------------------- ----------------------------- +noop [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +noop2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] + +summary + noo[WILDCARD] + [WILDCARD]x [WILDCARD] than noo[WILDCARD] + +group url +noop3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +parse url 2x [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +parse url 200x [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] + +summary + parse url 2x + [WILDLINE]x slower than noop3 + [WILDLINE]x faster than parse url 200x + + +[WILDLINE]/pass.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +bench0 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench1 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench4 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench5 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench6 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench7 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench8 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench9 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] + + +[WILDLINE]/multiple_group.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +-------------------------------------------------------------------- ----------------------------- + +group noop +noop [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +noop2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] + +summary + noo[WILDCARD] + [WILDCARD]x [WILDCARD] than noo[WILDCARD] + +group url +noop3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +parse url 2x [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +parse url 200x [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] + +summary + parse url 2x + [WILDCARD]x slower than noop3 + [WILDCARD]x faster than parse url 200x + diff --git a/tests/testdata/bench/multiple_group.ts b/tests/specs/bench/multifile_summary/multiple_group.ts similarity index 100% rename from tests/testdata/bench/multiple_group.ts rename to tests/specs/bench/multifile_summary/multiple_group.ts diff --git a/tests/specs/bench/multifile_summary/pass.ts b/tests/specs/bench/multifile_summary/pass.ts new file mode 100644 index 0000000000000..48348d44763a4 --- /dev/null +++ b/tests/specs/bench/multifile_summary/pass.ts @@ -0,0 +1,10 @@ +Deno.bench("bench0", () => {}); +Deno.bench("bench1", () => {}); +Deno.bench("bench2", () => {}); +Deno.bench("bench3", () => {}); +Deno.bench("bench4", () => {}); +Deno.bench("bench5", () => {}); +Deno.bench("bench6", () => {}); +Deno.bench("bench7", () => {}); +Deno.bench("bench8", () => {}); +Deno.bench("bench9", () => {}); diff --git a/tests/specs/bench/no_check/__test__.jsonc b/tests/specs/bench/no_check/__test__.jsonc new file mode 100644 index 0000000000000..d031e52defe50 --- /dev/null +++ b/tests/specs/bench/no_check/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench --no-check no_check.ts", + "output": "no_check.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/no_check/no_check.out b/tests/specs/bench/no_check/no_check.out new file mode 100644 index 0000000000000..c373c812c439f --- /dev/null +++ b/tests/specs/bench/no_check/no_check.out @@ -0,0 +1,9 @@ +error: (in promise) TypeError: Cannot read properties of undefined (reading 'fn') +Deno.bench(); + ^ + at [WILDCARD] + at [WILDCARD]/no_check.ts:1:6 +This error was not caught from a benchmark and caused the bench runner to fail on the referenced module. +It most likely originated from a dangling promise, event/timeout handler or top-level code. + +error: Bench failed diff --git a/tests/testdata/bench/no_check.ts b/tests/specs/bench/no_check/no_check.ts similarity index 100% rename from tests/testdata/bench/no_check.ts rename to tests/specs/bench/no_check/no_check.ts diff --git a/tests/specs/bench/no_prompt_by_default/__test__.jsonc b/tests/specs/bench/no_prompt_by_default/__test__.jsonc new file mode 100644 index 0000000000000..e3f4127da9802 --- /dev/null +++ b/tests/specs/bench/no_prompt_by_default/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench --quiet no_prompt_by_default.ts", + "output": "no_prompt_by_default.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/no_prompt_by_default/no_prompt_by_default.out b/tests/specs/bench/no_prompt_by_default/no_prompt_by_default.out new file mode 100644 index 0000000000000..7c5f2b5c2e194 --- /dev/null +++ b/tests/specs/bench/no_prompt_by_default/no_prompt_by_default.out @@ -0,0 +1,9 @@ +[WILDCARD]cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/no_prompt_by_default.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +no prompt error: PermissionDenied: Requires read access to "./some_file.txt", run again with the --allow-read flag +[WILDCARD] +error: Bench failed diff --git a/tests/testdata/bench/no_prompt_by_default.ts b/tests/specs/bench/no_prompt_by_default/no_prompt_by_default.ts similarity index 100% rename from tests/testdata/bench/no_prompt_by_default.ts rename to tests/specs/bench/no_prompt_by_default/no_prompt_by_default.ts diff --git a/tests/specs/bench/no_prompt_with_denied_perms/__test__.jsonc b/tests/specs/bench/no_prompt_with_denied_perms/__test__.jsonc new file mode 100644 index 0000000000000..a06645249a4e7 --- /dev/null +++ b/tests/specs/bench/no_prompt_with_denied_perms/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench --quiet --allow-read no_prompt_with_denied_perms.ts", + "output": "no_prompt_with_denied_perms.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/no_prompt_with_denied_perms/no_prompt_with_denied_perms.out b/tests/specs/bench/no_prompt_with_denied_perms/no_prompt_with_denied_perms.out new file mode 100644 index 0000000000000..bbdd2ac462490 --- /dev/null +++ b/tests/specs/bench/no_prompt_with_denied_perms/no_prompt_with_denied_perms.out @@ -0,0 +1,9 @@ +[WILDCARD]cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/no_prompt_with_denied_perms.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +no prompt error: PermissionDenied: Requires read access to "./some_file.txt", run again with the --allow-read flag +[WILDCARD] +error: Bench failed diff --git a/tests/testdata/bench/no_prompt_with_denied_perms.ts b/tests/specs/bench/no_prompt_with_denied_perms/no_prompt_with_denied_perms.ts similarity index 100% rename from tests/testdata/bench/no_prompt_with_denied_perms.ts rename to tests/specs/bench/no_prompt_with_denied_perms/no_prompt_with_denied_perms.ts diff --git a/tests/specs/bench/no_run/__test__.jsonc b/tests/specs/bench/no_run/__test__.jsonc new file mode 100644 index 0000000000000..159f6fd5a0085 --- /dev/null +++ b/tests/specs/bench/no_run/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench --no-run no_run.ts", + "output": "no_run.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/no_run/no_run.out b/tests/specs/bench/no_run/no_run.out new file mode 100644 index 0000000000000..77ce18366af15 --- /dev/null +++ b/tests/specs/bench/no_run/no_run.out @@ -0,0 +1,5 @@ +Check [WILDCARD]/no_run.ts +error: TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. +const _value: string = 1; + ~~~~~~ + at [WILDCARD]/no_run.ts:1:7 diff --git a/tests/testdata/bench/no_run.ts b/tests/specs/bench/no_run/no_run.ts similarity index 100% rename from tests/testdata/bench/no_run.ts rename to tests/specs/bench/no_run/no_run.ts diff --git a/tests/specs/bench/only/__test__.jsonc b/tests/specs/bench/only/__test__.jsonc new file mode 100644 index 0000000000000..7d50a6dec2ac0 --- /dev/null +++ b/tests/specs/bench/only/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench only.ts", + "output": "only.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/only/only.out b/tests/specs/bench/only/only.out new file mode 100644 index 0000000000000..e3332d174afb4 --- /dev/null +++ b/tests/specs/bench/only/only.out @@ -0,0 +1,9 @@ +Check [WILDCARD]/only.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/only.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +only [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +error: Bench failed because the "only" option was used diff --git a/tests/testdata/bench/only.ts b/tests/specs/bench/only/only.ts similarity index 100% rename from tests/testdata/bench/only.ts rename to tests/specs/bench/only/only.ts diff --git a/tests/specs/bench/overloads/__test__.jsonc b/tests/specs/bench/overloads/__test__.jsonc new file mode 100644 index 0000000000000..ae0fe0a07a402 --- /dev/null +++ b/tests/specs/bench/overloads/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench overloads.ts", + "output": "overloads.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/overloads/overloads.out b/tests/specs/bench/overloads/overloads.out new file mode 100644 index 0000000000000..21f8759dd53dd --- /dev/null +++ b/tests/specs/bench/overloads/overloads.out @@ -0,0 +1,12 @@ +Check [WILDCARD]/overloads.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/overloads.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +bench0 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench1 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench4 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/tests/testdata/bench/overloads.ts b/tests/specs/bench/overloads/overloads.ts similarity index 100% rename from tests/testdata/bench/overloads.ts rename to tests/specs/bench/overloads/overloads.ts diff --git a/tests/specs/bench/package_json/__test__.jsonc b/tests/specs/bench/package_json/__test__.jsonc new file mode 100644 index 0000000000000..001cc8b54ea36 --- /dev/null +++ b/tests/specs/bench/package_json/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "tempDir": true, + "args": "bench", + "output": "lib.bench.out" +} diff --git a/tests/testdata/package_json/basic/lib.bench.out b/tests/specs/bench/package_json/lib.bench.out similarity index 100% rename from tests/testdata/package_json/basic/lib.bench.out rename to tests/specs/bench/package_json/lib.bench.out diff --git a/tests/testdata/package_json/basic/lib.bench.ts b/tests/specs/bench/package_json/lib.bench.ts similarity index 100% rename from tests/testdata/package_json/basic/lib.bench.ts rename to tests/specs/bench/package_json/lib.bench.ts diff --git a/tests/specs/bench/package_json/lib.ts b/tests/specs/bench/package_json/lib.ts new file mode 100644 index 0000000000000..1deed81f7ec1e --- /dev/null +++ b/tests/specs/bench/package_json/lib.ts @@ -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(); +} diff --git a/tests/specs/bench/package_json/package.json b/tests/specs/bench/package_json/package.json new file mode 100644 index 0000000000000..54ca824d645c5 --- /dev/null +++ b/tests/specs/bench/package_json/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@denotest/esm-basic": "*" + } +} diff --git a/tests/specs/bench/pass/__test__.jsonc b/tests/specs/bench/pass/__test__.jsonc new file mode 100644 index 0000000000000..797684ec6232f --- /dev/null +++ b/tests/specs/bench/pass/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench pass.ts", + "output": "pass.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/pass/pass.out b/tests/specs/bench/pass/pass.out new file mode 100644 index 0000000000000..4be2b872345b7 --- /dev/null +++ b/tests/specs/bench/pass/pass.out @@ -0,0 +1,17 @@ +Check [WILDCARD]/pass.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/pass.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +bench0 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench1 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench4 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench5 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench6 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench7 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench8 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench9 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/tests/specs/bench/pass/pass.ts b/tests/specs/bench/pass/pass.ts new file mode 100644 index 0000000000000..48348d44763a4 --- /dev/null +++ b/tests/specs/bench/pass/pass.ts @@ -0,0 +1,10 @@ +Deno.bench("bench0", () => {}); +Deno.bench("bench1", () => {}); +Deno.bench("bench2", () => {}); +Deno.bench("bench3", () => {}); +Deno.bench("bench4", () => {}); +Deno.bench("bench5", () => {}); +Deno.bench("bench6", () => {}); +Deno.bench("bench7", () => {}); +Deno.bench("bench8", () => {}); +Deno.bench("bench9", () => {}); diff --git a/tests/specs/bench/quiet/__test__.jsonc b/tests/specs/bench/quiet/__test__.jsonc new file mode 100644 index 0000000000000..a220e9936f16a --- /dev/null +++ b/tests/specs/bench/quiet/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench --quiet quiet.ts", + "output": "quiet.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/quiet/quiet.out b/tests/specs/bench/quiet/quiet.out new file mode 100644 index 0000000000000..fa9166d65be53 --- /dev/null +++ b/tests/specs/bench/quiet/quiet.out @@ -0,0 +1,10 @@ +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/quiet.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +------------------------------------------------------------------- ----------------------------- +console.log [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +console.error [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +console.info [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +console.warn [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/tests/testdata/bench/quiet.ts b/tests/specs/bench/quiet/quiet.ts similarity index 100% rename from tests/testdata/bench/quiet.ts rename to tests/specs/bench/quiet/quiet.ts diff --git a/tests/specs/bench/unhandled_rejection/__test__.jsonc b/tests/specs/bench/unhandled_rejection/__test__.jsonc new file mode 100644 index 0000000000000..0576136ef779c --- /dev/null +++ b/tests/specs/bench/unhandled_rejection/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench unhandled_rejection.ts", + "output": "unhandled_rejection.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/unhandled_rejection/unhandled_rejection.out b/tests/specs/bench/unhandled_rejection/unhandled_rejection.out new file mode 100644 index 0000000000000..b95b9ab8be20c --- /dev/null +++ b/tests/specs/bench/unhandled_rejection/unhandled_rejection.out @@ -0,0 +1,11 @@ +Check [WILDCARD]/unhandled_rejection.ts +error: (in promise) Error: rejection + reject(new Error("rejection")); + ^ + at [WILDCARD]/unhandled_rejection.ts:2:10 + at new Promise () + at [WILDCARD]/unhandled_rejection.ts:1:1 +This error was not caught from a benchmark and caused the bench runner to fail on the referenced module. +It most likely originated from a dangling promise, event/timeout handler or top-level code. + +error: Bench failed diff --git a/tests/testdata/bench/unhandled_rejection.ts b/tests/specs/bench/unhandled_rejection/unhandled_rejection.ts similarity index 100% rename from tests/testdata/bench/unhandled_rejection.ts rename to tests/specs/bench/unhandled_rejection/unhandled_rejection.ts diff --git a/tests/specs/bench/unresolved_promise/__test__.jsonc b/tests/specs/bench/unresolved_promise/__test__.jsonc new file mode 100644 index 0000000000000..487e46b3d7695 --- /dev/null +++ b/tests/specs/bench/unresolved_promise/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench unresolved_promise.ts", + "output": "unresolved_promise.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/unresolved_promise/unresolved_promise.out b/tests/specs/bench/unresolved_promise/unresolved_promise.out new file mode 100644 index 0000000000000..92d29f399b92b --- /dev/null +++ b/tests/specs/bench/unresolved_promise/unresolved_promise.out @@ -0,0 +1,9 @@ +Check [WILDCARD]/unresolved_promise.ts +error: Top-level await promise never resolved +await new Promise((_resolve, _reject) => {}); +^ + at ([WILDCARD]/unresolved_promise.ts:1:1) +This error was not caught from a benchmark and caused the bench runner to fail on the referenced module. +It most likely originated from a dangling promise, event/timeout handler or top-level code. + +error: Bench failed diff --git a/tests/testdata/bench/unresolved_promise.ts b/tests/specs/bench/unresolved_promise/unresolved_promise.ts similarity index 100% rename from tests/testdata/bench/unresolved_promise.ts rename to tests/specs/bench/unresolved_promise/unresolved_promise.ts diff --git a/tests/specs/cache/check_local_by_default/__test__.jsonc b/tests/specs/cache/check_local_by_default/__test__.jsonc new file mode 100644 index 0000000000000..e6d0829fd5483 --- /dev/null +++ b/tests/specs/cache/check_local_by_default/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "cache --quiet check_local_by_default.ts", + "output": "check_local_by_default.out" +} diff --git a/tests/testdata/publish/invalid_path/path with spaces.txt b/tests/specs/cache/check_local_by_default/check_local_by_default.out similarity index 100% rename from tests/testdata/publish/invalid_path/path with spaces.txt rename to tests/specs/cache/check_local_by_default/check_local_by_default.out diff --git a/tests/testdata/cache/check_local_by_default.ts b/tests/specs/cache/check_local_by_default/check_local_by_default.ts similarity index 100% rename from tests/testdata/cache/check_local_by_default.ts rename to tests/specs/cache/check_local_by_default/check_local_by_default.ts diff --git a/tests/specs/cache/check_local_by_default2/__test__.jsonc b/tests/specs/cache/check_local_by_default2/__test__.jsonc new file mode 100644 index 0000000000000..a9e70dcd94146 --- /dev/null +++ b/tests/specs/cache/check_local_by_default2/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "cache --quiet check_local_by_default2.ts", + "output": "check_local_by_default2.out" +} diff --git a/tests/specs/cache/check_local_by_default2/check_local_by_default2.out b/tests/specs/cache/check_local_by_default2/check_local_by_default2.out new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/tests/testdata/cache/check_local_by_default2.ts b/tests/specs/cache/check_local_by_default2/check_local_by_default2.ts similarity index 100% rename from tests/testdata/cache/check_local_by_default2.ts rename to tests/specs/cache/check_local_by_default2/check_local_by_default2.ts diff --git a/tests/specs/cache/extensionless/__test__.jsonc b/tests/specs/cache/extensionless/__test__.jsonc new file mode 100644 index 0000000000000..837f26ecccd04 --- /dev/null +++ b/tests/specs/cache/extensionless/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "cache --reload --check=all http://localhost:4545/subdir/no_js_ext", + "output": "cache_extensionless.out" +} diff --git a/tests/testdata/cache/cache_extensionless.out b/tests/specs/cache/extensionless/cache_extensionless.out similarity index 100% rename from tests/testdata/cache/cache_extensionless.out rename to tests/specs/cache/extensionless/cache_extensionless.out diff --git a/tests/specs/cache/fetch_multiple/__test__.jsonc b/tests/specs/cache/fetch_multiple/__test__.jsonc new file mode 100644 index 0000000000000..a5cf41113111d --- /dev/null +++ b/tests/specs/cache/fetch_multiple/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "cache --reload --check=all test.ts other.ts", + "output": "fetch_multiple.out" +} diff --git a/tests/specs/cache/fetch_multiple/fetch_multiple.out b/tests/specs/cache/fetch_multiple/fetch_multiple.out new file mode 100644 index 0000000000000..1cd3639ecfd74 --- /dev/null +++ b/tests/specs/cache/fetch_multiple/fetch_multiple.out @@ -0,0 +1,5 @@ +Download http://localhost:4545/subdir/mod2.ts +Download http://localhost:4545/subdir/mt_text_typescript.t1.ts +Download http://localhost:4545/subdir/print_hello.ts +Check [WILDCARD]/fetch_multiple/test.ts +Check [WILDCARD]/fetch_multiple/other.ts diff --git a/tests/testdata/run/fetch/other.ts b/tests/specs/cache/fetch_multiple/other.ts similarity index 100% rename from tests/testdata/run/fetch/other.ts rename to tests/specs/cache/fetch_multiple/other.ts diff --git a/tests/testdata/run/fetch/test.ts b/tests/specs/cache/fetch_multiple/test.ts similarity index 100% rename from tests/testdata/run/fetch/test.ts rename to tests/specs/cache/fetch_multiple/test.ts diff --git a/tests/specs/cache/ignore_require/__test__.jsonc b/tests/specs/cache/ignore_require/__test__.jsonc new file mode 100644 index 0000000000000..e6d0093c7eb9b --- /dev/null +++ b/tests/specs/cache/ignore_require/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "cache --reload --no-check ignore_require.js", + "output": "" +} diff --git a/tests/testdata/cache/ignore_require.js b/tests/specs/cache/ignore_require/ignore_require.js similarity index 100% rename from tests/testdata/cache/ignore_require.js rename to tests/specs/cache/ignore_require/ignore_require.js diff --git a/tests/specs/cache/json_import/__test__.jsonc b/tests/specs/cache/json_import/__test__.jsonc new file mode 100644 index 0000000000000..fdc3459c3f508 --- /dev/null +++ b/tests/specs/cache/json_import/__test__.jsonc @@ -0,0 +1,5 @@ +{ + // should not error + "args": "cache --quiet main.ts", + "output": "[WILDCARD]" +} diff --git a/tests/testdata/cache/json_import/main.ts b/tests/specs/cache/json_import/main.ts similarity index 100% rename from tests/testdata/cache/json_import/main.ts rename to tests/specs/cache/json_import/main.ts diff --git a/tests/testdata/cache/json_import/test.json b/tests/specs/cache/json_import/test.json similarity index 100% rename from tests/testdata/cache/json_import/test.json rename to tests/specs/cache/json_import/test.json diff --git a/tests/specs/cache/package_json/__test__.jsonc b/tests/specs/cache/package_json/__test__.jsonc new file mode 100644 index 0000000000000..b25ac147d6ee6 --- /dev/null +++ b/tests/specs/cache/package_json/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "tempDir": true, + "args": "cache main.ts", + "output": "main.cache.out" +} diff --git a/tests/specs/cache/package_json/lib.ts b/tests/specs/cache/package_json/lib.ts new file mode 100644 index 0000000000000..1deed81f7ec1e --- /dev/null +++ b/tests/specs/cache/package_json/lib.ts @@ -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(); +} diff --git a/tests/testdata/package_json/basic/main.cache.out b/tests/specs/cache/package_json/main.cache.out similarity index 100% rename from tests/testdata/package_json/basic/main.cache.out rename to tests/specs/cache/package_json/main.cache.out diff --git a/tests/specs/cache/package_json/main.ts b/tests/specs/cache/package_json/main.ts new file mode 100644 index 0000000000000..e241f30026d91 --- /dev/null +++ b/tests/specs/cache/package_json/main.ts @@ -0,0 +1,3 @@ +import { getValue } from "./lib.ts"; + +console.log(getValue()); diff --git a/tests/specs/cache/package_json/package.json b/tests/specs/cache/package_json/package.json new file mode 100644 index 0000000000000..54ca824d645c5 --- /dev/null +++ b/tests/specs/cache/package_json/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@denotest/esm-basic": "*" + } +} diff --git a/tests/specs/cache/performance_stats/__test__.jsonc b/tests/specs/cache/performance_stats/__test__.jsonc new file mode 100644 index 0000000000000..f4d37b8036bed --- /dev/null +++ b/tests/specs/cache/performance_stats/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "cache --reload --check=all --log-level debug hello.ts", + "output": "performance_stats.out" +} diff --git a/tests/specs/cache/performance_stats/hello.ts b/tests/specs/cache/performance_stats/hello.ts new file mode 100644 index 0000000000000..accefceba62b4 --- /dev/null +++ b/tests/specs/cache/performance_stats/hello.ts @@ -0,0 +1 @@ +console.log("Hello World"); diff --git a/tests/specs/cache/performance_stats/performance_stats.out b/tests/specs/cache/performance_stats/performance_stats.out new file mode 100644 index 0000000000000..141829ee6c752 --- /dev/null +++ b/tests/specs/cache/performance_stats/performance_stats.out @@ -0,0 +1,16 @@ +[WILDCARD] +DEBUG RS - [WILDCARD] - Compilation statistics: + Files: [WILDCARD] + Nodes: [WILDCARD] + Identifiers: [WILDCARD] + Symbols: [WILDCARD] + Types: [WILDCARD] + Instantiations: [WILDCARD] + Parse time: [WILDCARD] + Bind time: [WILDCARD] + Check time: [WILDCARD] + Emit time: [WILDCARD] + Total TS time: [WILDCARD] + Compile time: [WILDCARD] + +[WILDCARD] diff --git a/tests/specs/cache/random_extension/__test__.jsonc b/tests/specs/cache/random_extension/__test__.jsonc new file mode 100644 index 0000000000000..7b847a77d9803 --- /dev/null +++ b/tests/specs/cache/random_extension/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "cache --reload --check=all http://localhost:4545/subdir/no_js_ext@1.0.0", + "output": "cache_random_extension.out" +} diff --git a/tests/testdata/cache/cache_random_extension.out b/tests/specs/cache/random_extension/cache_random_extension.out similarity index 100% rename from tests/testdata/cache/cache_random_extension.out rename to tests/specs/cache/random_extension/cache_random_extension.out diff --git a/tests/specs/cache/redirect/__test__.jsonc b/tests/specs/cache/redirect/__test__.jsonc new file mode 100644 index 0000000000000..251bc61749626 --- /dev/null +++ b/tests/specs/cache/redirect/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "cache --reload --check=all http://localhost:4548/subdir/redirects/a.ts", + "output": "redirect_cache.out" +} diff --git a/tests/testdata/cache/redirect_cache.out b/tests/specs/cache/redirect/redirect_cache.out similarity index 100% rename from tests/testdata/cache/redirect_cache.out rename to tests/specs/cache/redirect/redirect_cache.out diff --git a/tests/testdata/cache/095_cache_with_bare_import.ts b/tests/specs/cache/with_bare_import/095_cache_with_bare_import.ts similarity index 100% rename from tests/testdata/cache/095_cache_with_bare_import.ts rename to tests/specs/cache/with_bare_import/095_cache_with_bare_import.ts diff --git a/tests/specs/cache/with_bare_import/095_cache_with_bare_import.ts.out b/tests/specs/cache/with_bare_import/095_cache_with_bare_import.ts.out new file mode 100644 index 0000000000000..2668a6e08368f --- /dev/null +++ b/tests/specs/cache/with_bare_import/095_cache_with_bare_import.ts.out @@ -0,0 +1,2 @@ +[WILDCARD]error: Relative import path "foo" not prefixed with / or ./ or ../ + at file:///[WILDCARD]/095_cache_with_bare_import.ts:[WILDCARD] diff --git a/tests/specs/cache/with_bare_import/__test__.jsonc b/tests/specs/cache/with_bare_import/__test__.jsonc new file mode 100644 index 0000000000000..0ff2d09cb72cb --- /dev/null +++ b/tests/specs/cache/with_bare_import/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "cache 095_cache_with_bare_import.ts", + "output": "095_cache_with_bare_import.ts.out", + "exitCode": 1 +} diff --git a/tests/specs/check/check_types_dts/__test__.jsonc b/tests/specs/check/check_types_dts/__test__.jsonc new file mode 100644 index 0000000000000..7f620daa27a21 --- /dev/null +++ b/tests/specs/check/check_types_dts/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "check main.ts", + "output": "main.out", + "exitCode": 0 +} diff --git a/tests/testdata/check/types_dts/deno.json b/tests/specs/check/check_types_dts/deno.json similarity index 100% rename from tests/testdata/check/types_dts/deno.json rename to tests/specs/check/check_types_dts/deno.json diff --git a/tests/specs/check/check_types_dts/main.out b/tests/specs/check/check_types_dts/main.out new file mode 100644 index 0000000000000..b8fb00c4fa6ab --- /dev/null +++ b/tests/specs/check/check_types_dts/main.out @@ -0,0 +1 @@ +Check file:///[WILDCARD]/main.ts diff --git a/tests/testdata/check/types_dts/main.ts b/tests/specs/check/check_types_dts/main.ts similarity index 100% rename from tests/testdata/check/types_dts/main.ts rename to tests/specs/check/check_types_dts/main.ts diff --git a/tests/testdata/check/types_dts/types.d.ts b/tests/specs/check/check_types_dts/types.d.ts similarity index 100% rename from tests/testdata/check/types_dts/types.d.ts rename to tests/specs/check/check_types_dts/types.d.ts diff --git a/tests/specs/check/check_with_excluded_file_specified/__test__.jsonc b/tests/specs/check/check_with_excluded_file_specified/__test__.jsonc new file mode 100644 index 0000000000000..212ab8fb3a285 --- /dev/null +++ b/tests/specs/check/check_with_excluded_file_specified/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "check lib/types.d.ts", + "output": "check.out" +} diff --git a/tests/testdata/check/excluded_file_specified/check.out b/tests/specs/check/check_with_excluded_file_specified/check.out similarity index 100% rename from tests/testdata/check/excluded_file_specified/check.out rename to tests/specs/check/check_with_excluded_file_specified/check.out diff --git a/tests/testdata/check/excluded_file_specified/deno.json b/tests/specs/check/check_with_excluded_file_specified/deno.json similarity index 100% rename from tests/testdata/check/excluded_file_specified/deno.json rename to tests/specs/check/check_with_excluded_file_specified/deno.json diff --git a/tests/testdata/check/excluded_file_specified/lib/types.d.ts b/tests/specs/check/check_with_excluded_file_specified/lib/types.d.ts similarity index 100% rename from tests/testdata/check/excluded_file_specified/lib/types.d.ts rename to tests/specs/check/check_with_excluded_file_specified/lib/types.d.ts diff --git a/tests/specs/check/extensionless/__test__.jsonc b/tests/specs/check/extensionless/__test__.jsonc new file mode 100644 index 0000000000000..670680b7d9294 --- /dev/null +++ b/tests/specs/check/extensionless/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "check --reload --all http://localhost:4545/subdir/no_js_ext", + "output": "check.out" +} diff --git a/tests/specs/check/extensionless/check.out b/tests/specs/check/extensionless/check.out new file mode 100644 index 0000000000000..3694c67cb7beb --- /dev/null +++ b/tests/specs/check/extensionless/check.out @@ -0,0 +1,2 @@ +[WILDCARD] +Check http://localhost:4545/subdir/no_js_ext diff --git a/tests/specs/check/random_extension/__test__.jsonc b/tests/specs/check/random_extension/__test__.jsonc new file mode 100644 index 0000000000000..f504c1d2b48d1 --- /dev/null +++ b/tests/specs/check/random_extension/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "check --reload --all http://localhost:4545/subdir/no_js_ext@1.0.0", + "output": "output.out" +} diff --git a/tests/specs/check/random_extension/output.out b/tests/specs/check/random_extension/output.out new file mode 100644 index 0000000000000..745a2e0e31dda --- /dev/null +++ b/tests/specs/check/random_extension/output.out @@ -0,0 +1,2 @@ +[WILDCARD] +Check http://localhost:4545/subdir/no_js_ext@1.0.0 diff --git a/tests/specs/check/with_bare_import/095_cache_with_bare_import.ts b/tests/specs/check/with_bare_import/095_cache_with_bare_import.ts new file mode 100644 index 0000000000000..c0748305d5357 --- /dev/null +++ b/tests/specs/check/with_bare_import/095_cache_with_bare_import.ts @@ -0,0 +1 @@ +import "foo"; diff --git a/tests/specs/check/with_bare_import/095_cache_with_bare_import.ts.out b/tests/specs/check/with_bare_import/095_cache_with_bare_import.ts.out new file mode 100644 index 0000000000000..2668a6e08368f --- /dev/null +++ b/tests/specs/check/with_bare_import/095_cache_with_bare_import.ts.out @@ -0,0 +1,2 @@ +[WILDCARD]error: Relative import path "foo" not prefixed with / or ./ or ../ + at file:///[WILDCARD]/095_cache_with_bare_import.ts:[WILDCARD] diff --git a/tests/specs/check/with_bare_import/__test__.jsonc b/tests/specs/check/with_bare_import/__test__.jsonc new file mode 100644 index 0000000000000..c32a66ad2ccf5 --- /dev/null +++ b/tests/specs/check/with_bare_import/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "check 095_cache_with_bare_import.ts", + "output": "095_cache_with_bare_import.ts.out", + "exitCode": 1 +} diff --git a/tests/specs/compile/jsr_with_deps/__test__.jsonc b/tests/specs/compile/jsr_with_deps/__test__.jsonc new file mode 100644 index 0000000000000..be2bbd1e4fcc2 --- /dev/null +++ b/tests/specs/compile/jsr_with_deps/__test__.jsonc @@ -0,0 +1,22 @@ +{ + "tempDir": true, + "steps": [{ + "if": "unix", + "args": "compile --output main main.ts", + "output": "[WILDCARD]" + }, { + "if": "unix", + "commandName": "./main", + "args": [], + "output": "main.out" + }, { + "if": "windows", + "args": "compile --output main.exe main.ts", + "output": "[WILDCARD]" + }, { + "if": "windows", + "commandName": "./main.exe", + "args": [], + "output": "main.out" + }] +} diff --git a/tests/specs/compile/jsr_with_deps/main.out b/tests/specs/compile/jsr_with_deps/main.out new file mode 100644 index 0000000000000..6340327e03817 --- /dev/null +++ b/tests/specs/compile/jsr_with_deps/main.out @@ -0,0 +1,2 @@ +[Function: join] +http://[WILDLINE]/@std/url/0.220.1/join.ts diff --git a/tests/specs/compile/jsr_with_deps/main.ts b/tests/specs/compile/jsr_with_deps/main.ts new file mode 100644 index 0000000000000..44a7dc08c83df --- /dev/null +++ b/tests/specs/compile/jsr_with_deps/main.ts @@ -0,0 +1,8 @@ +// this was previously hanging in deno compile and wouldn't work +import { join } from "jsr:@std/url@0.220/join"; +import "jsr:@std/url@0.220/normalize"; + +console.log(join); + +// ensure import.meta.resolve works in compile for jsr specifiers +console.log(import.meta.resolve("jsr:@std/url@0.220/join")); diff --git a/tests/specs/jsr/deps/main.out b/tests/specs/jsr/deps/main.out index 621703c4ba2e6..48f75c0819e14 100644 --- a/tests/specs/jsr/deps/main.out +++ b/tests/specs/jsr/deps/main.out @@ -1,13 +1,13 @@ 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/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/no_module_graph/0.1.1_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/module-graph/1.4.0_meta.json +Download http://127.0.0.1:4250/@denotest/no-module-graph/0.1.1_meta.json [UNORDERED_START] 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/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/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/TestClass.ts [UNORDERED_END] { version: "0.1.1", other: Other {} } diff --git a/tests/specs/jsr/deps/main_info.out b/tests/specs/jsr/deps/main_info.out index c4d412707df86..0abdfa9401740 100644 --- a/tests/specs/jsr/deps/main_info.out +++ b/tests/specs/jsr/deps/main_info.out @@ -1,14 +1,14 @@ 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/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/no_module_graph/0.1.1_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/module-graph/1.4.0_meta.json +Download http://127.0.0.1:4250/@denotest/no-module-graph/0.1.1_meta.json [UNORDERED_START] 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/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/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/TestClass.ts [UNORDERED_END] local: [WILDCARD]main.ts type: TypeScript @@ -17,6 +17,6 @@ size: [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/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/TestClass.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/TestClass.ts ([WILDCARD]) diff --git a/tests/specs/jsr/module_graph/__test__.jsonc b/tests/specs/jsr/module_graph/__test__.jsonc index a8837a8b53777..16b086e8bcf2c 100644 --- a/tests/specs/jsr/module_graph/__test__.jsonc +++ b/tests/specs/jsr/module_graph/__test__.jsonc @@ -1,6 +1,6 @@ { "steps": [{ - "args": "run main.ts", + "args": "run --log-level=debug main.ts", "output": "main.out" }, { "cleanDenoDir": true, diff --git a/tests/specs/jsr/module_graph/main.out b/tests/specs/jsr/module_graph/main.out index 1cd0115b9b5c8..0bc19aeba21c7 100644 --- a/tests/specs/jsr/module_graph/main.out +++ b/tests/specs/jsr/module_graph/main.out @@ -1,7 +1,5 @@ -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 -[UNORDERED_START] -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] +[WILDCARD]Caching module info for http://[WILDLINE]/@denotest/module-graph/1.4.0/mod.ts +[WILDCARD]Caching module info for http://[WILDLINE]/@denotest/module-graph/1.4.0/other.ts +[WILDCARD] Test { other: Other {} } +[WILDCARD] diff --git a/tests/specs/jsr/module_graph/main.ts b/tests/specs/jsr/module_graph/main.ts index c92823cc2f94b..3f95747c50b5d 100644 --- a/tests/specs/jsr/module_graph/main.ts +++ b/tests/specs/jsr/module_graph/main.ts @@ -1,3 +1,3 @@ -import { Test } from "jsr:@denotest/module_graph"; +import { Test } from "jsr:@denotest/module-graph"; console.log(new Test()); diff --git a/tests/specs/jsr/module_graph/main_info.out b/tests/specs/jsr/module_graph/main_info.out index c35cca5b4ea9b..5e9e851632c19 100644 --- a/tests/specs/jsr/module_graph/main_info.out +++ b/tests/specs/jsr/module_graph/main_info.out @@ -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/1.4.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/1.4.0_meta.json [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/other.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 [UNORDERED_END] local: [WILDCARD]main.ts type: TypeScript @@ -10,5 +10,5 @@ dependencies: 2 unique size: [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/other.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]) diff --git a/tests/specs/jsr/module_graph2/__test__.jsonc b/tests/specs/jsr/module_graph2/__test__.jsonc new file mode 100644 index 0000000000000..16b086e8bcf2c --- /dev/null +++ b/tests/specs/jsr/module_graph2/__test__.jsonc @@ -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" + }] +} diff --git a/tests/specs/jsr/module_graph2/main.out b/tests/specs/jsr/module_graph2/main.out new file mode 100644 index 0000000000000..9f37a0382c0f4 --- /dev/null +++ b/tests/specs/jsr/module_graph2/main.out @@ -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] diff --git a/tests/specs/jsr/module_graph2/main.ts b/tests/specs/jsr/module_graph2/main.ts new file mode 100644 index 0000000000000..150bfef24a9d2 --- /dev/null +++ b/tests/specs/jsr/module_graph2/main.ts @@ -0,0 +1,3 @@ +import { Test } from "jsr:@denotest/module-graph2"; + +console.log(new Test()); diff --git a/tests/specs/jsr/module_graph2/main_info.out b/tests/specs/jsr/module_graph2/main_info.out new file mode 100644 index 0000000000000..266ee6d9684d2 --- /dev/null +++ b/tests/specs/jsr/module_graph2/main_info.out @@ -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]) diff --git a/tests/specs/jsr/no_module_graph/main.out b/tests/specs/jsr/no_module_graph/main.out index da9b67e11b564..1837c5c1caf0b 100644 --- a/tests/specs/jsr/no_module_graph/main.out +++ b/tests/specs/jsr/no_module_graph/main.out @@ -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/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/TestClass.ts +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/mod.ts +Download http://127.0.0.1:4250/@denotest/no-module-graph/0.1.0/TestClass.ts 0.1.0 TestClass {} diff --git a/tests/specs/jsr/no_module_graph/main.ts b/tests/specs/jsr/no_module_graph/main.ts index 6ea030c59f4c0..9d50eaab81f11 100644 --- a/tests/specs/jsr/no_module_graph/main.ts +++ b/tests/specs/jsr/no_module_graph/main.ts @@ -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(new TestClass()); diff --git a/tests/specs/jsr/no_module_graph/main_info.out b/tests/specs/jsr/no_module_graph/main_info.out index 0293e412033c8..45c97f77e4c49 100644 --- a/tests/specs/jsr/no_module_graph/main_info.out +++ b/tests/specs/jsr/no_module_graph/main_info.out @@ -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/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/TestClass.ts +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/mod.ts +Download http://127.0.0.1:4250/@denotest/no-module-graph/0.1.0/TestClass.ts local: [WILDCARD]main.ts type: TypeScript dependencies: 2 unique size: [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/TestClass.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]) diff --git a/tests/specs/jsr/no_module_graph/multiple.ts b/tests/specs/jsr/no_module_graph/multiple.ts index 660ed8be6b3de..9c7474a2cf486 100644 --- a/tests/specs/jsr/no_module_graph/multiple.ts +++ b/tests/specs/jsr/no_module_graph/multiple.ts @@ -1,5 +1,5 @@ -import version1 from "jsr:@denotest/no_module_graph@0.1.0"; -import version2 from "jsr:@denotest/no_module_graph@^0.2"; +import version1 from "jsr:@denotest/no-module-graph@0.1.0"; +import version2 from "jsr:@denotest/no-module-graph@^0.2"; console.log(version1); console.log(version2); diff --git a/tests/specs/lint/no_slow_types/__test__.jsonc b/tests/specs/lint/no_slow_types/__test__.jsonc new file mode 100644 index 0000000000000..2a5a340328373 --- /dev/null +++ b/tests/specs/lint/no_slow_types/__test__.jsonc @@ -0,0 +1,17 @@ +{ + "steps": [{ + "args": "lint", + "output": "no_slow_types.out", + "exitCode": 1 + }, { + "args": "lint --rules-exclude=no-slow-types", + "output": "Checked 4 files\n" + }, { + "args": "lint --config=deno.non-package.json", + "output": "Checked 4 files\n" + }, { + // non-entrypoint + "args": "lint d.ts", + "output": "Checked 1 file\n" + }] +} diff --git a/tests/testdata/lint/no_slow_types/a.ts b/tests/specs/lint/no_slow_types/a.ts similarity index 100% rename from tests/testdata/lint/no_slow_types/a.ts rename to tests/specs/lint/no_slow_types/a.ts diff --git a/tests/testdata/lint/no_slow_types/b.ts b/tests/specs/lint/no_slow_types/b.ts similarity index 100% rename from tests/testdata/lint/no_slow_types/b.ts rename to tests/specs/lint/no_slow_types/b.ts diff --git a/tests/testdata/lint/no_slow_types/c.ts b/tests/specs/lint/no_slow_types/c.ts similarity index 100% rename from tests/testdata/lint/no_slow_types/c.ts rename to tests/specs/lint/no_slow_types/c.ts diff --git a/tests/testdata/lint/no_slow_types/d.ts b/tests/specs/lint/no_slow_types/d.ts similarity index 100% rename from tests/testdata/lint/no_slow_types/d.ts rename to tests/specs/lint/no_slow_types/d.ts diff --git a/tests/testdata/lint/no_slow_types/deno.json b/tests/specs/lint/no_slow_types/deno.json similarity index 100% rename from tests/testdata/lint/no_slow_types/deno.json rename to tests/specs/lint/no_slow_types/deno.json diff --git a/tests/testdata/lint/no_slow_types/deno.non-package.json b/tests/specs/lint/no_slow_types/deno.non-package.json similarity index 100% rename from tests/testdata/lint/no_slow_types/deno.non-package.json rename to tests/specs/lint/no_slow_types/deno.non-package.json diff --git a/tests/testdata/lint/no_slow_types/no_slow_types.out b/tests/specs/lint/no_slow_types/no_slow_types.out similarity index 100% rename from tests/testdata/lint/no_slow_types/no_slow_types.out rename to tests/specs/lint/no_slow_types/no_slow_types.out diff --git a/tests/testdata/lint/no_slow_types/no_slow_types_entrypoint.out b/tests/specs/lint/no_slow_types/no_slow_types_entrypoint.out similarity index 100% rename from tests/testdata/lint/no_slow_types/no_slow_types_entrypoint.out rename to tests/specs/lint/no_slow_types/no_slow_types_entrypoint.out diff --git a/tests/specs/lint/no_slow_types_entrypoint/__test__.jsonc b/tests/specs/lint/no_slow_types_entrypoint/__test__.jsonc new file mode 100644 index 0000000000000..2ba74c03fd6eb --- /dev/null +++ b/tests/specs/lint/no_slow_types_entrypoint/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint a.ts", + "output": "no_slow_types_entrypoint.out", + "exitCode": 1 +} diff --git a/tests/testdata/lint/no_slow_types_workspace/a/mod.ts b/tests/specs/lint/no_slow_types_entrypoint/a.ts similarity index 100% rename from tests/testdata/lint/no_slow_types_workspace/a/mod.ts rename to tests/specs/lint/no_slow_types_entrypoint/a.ts diff --git a/tests/testdata/lint/no_slow_types_workspace/a/b.ts b/tests/specs/lint/no_slow_types_entrypoint/b.ts similarity index 100% rename from tests/testdata/lint/no_slow_types_workspace/a/b.ts rename to tests/specs/lint/no_slow_types_entrypoint/b.ts diff --git a/tests/specs/lint/no_slow_types_entrypoint/c.ts b/tests/specs/lint/no_slow_types_entrypoint/c.ts new file mode 100644 index 0000000000000..517aa3d211828 --- /dev/null +++ b/tests/specs/lint/no_slow_types_entrypoint/c.ts @@ -0,0 +1,4 @@ +// this one won't error because it's not an export +export function addC(a: number, b: number) { + return a + b; +} diff --git a/tests/testdata/lint/no_slow_types_workspace/a/d.ts b/tests/specs/lint/no_slow_types_entrypoint/d.ts similarity index 100% rename from tests/testdata/lint/no_slow_types_workspace/a/d.ts rename to tests/specs/lint/no_slow_types_entrypoint/d.ts diff --git a/tests/specs/lint/no_slow_types_entrypoint/deno.json b/tests/specs/lint/no_slow_types_entrypoint/deno.json new file mode 100644 index 0000000000000..2fd0af5f0f03a --- /dev/null +++ b/tests/specs/lint/no_slow_types_entrypoint/deno.json @@ -0,0 +1,8 @@ +{ + "name": "@pkg/pkg", + "version": "1.0.0", + "exports": { + "./a": "./a.ts", + "./b": "./b.ts" + } +} diff --git a/tests/specs/lint/no_slow_types_entrypoint/deno.non-package.json b/tests/specs/lint/no_slow_types_entrypoint/deno.non-package.json new file mode 100644 index 0000000000000..2c63c0851048d --- /dev/null +++ b/tests/specs/lint/no_slow_types_entrypoint/deno.non-package.json @@ -0,0 +1,2 @@ +{ +} diff --git a/tests/specs/lint/no_slow_types_entrypoint/no_slow_types.out b/tests/specs/lint/no_slow_types_entrypoint/no_slow_types.out new file mode 100644 index 0000000000000..5828906e76952 --- /dev/null +++ b/tests/specs/lint/no_slow_types_entrypoint/no_slow_types.out @@ -0,0 +1,35 @@ +error[no-slow-types]: missing explicit return type in the public API + --> [WILDCARD]a.ts:1:17 + | +1 | export function add(a: number, b: number) { + | ^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +error[no-slow-types]: missing explicit return type in the public API + --> [WILDCARD]b.ts:1:17 + | +1 | export function addB(a: number, b: number) { + | ^^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +error[no-slow-types]: missing explicit return type in the public API + --> [WILDCARD]d.ts:2:17 + | +2 | export function addD(a: number, b: number) { + | ^^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +Found 3 problems +Checked 4 files diff --git a/tests/specs/lint/no_slow_types_entrypoint/no_slow_types_entrypoint.out b/tests/specs/lint/no_slow_types_entrypoint/no_slow_types_entrypoint.out new file mode 100644 index 0000000000000..b8c1013bf0d50 --- /dev/null +++ b/tests/specs/lint/no_slow_types_entrypoint/no_slow_types_entrypoint.out @@ -0,0 +1,35 @@ +error[no-slow-types]: missing explicit return type in the public API + --> [WILDCARD]a.ts:1:17 + | +1 | export function add(a: number, b: number) { + | ^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +error[no-slow-types]: missing explicit return type in the public API + --> [WILDCARD]b.ts:1:17 + | +1 | export function addB(a: number, b: number) { + | ^^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +error[no-slow-types]: missing explicit return type in the public API + --> [WILDCARD]d.ts:2:17 + | +2 | export function addD(a: number, b: number) { + | ^^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +Found 3 problems +Checked 1 file diff --git a/tests/specs/lint/no_slow_types_workspace/__test__.jsonc b/tests/specs/lint/no_slow_types_workspace/__test__.jsonc new file mode 100644 index 0000000000000..7128e116c5d7c --- /dev/null +++ b/tests/specs/lint/no_slow_types_workspace/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint", + "output": "output.out", + "exitCode": 1 +} diff --git a/tests/specs/lint/no_slow_types_workspace/a/b.ts b/tests/specs/lint/no_slow_types_workspace/a/b.ts new file mode 100644 index 0000000000000..b96a794894c10 --- /dev/null +++ b/tests/specs/lint/no_slow_types_workspace/a/b.ts @@ -0,0 +1,5 @@ +export function addB(a: number, b: number) { + return a + b; +} + +export * from "./d.ts"; diff --git a/tests/specs/lint/no_slow_types_workspace/a/d.ts b/tests/specs/lint/no_slow_types_workspace/a/d.ts new file mode 100644 index 0000000000000..babe9d81b538a --- /dev/null +++ b/tests/specs/lint/no_slow_types_workspace/a/d.ts @@ -0,0 +1,4 @@ +// this one is re-exported via b.ts +export function addD(a: number, b: number) { + return a + b; +} diff --git a/tests/testdata/lint/no_slow_types_workspace/a/deno.json b/tests/specs/lint/no_slow_types_workspace/a/deno.json similarity index 100% rename from tests/testdata/lint/no_slow_types_workspace/a/deno.json rename to tests/specs/lint/no_slow_types_workspace/a/deno.json diff --git a/tests/specs/lint/no_slow_types_workspace/a/mod.ts b/tests/specs/lint/no_slow_types_workspace/a/mod.ts new file mode 100644 index 0000000000000..3b399665dc81d --- /dev/null +++ b/tests/specs/lint/no_slow_types_workspace/a/mod.ts @@ -0,0 +1,3 @@ +export function add(a: number, b: number) { + return a + b; +} diff --git a/tests/testdata/lint/no_slow_types_workspace/b/deno.json b/tests/specs/lint/no_slow_types_workspace/b/deno.json similarity index 100% rename from tests/testdata/lint/no_slow_types_workspace/b/deno.json rename to tests/specs/lint/no_slow_types_workspace/b/deno.json diff --git a/tests/testdata/lint/no_slow_types_workspace/b/mod.ts b/tests/specs/lint/no_slow_types_workspace/b/mod.ts similarity index 100% rename from tests/testdata/lint/no_slow_types_workspace/b/mod.ts rename to tests/specs/lint/no_slow_types_workspace/b/mod.ts diff --git a/tests/testdata/lint/no_slow_types_workspace/c/deno.json b/tests/specs/lint/no_slow_types_workspace/c/deno.json similarity index 100% rename from tests/testdata/lint/no_slow_types_workspace/c/deno.json rename to tests/specs/lint/no_slow_types_workspace/c/deno.json diff --git a/tests/testdata/lint/no_slow_types_workspace/c/mod_c.ts b/tests/specs/lint/no_slow_types_workspace/c/mod_c.ts similarity index 100% rename from tests/testdata/lint/no_slow_types_workspace/c/mod_c.ts rename to tests/specs/lint/no_slow_types_workspace/c/mod_c.ts diff --git a/tests/testdata/lint/no_slow_types_workspace/deno.json b/tests/specs/lint/no_slow_types_workspace/deno.json similarity index 100% rename from tests/testdata/lint/no_slow_types_workspace/deno.json rename to tests/specs/lint/no_slow_types_workspace/deno.json diff --git a/tests/testdata/lint/no_slow_types_workspace/output.out b/tests/specs/lint/no_slow_types_workspace/output.out similarity index 100% rename from tests/testdata/lint/no_slow_types_workspace/output.out rename to tests/specs/lint/no_slow_types_workspace/output.out diff --git a/tests/specs/lockfile/no_lock/__test__.jsonc b/tests/specs/lockfile/no_lock/__test__.jsonc new file mode 100644 index 0000000000000..60bbd17e0aa89 --- /dev/null +++ b/tests/specs/lockfile/no_lock/__test__.jsonc @@ -0,0 +1,31 @@ +{ + "steps": [{ + "args": "info main.ts", + "output": "fail_initial.out", + "exitCode": 10 + }, { + "args": "info --no-lock main.ts", + "output": "info.nolock.out" + }, { + "args": "bench", + "output": "fail.out", + "exitCode": 10 + }, { + "args": "bench --no-lock", + "output": "bench.nolock.out" + }, { + "args": "doc main.ts", + "exitCode": 10, + "output": "fail.out" + }, { + "args": "doc --no-lock main.ts", + "output": "doc.nolock.out" + }, { + "args": "test", + "exitCode": 10, + "output": "fail.out" + }, { + "args": "test --no-lock", + "output": "test.nolock.out" + }] +} diff --git a/tests/testdata/lockfile/basic/bench.nolock.out b/tests/specs/lockfile/no_lock/bench.nolock.out similarity index 62% rename from tests/testdata/lockfile/basic/bench.nolock.out rename to tests/specs/lockfile/no_lock/bench.nolock.out index 83e4de242b2da..351efc97098d0 100644 --- a/tests/testdata/lockfile/basic/bench.nolock.out +++ b/tests/specs/lockfile/no_lock/bench.nolock.out @@ -1,4 +1,3 @@ -Download http://localhost:4545/lockfile/basic/mod.ts Check file:///[WILDCARD]/main.bench.ts cpu: [WILDCARD] runtime: [WILDCARD] diff --git a/tests/testdata/lockfile/basic/deno.json b/tests/specs/lockfile/no_lock/deno.json similarity index 100% rename from tests/testdata/lockfile/basic/deno.json rename to tests/specs/lockfile/no_lock/deno.json diff --git a/tests/testdata/lockfile/basic/deno.lock b/tests/specs/lockfile/no_lock/deno.lock similarity index 100% rename from tests/testdata/lockfile/basic/deno.lock rename to tests/specs/lockfile/no_lock/deno.lock diff --git a/tests/specs/lockfile/no_lock/doc.nolock.out b/tests/specs/lockfile/no_lock/doc.nolock.out new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/tests/specs/lockfile/no_lock/fail.out b/tests/specs/lockfile/no_lock/fail.out new file mode 100644 index 0000000000000..4c2b044238378 --- /dev/null +++ b/tests/specs/lockfile/no_lock/fail.out @@ -0,0 +1,3 @@ +error: The source code is invalid, as it does not match the expected hash in the lock file. + Specifier: [WILDCARD]mod.ts + Lock file: [WILDCARD]deno.lock diff --git a/tests/testdata/lockfile/basic/fail.out b/tests/specs/lockfile/no_lock/fail_initial.out similarity index 100% rename from tests/testdata/lockfile/basic/fail.out rename to tests/specs/lockfile/no_lock/fail_initial.out diff --git a/tests/specs/lockfile/no_lock/info.nolock.out b/tests/specs/lockfile/no_lock/info.nolock.out new file mode 100644 index 0000000000000..b036611937063 --- /dev/null +++ b/tests/specs/lockfile/no_lock/info.nolock.out @@ -0,0 +1,7 @@ +local: [WILDLINE]main.ts +type: TypeScript +dependencies: 1 unique +size: [WILDCARD] + +file:///[WILDCARD]/main.ts ([WILDLINE]) +└── http://localhost:4545/lockfile/basic/mod.ts ([WILDLINE]) diff --git a/tests/testdata/lockfile/basic/main.bench.ts b/tests/specs/lockfile/no_lock/main.bench.ts similarity index 100% rename from tests/testdata/lockfile/basic/main.bench.ts rename to tests/specs/lockfile/no_lock/main.bench.ts diff --git a/tests/testdata/lockfile/basic/main.test.ts b/tests/specs/lockfile/no_lock/main.test.ts similarity index 100% rename from tests/testdata/lockfile/basic/main.test.ts rename to tests/specs/lockfile/no_lock/main.test.ts diff --git a/tests/testdata/lockfile/basic/main.ts b/tests/specs/lockfile/no_lock/main.ts similarity index 100% rename from tests/testdata/lockfile/basic/main.ts rename to tests/specs/lockfile/no_lock/main.ts diff --git a/tests/testdata/lockfile/basic/test.nolock.out b/tests/specs/lockfile/no_lock/test.nolock.out similarity index 63% rename from tests/testdata/lockfile/basic/test.nolock.out rename to tests/specs/lockfile/no_lock/test.nolock.out index 1332dfa8f10cb..b5039c2d6d2a2 100644 --- a/tests/testdata/lockfile/basic/test.nolock.out +++ b/tests/specs/lockfile/no_lock/test.nolock.out @@ -1,4 +1,3 @@ -Download http://localhost:4545/lockfile/basic/mod.ts Check file:///[WILDCARD]/main.test.ts running 1 test from [WILDCARD]/main.test.ts [WILDCARD] diff --git a/tests/specs/mod.rs b/tests/specs/mod.rs index 2040eea6277f9..fc61fefac3e66 100644 --- a/tests/specs/mod.rs +++ b/tests/specs/mod.rs @@ -71,8 +71,13 @@ struct StepMetaData { /// Whether to clean the deno_dir before running the step. #[serde(default)] pub clean_deno_dir: bool, + /// If the test should be retried multiple times on failure. + #[serde(default)] + pub flaky: bool, pub args: VecOrString, pub cwd: Option, + #[serde(rename = "if")] + pub if_cond: Option, pub command_name: Option, #[serde(default)] pub envs: HashMap, @@ -152,8 +157,11 @@ fn run_test(test: &CollectedTest, diagnostic_logger: Rc>>) { // todo(dsherret): add bases in the future as needed Some(base) => panic!("Unknown test base: {}", base), None => { - // by default add npm and jsr env vars - builder = builder.add_jsr_env_vars().add_npm_env_vars(); + // by default add all these + builder = builder + .add_jsr_env_vars() + .add_npm_env_vars() + .add_compile_env_vars(); } } @@ -167,35 +175,75 @@ fn run_test(test: &CollectedTest, diagnostic_logger: Rc>>) { cwd.copy_to_recursive_with_exclusions(temp_dir, &assertion_paths); } - for step in &metadata.steps { - if step.clean_deno_dir { - context.deno_dir().path().remove_dir_all(); + for step in metadata.steps.iter().filter(|s| should_run_step(s)) { + let run_func = || run_step(step, &metadata, &cwd, &context); + if step.flaky { + run_flaky(run_func); + } else { + run_func(); } + } +} - let command = context - .new_command() - .envs(metadata.envs.iter().chain(step.envs.iter())); - let command = match &step.args { - VecOrString::Vec(args) => command.args_vec(args), - VecOrString::String(text) => command.args(text), - }; - let command = match &step.cwd { - Some(cwd) => command.current_dir(cwd), - None => command, - }; - let command = match &step.command_name { - Some(command_name) => command.name(command_name), - None => command, - }; - let output = command.run(); - if step.output.ends_with(".out") { - let test_output_path = cwd.join(&step.output); - output.assert_matches_file(test_output_path); - } else { - output.assert_matches_text(&step.output); +fn should_run_step(step: &StepMetaData) -> bool { + if let Some(cond) = &step.if_cond { + match cond.as_str() { + "windows" => cfg!(windows), + "unix" => cfg!(unix), + "mac" => cfg!(target_os = "macos"), + "linux" => cfg!(target_os = "linux"), + value => panic!("Unknown if condition: {}", value), + } + } else { + true + } +} + +fn run_flaky(action: impl Fn()) { + for _ in 0..2 { + let result = std::panic::catch_unwind(AssertUnwindSafe(&action)); + if result.is_ok() { + return; } - output.assert_exit_code(step.exit_code); } + + // surface error on third try + action(); +} + +fn run_step( + step: &StepMetaData, + metadata: &MultiTestMetaData, + cwd: &PathRef, + context: &test_util::TestContext, +) { + if step.clean_deno_dir { + context.deno_dir().path().remove_dir_all(); + } + + let command = context + .new_command() + .envs(metadata.envs.iter().chain(step.envs.iter())); + let command = match &step.args { + VecOrString::Vec(args) => command.args_vec(args), + VecOrString::String(text) => command.args(text), + }; + let command = match &step.cwd { + Some(cwd) => command.current_dir(cwd), + None => command, + }; + let command = match &step.command_name { + Some(command_name) => command.name(command_name), + None => command, + }; + let output = command.run(); + if step.output.ends_with(".out") { + let test_output_path = cwd.join(&step.output); + output.assert_matches_file(test_output_path); + } else { + output.assert_matches_text(&step.output); + } + output.assert_exit_code(step.exit_code); } fn resolve_test_and_assertion_files( diff --git a/tests/specs/node/node_debug/__test__.jsonc b/tests/specs/node/node_debug/__test__.jsonc new file mode 100644 index 0000000000000..825d3bd3f1486 --- /dev/null +++ b/tests/specs/node/node_debug/__test__.jsonc @@ -0,0 +1,6 @@ +{ + "args": "run --allow-read main.mjs", + "envs": { "NODE_DEBUG": "*" }, + "output": "main.out", + "exitCode": 0 +} diff --git a/tests/specs/node/node_debug/hello.txt b/tests/specs/node/node_debug/hello.txt new file mode 100644 index 0000000000000..3b18e512dba79 --- /dev/null +++ b/tests/specs/node/node_debug/hello.txt @@ -0,0 +1 @@ +hello world diff --git a/tests/specs/node/node_debug/main.mjs b/tests/specs/node/node_debug/main.mjs new file mode 100644 index 0000000000000..b33657982eba2 --- /dev/null +++ b/tests/specs/node/node_debug/main.mjs @@ -0,0 +1,14 @@ +import { createReadStream } from "node:fs"; +import path from "node:path"; + +const filePath = path.join(import.meta.dirname, "hello.txt"); +const readableStream = createReadStream(filePath); +readableStream.on("data", (chunk) => { + console.log(chunk.toString()); +}); +readableStream.on("end", () => { + console.log("Finished reading the file"); +}); +readableStream.on("error", (error) => { + console.error("Error reading the file:", error); +}); diff --git a/tests/specs/node/node_debug/main.out b/tests/specs/node/node_debug/main.out new file mode 100644 index 0000000000000..efdd4c209d398 --- /dev/null +++ b/tests/specs/node/node_debug/main.out @@ -0,0 +1,36 @@ +STREAM [WILDCARD] 'resume' +STREAM [WILDCARD] 'resume' false +STREAM [WILDCARD] 'read' 0 +STREAM [WILDCARD] 'need readable' false +STREAM [WILDCARD] 'length less than watermark' true +STREAM [WILDCARD] 'reading, ended or constructing' false +STREAM [WILDCARD] 'flow' true +STREAM [WILDCARD] 'read' undefined +STREAM [WILDCARD] 'need readable' true +STREAM [WILDCARD] 'length less than watermark' true +STREAM [WILDCARD] 'reading, ended or constructing' false +STREAM [WILDCARD] 'read' 0 +STREAM [WILDCARD] 'need readable' true +STREAM [WILDCARD] 'length less than watermark' true +STREAM [WILDCARD] 'reading, ended or constructing' false +STREAM [WILDCARD] 'maybeReadMore read 0' +STREAM [WILDCARD] 'read' 0 +STREAM [WILDCARD] 'need readable' true +STREAM [WILDCARD] 'length less than watermark' true +STREAM [WILDCARD] 'do read' +STREAM [WILDCARD] 'readableAddChunk' +hello world + +STREAM [WILDCARD] 'maybeReadMore read 0' +STREAM [WILDCARD] 'read' 0 +STREAM [WILDCARD] 'need readable' true +STREAM [WILDCARD] 'length less than watermark' true +STREAM [WILDCARD] 'do read' +STREAM [WILDCARD] 'readableAddChunk' null +STREAM [WILDCARD] 'onEofChunk' +STREAM [WILDCARD] 'emitReadable_' false 0 true +STREAM [WILDCARD] 'flow' true +STREAM [WILDCARD] 'read' undefined +STREAM [WILDCARD] 'endReadable' false +STREAM [WILDCARD] 'endReadableNT' false 0 +Finished reading the file diff --git a/tests/specs/node/worker_threads/__test__.jsonc b/tests/specs/node/worker_threads/__test__.jsonc new file mode 100644 index 0000000000000..adcb9a85d67f6 --- /dev/null +++ b/tests/specs/node/worker_threads/__test__.jsonc @@ -0,0 +1,8 @@ +{ + "steps": [{ + "args": "run message_port_removelistener.mjs", + "output": "message_port_removelistener.mjs.out", + // Note: successful exit asserts that the test passed + "exitCode": 0 + }] +} diff --git a/tests/specs/node/worker_threads/message_port_removelistener.mjs b/tests/specs/node/worker_threads/message_port_removelistener.mjs new file mode 100644 index 0000000000000..e0cac6ce93d37 --- /dev/null +++ b/tests/specs/node/worker_threads/message_port_removelistener.mjs @@ -0,0 +1,9 @@ +import { MessageChannel } from "node:worker_threads"; + +const { port1, port2 } = new MessageChannel(); +const listener = (message) => { + console.log(message); + port1.off("message", listener); +}; +port1.on("message", listener); +port2.postMessage("Hello World!"); diff --git a/tests/specs/node/worker_threads/message_port_removelistener.mjs.out b/tests/specs/node/worker_threads/message_port_removelistener.mjs.out new file mode 100644 index 0000000000000..980a0d5f19a64 --- /dev/null +++ b/tests/specs/node/worker_threads/message_port_removelistener.mjs.out @@ -0,0 +1 @@ +Hello World! diff --git a/tests/specs/publish/allow_slow_types/__test__.jsonc b/tests/specs/publish/allow_slow_types/__test__.jsonc new file mode 100644 index 0000000000000..e9f1cd01151e4 --- /dev/null +++ b/tests/specs/publish/allow_slow_types/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "publish --allow-slow-types --token 'sadfasdf'", + "output": "allow_slow_types.out", + "exitCode": 0 +} diff --git a/tests/testdata/publish/allow_slow_types.out b/tests/specs/publish/allow_slow_types/allow_slow_types.out similarity index 100% rename from tests/testdata/publish/allow_slow_types.out rename to tests/specs/publish/allow_slow_types/allow_slow_types.out diff --git a/tests/testdata/publish/has_slow_types/deno.json b/tests/specs/publish/allow_slow_types/deno.json similarity index 100% rename from tests/testdata/publish/has_slow_types/deno.json rename to tests/specs/publish/allow_slow_types/deno.json diff --git a/tests/testdata/publish/has_slow_types/mod.ts b/tests/specs/publish/allow_slow_types/mod.ts similarity index 100% rename from tests/testdata/publish/has_slow_types/mod.ts rename to tests/specs/publish/allow_slow_types/mod.ts diff --git a/tests/specs/publish/bare_node_builtins/__test__.jsonc b/tests/specs/publish/bare_node_builtins/__test__.jsonc new file mode 100644 index 0000000000000..f9e38fbe588ac --- /dev/null +++ b/tests/specs/publish/bare_node_builtins/__test__.jsonc @@ -0,0 +1,17 @@ +{ + "tempDir": true, + "envs": { + "DISABLE_JSR_PROVENANCE": "true", + "DENO_TESTING_DISABLE_GIT_CHECK": "1" + }, + "steps": [{ + "args": "publish --token 'sadfasdf' --dry-run --unstable-bare-node-builtins", + "output": "bare_node_builtins.out" + }, { + "envs": { + "DENO_DISABLE_PEDANTIC_NODE_WARNINGS": "1" + }, + "args": "publish --token 'sadfasdf' --dry-run --unstable-bare-node-builtins", + "output": "no_warnings.out" + }] +} diff --git a/tests/specs/publish/bare_node_builtins/bare_node_builtins.out b/tests/specs/publish/bare_node_builtins/bare_node_builtins.out new file mode 100644 index 0000000000000..09acc639fa98a --- /dev/null +++ b/tests/specs/publish/bare_node_builtins/bare_node_builtins.out @@ -0,0 +1,11 @@ +Warning: Resolving "url" as "node:url" at file:///[WILDLINE]/mod.ts:1:22. If you want to use a built-in Node module, add a "node:" prefix. +Warning: Resolving "url" as "node:url" at file:///[WILDLINE]/mod.ts:1:22. If you want to use a built-in Node module, add a "node:" prefix. +Download http://localhost:4545/npm/registry/@types/node +Download http://localhost:4545/npm/registry/@types/node/node-18.16.19.tgz +Check file:///[WILDLINE]/mod.ts +Checking for slow types in the public API... +Check file:///[WILDLINE]/mod.ts +Simulating publish of @foo/bar@1.0.0 with files: + file:///[WILDLINE]/deno.json (87B) + file:///[WILDLINE]/mod.ts (121B) +Warning Aborting due to --dry-run diff --git a/tests/testdata/publish/bare_node_builtins/deno.json b/tests/specs/publish/bare_node_builtins/deno.json similarity index 100% rename from tests/testdata/publish/bare_node_builtins/deno.json rename to tests/specs/publish/bare_node_builtins/deno.json diff --git a/tests/testdata/publish/bare_node_builtins/mod.ts b/tests/specs/publish/bare_node_builtins/mod.ts similarity index 100% rename from tests/testdata/publish/bare_node_builtins/mod.ts rename to tests/specs/publish/bare_node_builtins/mod.ts diff --git a/tests/specs/publish/bare_node_builtins/no_warnings.out b/tests/specs/publish/bare_node_builtins/no_warnings.out new file mode 100644 index 0000000000000..f9a11f37c40f7 --- /dev/null +++ b/tests/specs/publish/bare_node_builtins/no_warnings.out @@ -0,0 +1,5 @@ +Checking for slow types in the public API... +Simulating publish of @foo/bar@1.0.0 with files: + file:///[WILDLINE]/deno.json (87B) + file:///[WILDLINE]/mod.ts (121B) +Warning Aborting due to --dry-run diff --git a/tests/specs/publish/config_file_jsonc/__test__.jsonc b/tests/specs/publish/config_file_jsonc/__test__.jsonc new file mode 100644 index 0000000000000..bef8ce4ca15ea --- /dev/null +++ b/tests/specs/publish/config_file_jsonc/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "deno_jsonc.out" +} diff --git a/tests/testdata/publish/deno_jsonc/deno.jsonc b/tests/specs/publish/config_file_jsonc/deno.jsonc similarity index 100% rename from tests/testdata/publish/deno_jsonc/deno.jsonc rename to tests/specs/publish/config_file_jsonc/deno.jsonc diff --git a/tests/testdata/publish/deno_jsonc.out b/tests/specs/publish/config_file_jsonc/deno_jsonc.out similarity index 62% rename from tests/testdata/publish/deno_jsonc.out rename to tests/specs/publish/config_file_jsonc/deno_jsonc.out index 820554943a324..af45ed598b655 100644 --- a/tests/testdata/publish/deno_jsonc.out +++ b/tests/specs/publish/config_file_jsonc/deno_jsonc.out @@ -1,6 +1,6 @@ -Check file:///[WILDCARD]/publish/deno_jsonc/mod.ts +Check file:///[WILDCARD]/mod.ts Checking for slow types in the public API... -Check file:///[WILDCARD]/publish/deno_jsonc/mod.ts +Check file:///[WILDCARD]/mod.ts Publishing @foo/bar@1.0.0 ... Successfully published @foo/bar@1.0.0 Visit http://127.0.0.1:4250/@foo/bar@1.0.0 for details diff --git a/tests/testdata/publish/deno_jsonc/mod.ts b/tests/specs/publish/config_file_jsonc/mod.ts similarity index 100% rename from tests/testdata/publish/deno_jsonc/mod.ts rename to tests/specs/publish/config_file_jsonc/mod.ts diff --git a/tests/testdata/publish/deno_jsonc/std_http.ts b/tests/specs/publish/config_file_jsonc/std_http.ts similarity index 100% rename from tests/testdata/publish/deno_jsonc/std_http.ts rename to tests/specs/publish/config_file_jsonc/std_http.ts diff --git a/tests/specs/publish/config_flag/__test__.jsonc b/tests/specs/publish/config_flag/__test__.jsonc new file mode 100644 index 0000000000000..289f9abc91ac3 --- /dev/null +++ b/tests/specs/publish/config_flag/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "publish --token 'sadfasdf' --config=successful/deno.json", + "output": "successful.out" +} diff --git a/tests/specs/publish/config_flag/successful.out b/tests/specs/publish/config_flag/successful.out new file mode 100644 index 0000000000000..78265361a3e67 --- /dev/null +++ b/tests/specs/publish/config_flag/successful.out @@ -0,0 +1,6 @@ +Check file:///[WILDCARD]/successful/mod.ts +Checking for slow types in the public API... +Check file:///[WILDCARD]/successful/mod.ts +Publishing @foo/bar@1.0.0 ... +Successfully published @foo/bar@1.0.0 +Visit http://127.0.0.1:4250/@foo/bar@1.0.0 for details diff --git a/tests/specs/publish/config_flag/successful/deno.json b/tests/specs/publish/config_flag/successful/deno.json new file mode 100644 index 0000000000000..fefab899bdbeb --- /dev/null +++ b/tests/specs/publish/config_flag/successful/deno.json @@ -0,0 +1,10 @@ +{ + "name": "@foo/bar", + "version": "1.0.0", + "exports": { + ".": "./mod.ts" + }, + "imports": { + "@std/http": "./std_http.ts" + } +} diff --git a/tests/testdata/publish/jsr_jsonc/mod.ts b/tests/specs/publish/config_flag/successful/mod.ts similarity index 100% rename from tests/testdata/publish/jsr_jsonc/mod.ts rename to tests/specs/publish/config_flag/successful/mod.ts diff --git a/tests/testdata/publish/jsr_jsonc/std_http.ts b/tests/specs/publish/config_flag/successful/std_http.ts similarity index 100% rename from tests/testdata/publish/jsr_jsonc/std_http.ts rename to tests/specs/publish/config_flag/successful/std_http.ts diff --git a/tests/specs/publish/dry_run/__test__.jsonc b/tests/specs/publish/dry_run/__test__.jsonc new file mode 100644 index 0000000000000..3ca6ff4d3c662 --- /dev/null +++ b/tests/specs/publish/dry_run/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "publish --token 'sadfasdf' --dry-run", + "output": "dry_run.out" +} diff --git a/tests/specs/publish/dry_run/deno.json b/tests/specs/publish/dry_run/deno.json new file mode 100644 index 0000000000000..fefab899bdbeb --- /dev/null +++ b/tests/specs/publish/dry_run/deno.json @@ -0,0 +1,10 @@ +{ + "name": "@foo/bar", + "version": "1.0.0", + "exports": { + ".": "./mod.ts" + }, + "imports": { + "@std/http": "./std_http.ts" + } +} diff --git a/tests/testdata/publish/dry_run.out b/tests/specs/publish/dry_run/dry_run.out similarity index 100% rename from tests/testdata/publish/dry_run.out rename to tests/specs/publish/dry_run/dry_run.out diff --git a/tests/specs/publish/dry_run/mod.ts b/tests/specs/publish/dry_run/mod.ts new file mode 100644 index 0000000000000..6e8a61bae9227 --- /dev/null +++ b/tests/specs/publish/dry_run/mod.ts @@ -0,0 +1,7 @@ +import http from "@std/http"; + +export function foobar(): { fileServer(): void } { + return { + fileServer: http.fileServer, + }; +} diff --git a/tests/specs/publish/dry_run/std_http.ts b/tests/specs/publish/dry_run/std_http.ts new file mode 100644 index 0000000000000..9d57b36f34eaf --- /dev/null +++ b/tests/specs/publish/dry_run/std_http.ts @@ -0,0 +1,6 @@ +// temp until we get jsr:@std/http in the test server +export default { + fileServer() { + console.log("Hi"); + }, +}; diff --git a/tests/specs/publish/has_slow_types/__test__.jsonc b/tests/specs/publish/has_slow_types/__test__.jsonc new file mode 100644 index 0000000000000..470bae81bdbc1 --- /dev/null +++ b/tests/specs/publish/has_slow_types/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "has_slow_types.out", + "exitCode": 1 +} diff --git a/tests/specs/publish/has_slow_types/deno.json b/tests/specs/publish/has_slow_types/deno.json new file mode 100644 index 0000000000000..5826e552929e5 --- /dev/null +++ b/tests/specs/publish/has_slow_types/deno.json @@ -0,0 +1,7 @@ +{ + "name": "@foo/bar", + "version": "1.1.0", + "exports": { + ".": "./mod.ts" + } +} diff --git a/tests/testdata/publish/has_slow_types.out b/tests/specs/publish/has_slow_types/has_slow_types.out similarity index 100% rename from tests/testdata/publish/has_slow_types.out rename to tests/specs/publish/has_slow_types/has_slow_types.out diff --git a/tests/specs/publish/has_slow_types/mod.ts b/tests/specs/publish/has_slow_types/mod.ts new file mode 100644 index 0000000000000..0253110493602 --- /dev/null +++ b/tests/specs/publish/has_slow_types/mod.ts @@ -0,0 +1,4 @@ +// requires an explicit type annotation of `number` +export function getRandom() { + return Math.random(); +} diff --git a/tests/specs/publish/invalid_import/__test__.jsonc b/tests/specs/publish/invalid_import/__test__.jsonc new file mode 100644 index 0000000000000..5436a04f83958 --- /dev/null +++ b/tests/specs/publish/invalid_import/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "publish --token 'sadfasdf' --dry-run", + "output": "invalid_import.out", + "exitCode": 1 +} diff --git a/tests/testdata/publish/invalid_import/deno.json b/tests/specs/publish/invalid_import/deno.json similarity index 100% rename from tests/testdata/publish/invalid_import/deno.json rename to tests/specs/publish/invalid_import/deno.json diff --git a/tests/testdata/publish/invalid_import.out b/tests/specs/publish/invalid_import/invalid_import.out similarity index 100% rename from tests/testdata/publish/invalid_import.out rename to tests/specs/publish/invalid_import/invalid_import.out diff --git a/tests/testdata/publish/invalid_import/mod.ts b/tests/specs/publish/invalid_import/mod.ts similarity index 100% rename from tests/testdata/publish/invalid_import/mod.ts rename to tests/specs/publish/invalid_import/mod.ts diff --git a/tests/specs/publish/invalid_import_esm_sh_suggestion/__test__.jsonc b/tests/specs/publish/invalid_import_esm_sh_suggestion/__test__.jsonc new file mode 100644 index 0000000000000..6a6c3bdec5657 --- /dev/null +++ b/tests/specs/publish/invalid_import_esm_sh_suggestion/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "publish --token 'sadfasdf' --dry-run", + "output": "invalid_import_esm_sh_suggestion.out", + "exitCode": 1 +} diff --git a/tests/testdata/publish/invalid_import_esm_sh_suggestion/deno.json b/tests/specs/publish/invalid_import_esm_sh_suggestion/deno.json similarity index 100% rename from tests/testdata/publish/invalid_import_esm_sh_suggestion/deno.json rename to tests/specs/publish/invalid_import_esm_sh_suggestion/deno.json diff --git a/tests/testdata/publish/invalid_import_esm_sh_suggestion.out b/tests/specs/publish/invalid_import_esm_sh_suggestion/invalid_import_esm_sh_suggestion.out similarity index 100% rename from tests/testdata/publish/invalid_import_esm_sh_suggestion.out rename to tests/specs/publish/invalid_import_esm_sh_suggestion/invalid_import_esm_sh_suggestion.out diff --git a/tests/testdata/publish/invalid_import_esm_sh_suggestion/mod.ts b/tests/specs/publish/invalid_import_esm_sh_suggestion/mod.ts similarity index 100% rename from tests/testdata/publish/invalid_import_esm_sh_suggestion/mod.ts rename to tests/specs/publish/invalid_import_esm_sh_suggestion/mod.ts diff --git a/tests/specs/publish/invalid_path/__test__.jsonc b/tests/specs/publish/invalid_path/__test__.jsonc new file mode 100644 index 0000000000000..24f9c0dfac66c --- /dev/null +++ b/tests/specs/publish/invalid_path/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "invalid_path.out", + "exitCode": 1 +} diff --git a/tests/testdata/publish/invalid_path/deno.json b/tests/specs/publish/invalid_path/deno.json similarity index 100% rename from tests/testdata/publish/invalid_path/deno.json rename to tests/specs/publish/invalid_path/deno.json diff --git a/tests/testdata/publish/invalid_path.out b/tests/specs/publish/invalid_path/invalid_path.out similarity index 100% rename from tests/testdata/publish/invalid_path.out rename to tests/specs/publish/invalid_path/invalid_path.out diff --git a/tests/testdata/publish/invalid_path/mod.ts b/tests/specs/publish/invalid_path/mod.ts similarity index 100% rename from tests/testdata/publish/invalid_path/mod.ts rename to tests/specs/publish/invalid_path/mod.ts diff --git a/tests/specs/publish/invalid_path/path with spaces.txt b/tests/specs/publish/invalid_path/path with spaces.txt new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/tests/specs/publish/javascript_decl_file/__test__.jsonc b/tests/specs/publish/javascript_decl_file/__test__.jsonc new file mode 100644 index 0000000000000..0b6b0888eebd6 --- /dev/null +++ b/tests/specs/publish/javascript_decl_file/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "javascript_decl_file.out", + "exitCode": 0 +} diff --git a/tests/testdata/publish/javascript_decl_file/deno.json b/tests/specs/publish/javascript_decl_file/deno.json similarity index 100% rename from tests/testdata/publish/javascript_decl_file/deno.json rename to tests/specs/publish/javascript_decl_file/deno.json diff --git a/tests/testdata/publish/javascript_decl_file.out b/tests/specs/publish/javascript_decl_file/javascript_decl_file.out similarity index 100% rename from tests/testdata/publish/javascript_decl_file.out rename to tests/specs/publish/javascript_decl_file/javascript_decl_file.out diff --git a/tests/testdata/publish/javascript_decl_file/mod.d.ts b/tests/specs/publish/javascript_decl_file/mod.d.ts similarity index 100% rename from tests/testdata/publish/javascript_decl_file/mod.d.ts rename to tests/specs/publish/javascript_decl_file/mod.d.ts diff --git a/tests/testdata/publish/javascript_decl_file/mod.js b/tests/specs/publish/javascript_decl_file/mod.js similarity index 100% rename from tests/testdata/publish/javascript_decl_file/mod.js rename to tests/specs/publish/javascript_decl_file/mod.js diff --git a/tests/specs/publish/javascript_missing_decl_file/__test__.jsonc b/tests/specs/publish/javascript_missing_decl_file/__test__.jsonc new file mode 100644 index 0000000000000..1e760cf2237d4 --- /dev/null +++ b/tests/specs/publish/javascript_missing_decl_file/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "javascript_missing_decl_file.out", + "exitCode": 0 +} diff --git a/tests/testdata/publish/javascript_missing_decl_file/deno.json b/tests/specs/publish/javascript_missing_decl_file/deno.json similarity index 100% rename from tests/testdata/publish/javascript_missing_decl_file/deno.json rename to tests/specs/publish/javascript_missing_decl_file/deno.json diff --git a/tests/testdata/publish/javascript_missing_decl_file.out b/tests/specs/publish/javascript_missing_decl_file/javascript_missing_decl_file.out similarity index 100% rename from tests/testdata/publish/javascript_missing_decl_file.out rename to tests/specs/publish/javascript_missing_decl_file/javascript_missing_decl_file.out diff --git a/tests/testdata/publish/javascript_missing_decl_file/mod.js b/tests/specs/publish/javascript_missing_decl_file/mod.js similarity index 100% rename from tests/testdata/publish/javascript_missing_decl_file/mod.js rename to tests/specs/publish/javascript_missing_decl_file/mod.js diff --git a/tests/testdata/publish/javascript_missing_decl_file/other.js b/tests/specs/publish/javascript_missing_decl_file/other.js similarity index 100% rename from tests/testdata/publish/javascript_missing_decl_file/other.js rename to tests/specs/publish/javascript_missing_decl_file/other.js diff --git a/tests/specs/publish/jsr_jsonc/__test__.jsonc b/tests/specs/publish/jsr_jsonc/__test__.jsonc new file mode 100644 index 0000000000000..774d5a534e192 --- /dev/null +++ b/tests/specs/publish/jsr_jsonc/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "mod.out" +} diff --git a/tests/testdata/publish/jsr_jsonc/jsr.jsonc b/tests/specs/publish/jsr_jsonc/jsr.jsonc similarity index 100% rename from tests/testdata/publish/jsr_jsonc/jsr.jsonc rename to tests/specs/publish/jsr_jsonc/jsr.jsonc diff --git a/tests/testdata/publish/jsr_jsonc/mod.out b/tests/specs/publish/jsr_jsonc/mod.out similarity index 100% rename from tests/testdata/publish/jsr_jsonc/mod.out rename to tests/specs/publish/jsr_jsonc/mod.out diff --git a/tests/specs/publish/jsr_jsonc/mod.ts b/tests/specs/publish/jsr_jsonc/mod.ts new file mode 100644 index 0000000000000..6e8a61bae9227 --- /dev/null +++ b/tests/specs/publish/jsr_jsonc/mod.ts @@ -0,0 +1,7 @@ +import http from "@std/http"; + +export function foobar(): { fileServer(): void } { + return { + fileServer: http.fileServer, + }; +} diff --git a/tests/specs/publish/jsr_jsonc/std_http.ts b/tests/specs/publish/jsr_jsonc/std_http.ts new file mode 100644 index 0000000000000..9d57b36f34eaf --- /dev/null +++ b/tests/specs/publish/jsr_jsonc/std_http.ts @@ -0,0 +1,6 @@ +// temp until we get jsr:@std/http in the test server +export default { + fileServer() { + console.log("Hi"); + }, +}; diff --git a/tests/specs/publish/missing_deno_json/__test__.jsonc b/tests/specs/publish/missing_deno_json/__test__.jsonc new file mode 100644 index 0000000000000..614caecd6b988 --- /dev/null +++ b/tests/specs/publish/missing_deno_json/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "missing_deno_json.out", + "exitCode": 1 +} diff --git a/tests/testdata/publish/missing_deno_json/main.ts b/tests/specs/publish/missing_deno_json/main.ts similarity index 100% rename from tests/testdata/publish/missing_deno_json/main.ts rename to tests/specs/publish/missing_deno_json/main.ts diff --git a/tests/testdata/publish/missing_deno_json.out b/tests/specs/publish/missing_deno_json/missing_deno_json.out similarity index 100% rename from tests/testdata/publish/missing_deno_json.out rename to tests/specs/publish/missing_deno_json/missing_deno_json.out diff --git a/tests/specs/publish/no_check/__test__.jsonc b/tests/specs/publish/no_check/__test__.jsonc new file mode 100644 index 0000000000000..e89cd7a574e91 --- /dev/null +++ b/tests/specs/publish/no_check/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "publish --token 'sadfasdf' --no-check", + "output": "successful_no_check.out" +} diff --git a/tests/specs/publish/no_check/deno.json b/tests/specs/publish/no_check/deno.json new file mode 100644 index 0000000000000..fefab899bdbeb --- /dev/null +++ b/tests/specs/publish/no_check/deno.json @@ -0,0 +1,10 @@ +{ + "name": "@foo/bar", + "version": "1.0.0", + "exports": { + ".": "./mod.ts" + }, + "imports": { + "@std/http": "./std_http.ts" + } +} diff --git a/tests/specs/publish/no_check/mod.ts b/tests/specs/publish/no_check/mod.ts new file mode 100644 index 0000000000000..6e8a61bae9227 --- /dev/null +++ b/tests/specs/publish/no_check/mod.ts @@ -0,0 +1,7 @@ +import http from "@std/http"; + +export function foobar(): { fileServer(): void } { + return { + fileServer: http.fileServer, + }; +} diff --git a/tests/specs/publish/no_check/std_http.ts b/tests/specs/publish/no_check/std_http.ts new file mode 100644 index 0000000000000..9d57b36f34eaf --- /dev/null +++ b/tests/specs/publish/no_check/std_http.ts @@ -0,0 +1,6 @@ +// temp until we get jsr:@std/http in the test server +export default { + fileServer() { + console.log("Hi"); + }, +}; diff --git a/tests/testdata/publish/successful_no_check.out b/tests/specs/publish/no_check/successful_no_check.out similarity index 100% rename from tests/testdata/publish/successful_no_check.out rename to tests/specs/publish/no_check/successful_no_check.out diff --git a/tests/specs/publish/no_token/__test__.jsonc b/tests/specs/publish/no_token/__test__.jsonc new file mode 100644 index 0000000000000..f8a7fa942b1fd --- /dev/null +++ b/tests/specs/publish/no_token/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "publish", + "output": "no_token.out", + "exitCode": 1 +} diff --git a/tests/testdata/publish/workspace/bar/mod.ts b/tests/specs/publish/no_token/main.ts similarity index 100% rename from tests/testdata/publish/workspace/bar/mod.ts rename to tests/specs/publish/no_token/main.ts diff --git a/tests/testdata/publish/no_token.out b/tests/specs/publish/no_token/no_token.out similarity index 100% rename from tests/testdata/publish/no_token.out rename to tests/specs/publish/no_token/no_token.out diff --git a/tests/specs/publish/node_specifier/__test__.jsonc b/tests/specs/publish/node_specifier/__test__.jsonc new file mode 100644 index 0000000000000..f845f247947bd --- /dev/null +++ b/tests/specs/publish/node_specifier/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "node_specifier.out" +} diff --git a/tests/testdata/publish/node_specifier/deno.json b/tests/specs/publish/node_specifier/deno.json similarity index 100% rename from tests/testdata/publish/node_specifier/deno.json rename to tests/specs/publish/node_specifier/deno.json diff --git a/tests/testdata/publish/node_specifier/mod.ts b/tests/specs/publish/node_specifier/mod.ts similarity index 100% rename from tests/testdata/publish/node_specifier/mod.ts rename to tests/specs/publish/node_specifier/mod.ts diff --git a/tests/testdata/publish/node_specifier.out b/tests/specs/publish/node_specifier/node_specifier.out similarity index 100% rename from tests/testdata/publish/node_specifier.out rename to tests/specs/publish/node_specifier/node_specifier.out diff --git a/tests/specs/publish/package_json/__test__.jsonc b/tests/specs/publish/package_json/__test__.jsonc new file mode 100644 index 0000000000000..c4e954a6efd14 --- /dev/null +++ b/tests/specs/publish/package_json/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "package_json.out" +} diff --git a/tests/testdata/publish/package_json/deno.json b/tests/specs/publish/package_json/deno.json similarity index 100% rename from tests/testdata/publish/package_json/deno.json rename to tests/specs/publish/package_json/deno.json diff --git a/tests/testdata/publish/package_json/mod.ts b/tests/specs/publish/package_json/mod.ts similarity index 100% rename from tests/testdata/publish/package_json/mod.ts rename to tests/specs/publish/package_json/mod.ts diff --git a/tests/testdata/publish/package_json/package.json b/tests/specs/publish/package_json/package.json similarity index 100% rename from tests/testdata/publish/package_json/package.json rename to tests/specs/publish/package_json/package.json diff --git a/tests/testdata/publish/package_json.out b/tests/specs/publish/package_json/package_json.out similarity index 100% rename from tests/testdata/publish/package_json.out rename to tests/specs/publish/package_json/package_json.out diff --git a/tests/specs/publish/sloppy_imports/__test__.jsonc b/tests/specs/publish/sloppy_imports/__test__.jsonc new file mode 100644 index 0000000000000..bfb3d38dd412f --- /dev/null +++ b/tests/specs/publish/sloppy_imports/__test__.jsonc @@ -0,0 +1,21 @@ +{ + "envs": { + "DISABLE_JSR_PROVENANCE": "true", + "DENO_TESTING_DISABLE_GIT_CHECK": "1" + }, + "tempDir": true, + "steps": [{ + "args": "publish --token 'sadfasdf' --dry-run --unstable-sloppy-imports", + "output": "sloppy_imports.out" + }, { + "args": "publish --token 'sadfasdf' --dry-run", + "output": "sloppy_imports_not_enabled.out", + "exitCode": 1 + }, { + "args": "publish --token 'sadfasdf' --dry-run --unstable-sloppy-imports", + "output": "sloppy_imports_no_warnings.out", + "envs": { + "DENO_DISABLE_PEDANTIC_NODE_WARNINGS": "1" + } + }] +} diff --git a/tests/testdata/publish/sloppy_imports/b/index.ts b/tests/specs/publish/sloppy_imports/b/index.ts similarity index 100% rename from tests/testdata/publish/sloppy_imports/b/index.ts rename to tests/specs/publish/sloppy_imports/b/index.ts diff --git a/tests/testdata/publish/sloppy_imports/deno.json b/tests/specs/publish/sloppy_imports/deno.json similarity index 100% rename from tests/testdata/publish/sloppy_imports/deno.json rename to tests/specs/publish/sloppy_imports/deno.json diff --git a/tests/testdata/publish/sloppy_imports/mod.ts b/tests/specs/publish/sloppy_imports/mod.ts similarity index 100% rename from tests/testdata/publish/sloppy_imports/mod.ts rename to tests/specs/publish/sloppy_imports/mod.ts diff --git a/tests/specs/publish/sloppy_imports/sloppy_imports.out b/tests/specs/publish/sloppy_imports/sloppy_imports.out new file mode 100644 index 0000000000000..bfa258b939998 --- /dev/null +++ b/tests/specs/publish/sloppy_imports/sloppy_imports.out @@ -0,0 +1,10 @@ +Warning Sloppy module resolution (hint: specify path to index.ts file in directory instead) + at file:///[WILDCARD]/mod.ts:1:20 +Check file:///[WILDCARD]/mod.ts +Checking for slow types in the public API... +Check file:///[WILDCARD]/mod.ts +Simulating publish of @foo/bar@1.0.0 with files: + file:///[WILDCARD]/b/index.ts (27B) + file:///[WILDCARD]/deno.json (87B) + file:///[WILDCARD]/mod.ts (35B) +Warning Aborting due to --dry-run diff --git a/tests/specs/publish/sloppy_imports/sloppy_imports_no_warnings.out b/tests/specs/publish/sloppy_imports/sloppy_imports_no_warnings.out new file mode 100644 index 0000000000000..72ff281a36cab --- /dev/null +++ b/tests/specs/publish/sloppy_imports/sloppy_imports_no_warnings.out @@ -0,0 +1,6 @@ +Checking for slow types in the public API... +Simulating publish of @foo/bar@1.0.0 with files: + file:///[WILDCARD]/b/index.ts (27B) + file:///[WILDCARD]/deno.json (87B) + file:///[WILDCARD]/mod.ts (35B) +Warning Aborting due to --dry-run diff --git a/tests/testdata/publish/sloppy_imports_not_enabled.out b/tests/specs/publish/sloppy_imports/sloppy_imports_not_enabled.out similarity index 68% rename from tests/testdata/publish/sloppy_imports_not_enabled.out rename to tests/specs/publish/sloppy_imports/sloppy_imports_not_enabled.out index c2f74ad2c86e0..4eacbea65503e 100644 --- a/tests/testdata/publish/sloppy_imports_not_enabled.out +++ b/tests/specs/publish/sloppy_imports/sloppy_imports_not_enabled.out @@ -1,2 +1,2 @@ error: [WILDCARD] Maybe specify path to 'index.ts' file in directory instead or run with --unstable-sloppy-imports - at file:///[WILDCARD]/sloppy_imports/mod.ts:1:20 + at file:///[WILDCARD]/mod.ts:1:20 diff --git a/tests/specs/publish/successful/__test__.jsonc b/tests/specs/publish/successful/__test__.jsonc new file mode 100644 index 0000000000000..fe5287e71772d --- /dev/null +++ b/tests/specs/publish/successful/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "successful.out" +} diff --git a/tests/specs/publish/successful/deno.json b/tests/specs/publish/successful/deno.json new file mode 100644 index 0000000000000..fefab899bdbeb --- /dev/null +++ b/tests/specs/publish/successful/deno.json @@ -0,0 +1,10 @@ +{ + "name": "@foo/bar", + "version": "1.0.0", + "exports": { + ".": "./mod.ts" + }, + "imports": { + "@std/http": "./std_http.ts" + } +} diff --git a/tests/specs/publish/successful/mod.ts b/tests/specs/publish/successful/mod.ts new file mode 100644 index 0000000000000..6e8a61bae9227 --- /dev/null +++ b/tests/specs/publish/successful/mod.ts @@ -0,0 +1,7 @@ +import http from "@std/http"; + +export function foobar(): { fileServer(): void } { + return { + fileServer: http.fileServer, + }; +} diff --git a/tests/specs/publish/successful/std_http.ts b/tests/specs/publish/successful/std_http.ts new file mode 100644 index 0000000000000..9d57b36f34eaf --- /dev/null +++ b/tests/specs/publish/successful/std_http.ts @@ -0,0 +1,6 @@ +// temp until we get jsr:@std/http in the test server +export default { + fileServer() { + console.log("Hi"); + }, +}; diff --git a/tests/testdata/publish/successful.out b/tests/specs/publish/successful/successful.out similarity index 100% rename from tests/testdata/publish/successful.out rename to tests/specs/publish/successful/successful.out diff --git a/tests/specs/publish/symlink/__test__.jsonc b/tests/specs/publish/symlink/__test__.jsonc new file mode 100644 index 0000000000000..32da3baff5550 --- /dev/null +++ b/tests/specs/publish/symlink/__test__.jsonc @@ -0,0 +1,15 @@ +{ + "tempDir": true, + "envs": { + "DISABLE_JSR_PROVENANCE": "true", + "DENO_TESTING_DISABLE_GIT_CHECK": "1" + }, + "steps": [{ + "args": ["eval", "Deno.symlinkSync('./mod.ts', './symlink');"], + "output": "[WILDCARD]" + }, { + "args": "publish --token 'sadfasdf' --dry-run", + "output": "symlink.out", + "exitCode": 0 + }] +} diff --git a/tests/testdata/publish/symlink/deno.json b/tests/specs/publish/symlink/deno.json similarity index 100% rename from tests/testdata/publish/symlink/deno.json rename to tests/specs/publish/symlink/deno.json diff --git a/tests/testdata/publish/symlink/mod.ts b/tests/specs/publish/symlink/mod.ts similarity index 100% rename from tests/testdata/publish/symlink/mod.ts rename to tests/specs/publish/symlink/mod.ts diff --git a/tests/testdata/publish/symlink.out b/tests/specs/publish/symlink/symlink.out similarity index 100% rename from tests/testdata/publish/symlink.out rename to tests/specs/publish/symlink/symlink.out diff --git a/tests/specs/publish/unanalyzable_dynamic_import/__test__.jsonc b/tests/specs/publish/unanalyzable_dynamic_import/__test__.jsonc new file mode 100644 index 0000000000000..45073b099d657 --- /dev/null +++ b/tests/specs/publish/unanalyzable_dynamic_import/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "unanalyzable_dynamic_import.out", + "exitCode": 0 +} diff --git a/tests/testdata/publish/unanalyzable_dynamic_import/deno.json b/tests/specs/publish/unanalyzable_dynamic_import/deno.json similarity index 100% rename from tests/testdata/publish/unanalyzable_dynamic_import/deno.json rename to tests/specs/publish/unanalyzable_dynamic_import/deno.json diff --git a/tests/testdata/publish/unanalyzable_dynamic_import/mod.ts b/tests/specs/publish/unanalyzable_dynamic_import/mod.ts similarity index 100% rename from tests/testdata/publish/unanalyzable_dynamic_import/mod.ts rename to tests/specs/publish/unanalyzable_dynamic_import/mod.ts diff --git a/tests/testdata/publish/unanalyzable_dynamic_import.out b/tests/specs/publish/unanalyzable_dynamic_import/unanalyzable_dynamic_import.out similarity index 100% rename from tests/testdata/publish/unanalyzable_dynamic_import.out rename to tests/specs/publish/unanalyzable_dynamic_import/unanalyzable_dynamic_import.out diff --git a/tests/specs/publish/unsupported_jsx_tsx/__test__.jsonc b/tests/specs/publish/unsupported_jsx_tsx/__test__.jsonc new file mode 100644 index 0000000000000..774d5a534e192 --- /dev/null +++ b/tests/specs/publish/unsupported_jsx_tsx/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "mod.out" +} diff --git a/tests/testdata/publish/unsupported_jsx_tsx/foo.jsx b/tests/specs/publish/unsupported_jsx_tsx/foo.jsx similarity index 100% rename from tests/testdata/publish/unsupported_jsx_tsx/foo.jsx rename to tests/specs/publish/unsupported_jsx_tsx/foo.jsx diff --git a/tests/testdata/publish/unsupported_jsx_tsx/foo.tsx b/tests/specs/publish/unsupported_jsx_tsx/foo.tsx similarity index 100% rename from tests/testdata/publish/unsupported_jsx_tsx/foo.tsx rename to tests/specs/publish/unsupported_jsx_tsx/foo.tsx diff --git a/tests/testdata/publish/unsupported_jsx_tsx/jsr.jsonc b/tests/specs/publish/unsupported_jsx_tsx/jsr.jsonc similarity index 100% rename from tests/testdata/publish/unsupported_jsx_tsx/jsr.jsonc rename to tests/specs/publish/unsupported_jsx_tsx/jsr.jsonc diff --git a/tests/testdata/publish/unsupported_jsx_tsx/mod.out b/tests/specs/publish/unsupported_jsx_tsx/mod.out similarity index 100% rename from tests/testdata/publish/unsupported_jsx_tsx/mod.out rename to tests/specs/publish/unsupported_jsx_tsx/mod.out diff --git a/tests/testdata/publish/unsupported_jsx_tsx/mod.ts b/tests/specs/publish/unsupported_jsx_tsx/mod.ts similarity index 100% rename from tests/testdata/publish/unsupported_jsx_tsx/mod.ts rename to tests/specs/publish/unsupported_jsx_tsx/mod.ts diff --git a/tests/specs/publish/workspace/__test__.jsonc b/tests/specs/publish/workspace/__test__.jsonc new file mode 100644 index 0000000000000..7b1c04d568a75 --- /dev/null +++ b/tests/specs/publish/workspace/__test__.jsonc @@ -0,0 +1,10 @@ +{ + "steps": [{ + "args": "publish --token 'sadfasdf'", + "output": "workspace.out" + }, { + "cwd": "./bar", + "args": "publish --token 'sadfasdf'", + "output": "workspace_individual.out" + }] +} diff --git a/tests/testdata/publish/workspace/bar/deno.json b/tests/specs/publish/workspace/bar/deno.json similarity index 100% rename from tests/testdata/publish/workspace/bar/deno.json rename to tests/specs/publish/workspace/bar/deno.json diff --git a/tests/specs/publish/workspace/bar/mod.ts b/tests/specs/publish/workspace/bar/mod.ts new file mode 100644 index 0000000000000..8d9b8a22a101a --- /dev/null +++ b/tests/specs/publish/workspace/bar/mod.ts @@ -0,0 +1,3 @@ +export function add(a: number, b: number): number { + return a + b; +} diff --git a/tests/testdata/publish/workspace/deno.json b/tests/specs/publish/workspace/deno.json similarity index 100% rename from tests/testdata/publish/workspace/deno.json rename to tests/specs/publish/workspace/deno.json diff --git a/tests/testdata/publish/workspace/foo/deno.json b/tests/specs/publish/workspace/foo/deno.json similarity index 100% rename from tests/testdata/publish/workspace/foo/deno.json rename to tests/specs/publish/workspace/foo/deno.json diff --git a/tests/testdata/publish/workspace/foo/mod.ts b/tests/specs/publish/workspace/foo/mod.ts similarity index 100% rename from tests/testdata/publish/workspace/foo/mod.ts rename to tests/specs/publish/workspace/foo/mod.ts diff --git a/tests/testdata/publish/workspace.out b/tests/specs/publish/workspace/workspace.out similarity index 63% rename from tests/testdata/publish/workspace.out rename to tests/specs/publish/workspace/workspace.out index 17f2dab3b6f8a..8c57bc2dd84aa 100644 --- a/tests/testdata/publish/workspace.out +++ b/tests/specs/publish/workspace/workspace.out @@ -1,9 +1,9 @@ Publishing a workspace... -Check file:///[WILDCARD]/workspace/foo/mod.ts -Check file:///[WILDCARD]/workspace/bar/mod.ts +Check file:///[WILDCARD]/foo/mod.ts +Check file:///[WILDCARD]/bar/mod.ts Checking for slow types in the public API... -Check file:///[WILDCARD]/workspace/foo/mod.ts -Check file:///[WILDCARD]/workspace/bar/mod.ts +Check file:///[WILDCARD]/foo/mod.ts +Check file:///[WILDCARD]/bar/mod.ts Publishing @foo/bar@1.0.0 ... Successfully published @foo/bar@1.0.0 Visit http://127.0.0.1:4250/@foo/bar@1.0.0 for details diff --git a/tests/testdata/publish/workspace_individual.out b/tests/specs/publish/workspace/workspace_individual.out similarity index 64% rename from tests/testdata/publish/workspace_individual.out rename to tests/specs/publish/workspace/workspace_individual.out index e734ae06ed135..edb6b53aa350b 100644 --- a/tests/testdata/publish/workspace_individual.out +++ b/tests/specs/publish/workspace/workspace_individual.out @@ -1,6 +1,6 @@ -Check file:///[WILDCARD]/workspace/bar/mod.ts +Check file:///[WILDCARD]/bar/mod.ts Checking for slow types in the public API... -Check file:///[WILDCARD]/workspace/bar/mod.ts +Check file:///[WILDCARD]/bar/mod.ts Publishing @foo/bar@1.0.0 ... Successfully published @foo/bar@1.0.0 Visit http://127.0.0.1:4250/@foo/bar@1.0.0 for details diff --git a/tests/specs/run/import_map_parent_dir/__test__.jsonc b/tests/specs/run/import_map_parent_dir/__test__.jsonc new file mode 100644 index 0000000000000..f938448544568 --- /dev/null +++ b/tests/specs/run/import_map_parent_dir/__test__.jsonc @@ -0,0 +1,9 @@ +{ + "steps": [{ + "args": "info --config=sub/deno.json sub/main.ts", + "output": "info.out" + }, { + "args": "run --check sub/main.ts", + "output": "run.out" + }] +} diff --git a/tests/specs/run/import_map_parent_dir/import_map.json b/tests/specs/run/import_map_parent_dir/import_map.json new file mode 100644 index 0000000000000..ce2344d64daef --- /dev/null +++ b/tests/specs/run/import_map_parent_dir/import_map.json @@ -0,0 +1,5 @@ +{ + "imports": { + "~/shared/": "./shared/" + } +} diff --git a/tests/specs/run/import_map_parent_dir/info.out b/tests/specs/run/import_map_parent_dir/info.out new file mode 100644 index 0000000000000..05b9b317e370c --- /dev/null +++ b/tests/specs/run/import_map_parent_dir/info.out @@ -0,0 +1,7 @@ +local: [WILDLINE]main.ts +type: TypeScript +dependencies: 1 unique +size: [WILDLINE] + +file:///[WILDLINE]/sub/main.ts ([WILDLINE]) +└── file:///[WILDLINE]/shared/models.ts ([WILDLINE]) diff --git a/tests/specs/run/import_map_parent_dir/run.out b/tests/specs/run/import_map_parent_dir/run.out new file mode 100644 index 0000000000000..1830c3186d066 --- /dev/null +++ b/tests/specs/run/import_map_parent_dir/run.out @@ -0,0 +1 @@ +Check file:///[WILDLINE]/main.ts diff --git a/tests/specs/run/import_map_parent_dir/shared/models.ts b/tests/specs/run/import_map_parent_dir/shared/models.ts new file mode 100644 index 0000000000000..990777fbb3273 --- /dev/null +++ b/tests/specs/run/import_map_parent_dir/shared/models.ts @@ -0,0 +1 @@ +export class Model {} diff --git a/tests/specs/run/import_map_parent_dir/sub/deno.json b/tests/specs/run/import_map_parent_dir/sub/deno.json new file mode 100644 index 0000000000000..cfc6886ff7529 --- /dev/null +++ b/tests/specs/run/import_map_parent_dir/sub/deno.json @@ -0,0 +1,3 @@ +{ + "importMap": "../import_map.json" +} diff --git a/tests/specs/run/import_map_parent_dir/sub/main.ts b/tests/specs/run/import_map_parent_dir/sub/main.ts new file mode 100644 index 0000000000000..b189095c389f8 --- /dev/null +++ b/tests/specs/run/import_map_parent_dir/sub/main.ts @@ -0,0 +1 @@ +import "~/shared/models.ts"; diff --git a/tests/specs/run/no_deno_json/__test__.jsonc b/tests/specs/run/no_deno_json/__test__.jsonc new file mode 100644 index 0000000000000..67867f023373e --- /dev/null +++ b/tests/specs/run/no_deno_json/__test__.jsonc @@ -0,0 +1,36 @@ +{ + "tempDir": true, + "steps": [{ + // --no-config + "args": "run -L debug -A --no-config noconfig.ts", + "output": "noconfig.out", + "cwd": "code" + }, { + // --no-npm + "args": "run -L debug -A --no-npm noconfig.ts", + "output": "noconfig.out", + "cwd": "code" + }, { + // not auto-discovered with env var + "args": "run -L debug -A noconfig.ts", + "output": "noconfig.out", + "cwd": "code", + "envs": { + "DENO_NO_PACKAGE_JSON": "1" + } + }, { + // this should not use --quiet because we should ensure no package.json install occurs + "args": "run -A no_package_json_imports.ts", + "output": "no_package_json_imports.out", + "cwd": "code" + }, { + // auto-discovered node_modules relative package.json + "args": "run -A main.js", + "output": "code/sub_dir/main.out", + "cwd": "code/sub_dir" + }, { + // auto-discovered for local script arg + "args": "run -L debug -A code/main.ts", // notice this is not in the sub dir + "output": "main.out" + }] +} diff --git a/tests/testdata/run/with_package_json/no_deno_json/main.ts b/tests/specs/run/no_deno_json/code/main.ts similarity index 100% rename from tests/testdata/run/with_package_json/no_deno_json/main.ts rename to tests/specs/run/no_deno_json/code/main.ts diff --git a/tests/testdata/run/with_package_json/no_deno_json/no_package_json_imports.ts b/tests/specs/run/no_deno_json/code/no_package_json_imports.ts similarity index 100% rename from tests/testdata/run/with_package_json/no_deno_json/no_package_json_imports.ts rename to tests/specs/run/no_deno_json/code/no_package_json_imports.ts diff --git a/tests/testdata/run/with_package_json/no_deno_json/noconfig.ts b/tests/specs/run/no_deno_json/code/noconfig.ts similarity index 78% rename from tests/testdata/run/with_package_json/no_deno_json/noconfig.ts rename to tests/specs/run/no_deno_json/code/noconfig.ts index 73b348fbc2350..e6f77f92b7564 100644 --- a/tests/testdata/run/with_package_json/no_deno_json/noconfig.ts +++ b/tests/specs/run/no_deno_json/code/noconfig.ts @@ -1,6 +1,6 @@ // ensure the cwd is this directory const cwd = Deno.cwd(); -if (!cwd.endsWith("no_deno_json")) { +if (!cwd.endsWith("code")) { console.log(cwd); throw "FAIL"; } else { diff --git a/tests/testdata/run/with_package_json/no_deno_json/package.json b/tests/specs/run/no_deno_json/code/package.json similarity index 100% rename from tests/testdata/run/with_package_json/no_deno_json/package.json rename to tests/specs/run/no_deno_json/code/package.json diff --git a/tests/testdata/run/with_package_json/no_deno_json/sub_dir/main.js b/tests/specs/run/no_deno_json/code/sub_dir/main.js similarity index 100% rename from tests/testdata/run/with_package_json/no_deno_json/sub_dir/main.js rename to tests/specs/run/no_deno_json/code/sub_dir/main.js diff --git a/tests/testdata/run/with_package_json/no_deno_json/sub_dir/main.out b/tests/specs/run/no_deno_json/code/sub_dir/main.out similarity index 100% rename from tests/testdata/run/with_package_json/no_deno_json/sub_dir/main.out rename to tests/specs/run/no_deno_json/code/sub_dir/main.out diff --git a/tests/specs/run/no_deno_json/main.out b/tests/specs/run/no_deno_json/main.out new file mode 100644 index 0000000000000..92f5de748b042 --- /dev/null +++ b/tests/specs/run/no_deno_json/main.out @@ -0,0 +1,4 @@ +[WILDCARD]package.json file found at '[WILDCARD]code[WILDCHAR]package.json' +[WILDCARD] +ok +[Function (anonymous)] Chalk [WILDCARD] diff --git a/tests/testdata/run/with_package_json/no_deno_json/no_package_json_imports.out b/tests/specs/run/no_deno_json/no_package_json_imports.out similarity index 100% rename from tests/testdata/run/with_package_json/no_deno_json/no_package_json_imports.out rename to tests/specs/run/no_deno_json/no_package_json_imports.out diff --git a/tests/testdata/run/with_package_json/no_deno_json/noconfig.out b/tests/specs/run/no_deno_json/noconfig.out similarity index 100% rename from tests/testdata/run/with_package_json/no_deno_json/noconfig.out rename to tests/specs/run/no_deno_json/noconfig.out diff --git a/tests/specs/schema.json b/tests/specs/schema.json index 8b21ab32cee50..94e069400b979 100644 --- a/tests/specs/schema.json +++ b/tests/specs/schema.json @@ -36,6 +36,18 @@ "type": "string" } }, + "flaky": { + "type": "boolean" + }, + "if": { + "type": "string", + "examples": [ + "mac", + "linux", + "windows", + "unix" + ] + }, "output": { "type": "string" }, diff --git a/tests/specs/test/include_relative_pattern_dot_slash/__test__.jsonc b/tests/specs/test/include_relative_pattern_dot_slash/__test__.jsonc new file mode 100644 index 0000000000000..335c9ccd68d07 --- /dev/null +++ b/tests/specs/test/include_relative_pattern_dot_slash/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "test", + "output": "output.out" +} diff --git a/tests/testdata/test/relative_pattern_dot_slash/deno.json b/tests/specs/test/include_relative_pattern_dot_slash/deno.json similarity index 100% rename from tests/testdata/test/relative_pattern_dot_slash/deno.json rename to tests/specs/test/include_relative_pattern_dot_slash/deno.json diff --git a/tests/testdata/test/relative_pattern_dot_slash/output.out b/tests/specs/test/include_relative_pattern_dot_slash/output.out similarity index 100% rename from tests/testdata/test/relative_pattern_dot_slash/output.out rename to tests/specs/test/include_relative_pattern_dot_slash/output.out diff --git a/tests/testdata/test/relative_pattern_dot_slash/test/add.mjs b/tests/specs/test/include_relative_pattern_dot_slash/test/add.mjs similarity index 100% rename from tests/testdata/test/relative_pattern_dot_slash/test/add.mjs rename to tests/specs/test/include_relative_pattern_dot_slash/test/add.mjs diff --git a/tests/testdata/test/relative_pattern_dot_slash/test/add.test.mjs b/tests/specs/test/include_relative_pattern_dot_slash/test/add.test.mjs similarity index 100% rename from tests/testdata/test/relative_pattern_dot_slash/test/add.test.mjs rename to tests/specs/test/include_relative_pattern_dot_slash/test/add.test.mjs diff --git a/tests/testdata/check/types_dts/main.out b/tests/testdata/check/types_dts/main.out deleted file mode 100644 index c769989e3c5ce..0000000000000 --- a/tests/testdata/check/types_dts/main.out +++ /dev/null @@ -1 +0,0 @@ -Check file:///[WILDCARD]/check/types_dts/main.ts diff --git a/tests/testdata/jsr/registry/@denotest/deps/1.0.0/mod.ts b/tests/testdata/jsr/registry/@denotest/deps/1.0.0/mod.ts index 4ba0d8aaf0946..2751698acc61d 100644 --- a/tests/testdata/jsr/registry/@denotest/deps/1.0.0/mod.ts +++ b/tests/testdata/jsr/registry/@denotest/deps/1.0.0/mod.ts @@ -1,5 +1,5 @@ -import { Other } from "jsr:@denotest/module_graph@1/other"; -import version from "jsr:@denotest/no_module_graph@^0.1"; +import { Other } from "jsr:@denotest/module-graph@1/other"; +import version from "jsr:@denotest/no-module-graph@^0.1"; export default { version, diff --git a/tests/testdata/jsr/registry/@denotest/deps/1.0.0_meta.json b/tests/testdata/jsr/registry/@denotest/deps/1.0.0_meta.json index 914e4bd73c024..814099af06216 100644 --- a/tests/testdata/jsr/registry/@denotest/deps/1.0.0_meta.json +++ b/tests/testdata/jsr/registry/@denotest/deps/1.0.0_meta.json @@ -8,13 +8,13 @@ "type": "static", "kind": "import", "range": [[0, 0], [0, 59]], - "specifier": "jsr:@denotest/module_graph@1/other", + "specifier": "jsr:@denotest/module-graph@1/other", "specifierRange": [[0, 22], [0, 58]] }, { "type": "static", "kind": "import", "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]] }] } diff --git a/tests/testdata/jsr/registry/@denotest/module_graph/1.4.0/mod.ts b/tests/testdata/jsr/registry/@denotest/module-graph/1.4.0/mod.ts similarity index 100% rename from tests/testdata/jsr/registry/@denotest/module_graph/1.4.0/mod.ts rename to tests/testdata/jsr/registry/@denotest/module-graph/1.4.0/mod.ts diff --git a/tests/testdata/jsr/registry/@denotest/module_graph/1.4.0/other.ts b/tests/testdata/jsr/registry/@denotest/module-graph/1.4.0/other.ts similarity index 100% rename from tests/testdata/jsr/registry/@denotest/module_graph/1.4.0/other.ts rename to tests/testdata/jsr/registry/@denotest/module-graph/1.4.0/other.ts diff --git a/tests/testdata/jsr/registry/@denotest/module_graph/1.4.0_meta.json b/tests/testdata/jsr/registry/@denotest/module-graph/1.4.0_meta.json similarity index 100% rename from tests/testdata/jsr/registry/@denotest/module_graph/1.4.0_meta.json rename to tests/testdata/jsr/registry/@denotest/module-graph/1.4.0_meta.json diff --git a/tests/testdata/jsr/registry/@denotest/module_graph/meta.json b/tests/testdata/jsr/registry/@denotest/module-graph/meta.json similarity index 100% rename from tests/testdata/jsr/registry/@denotest/module_graph/meta.json rename to tests/testdata/jsr/registry/@denotest/module-graph/meta.json diff --git a/tests/testdata/jsr/registry/@denotest/module-graph2/1.4.0/mod.ts b/tests/testdata/jsr/registry/@denotest/module-graph2/1.4.0/mod.ts new file mode 100644 index 0000000000000..cb3c4a5e02fd1 --- /dev/null +++ b/tests/testdata/jsr/registry/@denotest/module-graph2/1.4.0/mod.ts @@ -0,0 +1,5 @@ +import { Other } from "./other.ts"; + +export class Test { + other = new Other(); +} diff --git a/tests/testdata/jsr/registry/@denotest/module-graph2/1.4.0/other.ts b/tests/testdata/jsr/registry/@denotest/module-graph2/1.4.0/other.ts new file mode 100644 index 0000000000000..57e436cf889b8 --- /dev/null +++ b/tests/testdata/jsr/registry/@denotest/module-graph2/1.4.0/other.ts @@ -0,0 +1,2 @@ +export class Other { +} diff --git a/tests/testdata/jsr/registry/@denotest/module-graph2/1.4.0_meta.json b/tests/testdata/jsr/registry/@denotest/module-graph2/1.4.0_meta.json new file mode 100644 index 0000000000000..ce1d3782d2e3f --- /dev/null +++ b/tests/testdata/jsr/registry/@denotest/module-graph2/1.4.0_meta.json @@ -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": {} + } +} diff --git a/tests/testdata/jsr/registry/@denotest/module-graph2/meta.json b/tests/testdata/jsr/registry/@denotest/module-graph2/meta.json new file mode 100644 index 0000000000000..9a450c08b46c9 --- /dev/null +++ b/tests/testdata/jsr/registry/@denotest/module-graph2/meta.json @@ -0,0 +1,6 @@ +{ + "versions": { + "1.0.0": {}, + "1.4.0": {} + } +} diff --git a/tests/testdata/jsr/registry/@denotest/no_module_graph/0.1.0/TestClass.ts b/tests/testdata/jsr/registry/@denotest/no-module-graph/0.1.0/TestClass.ts similarity index 100% rename from tests/testdata/jsr/registry/@denotest/no_module_graph/0.1.0/TestClass.ts rename to tests/testdata/jsr/registry/@denotest/no-module-graph/0.1.0/TestClass.ts diff --git a/tests/testdata/jsr/registry/@denotest/no_module_graph/0.1.0/mod.ts b/tests/testdata/jsr/registry/@denotest/no-module-graph/0.1.0/mod.ts similarity index 100% rename from tests/testdata/jsr/registry/@denotest/no_module_graph/0.1.0/mod.ts rename to tests/testdata/jsr/registry/@denotest/no-module-graph/0.1.0/mod.ts diff --git a/tests/testdata/jsr/registry/@denotest/no_module_graph/0.1.0_meta.json b/tests/testdata/jsr/registry/@denotest/no-module-graph/0.1.0_meta.json similarity index 100% rename from tests/testdata/jsr/registry/@denotest/no_module_graph/0.1.0_meta.json rename to tests/testdata/jsr/registry/@denotest/no-module-graph/0.1.0_meta.json diff --git a/tests/testdata/jsr/registry/@denotest/no_module_graph/0.1.1/TestClass.ts b/tests/testdata/jsr/registry/@denotest/no-module-graph/0.1.1/TestClass.ts similarity index 100% rename from tests/testdata/jsr/registry/@denotest/no_module_graph/0.1.1/TestClass.ts rename to tests/testdata/jsr/registry/@denotest/no-module-graph/0.1.1/TestClass.ts diff --git a/tests/testdata/jsr/registry/@denotest/no_module_graph/0.1.1/mod.ts b/tests/testdata/jsr/registry/@denotest/no-module-graph/0.1.1/mod.ts similarity index 100% rename from tests/testdata/jsr/registry/@denotest/no_module_graph/0.1.1/mod.ts rename to tests/testdata/jsr/registry/@denotest/no-module-graph/0.1.1/mod.ts diff --git a/tests/testdata/jsr/registry/@denotest/no_module_graph/0.1.1_meta.json b/tests/testdata/jsr/registry/@denotest/no-module-graph/0.1.1_meta.json similarity index 100% rename from tests/testdata/jsr/registry/@denotest/no_module_graph/0.1.1_meta.json rename to tests/testdata/jsr/registry/@denotest/no-module-graph/0.1.1_meta.json diff --git a/tests/testdata/jsr/registry/@denotest/no_module_graph/0.2.0/TestClass.ts b/tests/testdata/jsr/registry/@denotest/no-module-graph/0.2.0/TestClass.ts similarity index 100% rename from tests/testdata/jsr/registry/@denotest/no_module_graph/0.2.0/TestClass.ts rename to tests/testdata/jsr/registry/@denotest/no-module-graph/0.2.0/TestClass.ts diff --git a/tests/testdata/jsr/registry/@denotest/no_module_graph/0.2.0/mod.ts b/tests/testdata/jsr/registry/@denotest/no-module-graph/0.2.0/mod.ts similarity index 100% rename from tests/testdata/jsr/registry/@denotest/no_module_graph/0.2.0/mod.ts rename to tests/testdata/jsr/registry/@denotest/no-module-graph/0.2.0/mod.ts diff --git a/tests/testdata/jsr/registry/@denotest/no_module_graph/0.2.0_meta.json b/tests/testdata/jsr/registry/@denotest/no-module-graph/0.2.0_meta.json similarity index 100% rename from tests/testdata/jsr/registry/@denotest/no_module_graph/0.2.0_meta.json rename to tests/testdata/jsr/registry/@denotest/no-module-graph/0.2.0_meta.json diff --git a/tests/testdata/jsr/registry/@denotest/no_module_graph/meta.json b/tests/testdata/jsr/registry/@denotest/no-module-graph/meta.json similarity index 100% rename from tests/testdata/jsr/registry/@denotest/no_module_graph/meta.json rename to tests/testdata/jsr/registry/@denotest/no-module-graph/meta.json diff --git a/tests/testdata/jsr/registry/@std/path/0.220.1/_common/assert_path.ts b/tests/testdata/jsr/registry/@std/path/0.220.1/_common/assert_path.ts new file mode 100644 index 0000000000000..7033edcd1a79b --- /dev/null +++ b/tests/testdata/jsr/registry/@std/path/0.220.1/_common/assert_path.ts @@ -0,0 +1,10 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +// Copyright the Browserify authors. MIT License. + +export function assertPath(path?: string) { + if (typeof path !== "string") { + throw new TypeError( + `Path must be a string. Received ${JSON.stringify(path)}`, + ); + } +} diff --git a/tests/testdata/jsr/registry/@std/path/0.220.1/_common/constants.ts b/tests/testdata/jsr/registry/@std/path/0.220.1/_common/constants.ts new file mode 100644 index 0000000000000..9bfd411b668de --- /dev/null +++ b/tests/testdata/jsr/registry/@std/path/0.220.1/_common/constants.ts @@ -0,0 +1,49 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +// Copyright the Browserify authors. MIT License. +// Ported from https://github.com/browserify/path-browserify/ +// This module is browser compatible. + +// Alphabet chars. +export const CHAR_UPPERCASE_A = 65; /* A */ +export const CHAR_LOWERCASE_A = 97; /* a */ +export const CHAR_UPPERCASE_Z = 90; /* Z */ +export const CHAR_LOWERCASE_Z = 122; /* z */ + +// Non-alphabetic chars. +export const CHAR_DOT = 46; /* . */ +export const CHAR_FORWARD_SLASH = 47; /* / */ +export const CHAR_BACKWARD_SLASH = 92; /* \ */ +export const CHAR_VERTICAL_LINE = 124; /* | */ +export const CHAR_COLON = 58; /* : */ +export const CHAR_QUESTION_MARK = 63; /* ? */ +export const CHAR_UNDERSCORE = 95; /* _ */ +export const CHAR_LINE_FEED = 10; /* \n */ +export const CHAR_CARRIAGE_RETURN = 13; /* \r */ +export const CHAR_TAB = 9; /* \t */ +export const CHAR_FORM_FEED = 12; /* \f */ +export const CHAR_EXCLAMATION_MARK = 33; /* ! */ +export const CHAR_HASH = 35; /* # */ +export const CHAR_SPACE = 32; /* */ +export const CHAR_NO_BREAK_SPACE = 160; /* \u00A0 */ +export const CHAR_ZERO_WIDTH_NOBREAK_SPACE = 65279; /* \uFEFF */ +export const CHAR_LEFT_SQUARE_BRACKET = 91; /* [ */ +export const CHAR_RIGHT_SQUARE_BRACKET = 93; /* ] */ +export const CHAR_LEFT_ANGLE_BRACKET = 60; /* < */ +export const CHAR_RIGHT_ANGLE_BRACKET = 62; /* > */ +export const CHAR_LEFT_CURLY_BRACKET = 123; /* { */ +export const CHAR_RIGHT_CURLY_BRACKET = 125; /* } */ +export const CHAR_HYPHEN_MINUS = 45; /* - */ +export const CHAR_PLUS = 43; /* + */ +export const CHAR_DOUBLE_QUOTE = 34; /* " */ +export const CHAR_SINGLE_QUOTE = 39; /* ' */ +export const CHAR_PERCENT = 37; /* % */ +export const CHAR_SEMICOLON = 59; /* ; */ +export const CHAR_CIRCUMFLEX_ACCENT = 94; /* ^ */ +export const CHAR_GRAVE_ACCENT = 96; /* ` */ +export const CHAR_AT = 64; /* @ */ +export const CHAR_AMPERSAND = 38; /* & */ +export const CHAR_EQUAL = 61; /* = */ + +// Digits +export const CHAR_0 = 48; /* 0 */ +export const CHAR_9 = 57; /* 9 */ diff --git a/tests/testdata/jsr/registry/@std/path/0.220.1/_common/normalize.ts b/tests/testdata/jsr/registry/@std/path/0.220.1/_common/normalize.ts new file mode 100644 index 0000000000000..3a1a1628453f5 --- /dev/null +++ b/tests/testdata/jsr/registry/@std/path/0.220.1/_common/normalize.ts @@ -0,0 +1,9 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +// This module is browser compatible. + +import { assertPath } from "./assert_path.ts"; + +export function assertArg(path: string) { + assertPath(path); + if (path.length === 0) return "."; +} diff --git a/tests/testdata/jsr/registry/@std/path/0.220.1/_common/normalize_string.ts b/tests/testdata/jsr/registry/@std/path/0.220.1/_common/normalize_string.ts new file mode 100644 index 0000000000000..d8f0e090a6ed2 --- /dev/null +++ b/tests/testdata/jsr/registry/@std/path/0.220.1/_common/normalize_string.ts @@ -0,0 +1,74 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +// Copyright the Browserify authors. MIT License. +// Ported from https://github.com/browserify/path-browserify/ +// This module is browser compatible. + +import { CHAR_DOT, CHAR_FORWARD_SLASH } from "./constants.ts"; + +// Resolves . and .. elements in a path with directory names +export function normalizeString( + path: string, + allowAboveRoot: boolean, + separator: string, + isPathSeparator: (code: number) => boolean, +): string { + let res = ""; + let lastSegmentLength = 0; + let lastSlash = -1; + let dots = 0; + let code: number | undefined; + for (let i = 0; i <= path.length; ++i) { + if (i < path.length) code = path.charCodeAt(i); + else if (isPathSeparator(code!)) break; + else code = CHAR_FORWARD_SLASH; + + if (isPathSeparator(code!)) { + if (lastSlash === i - 1 || dots === 1) { + // NOOP + } else if (lastSlash !== i - 1 && dots === 2) { + if ( + res.length < 2 || + lastSegmentLength !== 2 || + res.charCodeAt(res.length - 1) !== CHAR_DOT || + res.charCodeAt(res.length - 2) !== CHAR_DOT + ) { + if (res.length > 2) { + const lastSlashIndex = res.lastIndexOf(separator); + if (lastSlashIndex === -1) { + res = ""; + lastSegmentLength = 0; + } else { + res = res.slice(0, lastSlashIndex); + lastSegmentLength = res.length - 1 - res.lastIndexOf(separator); + } + lastSlash = i; + dots = 0; + continue; + } else if (res.length === 2 || res.length === 1) { + res = ""; + lastSegmentLength = 0; + lastSlash = i; + dots = 0; + continue; + } + } + if (allowAboveRoot) { + if (res.length > 0) res += `${separator}..`; + else res = ".."; + lastSegmentLength = 2; + } + } else { + if (res.length > 0) res += separator + path.slice(lastSlash + 1, i); + else res = path.slice(lastSlash + 1, i); + lastSegmentLength = i - lastSlash - 1; + } + lastSlash = i; + dots = 0; + } else if (code === CHAR_DOT && dots !== -1) { + ++dots; + } else { + dots = -1; + } + } + return res; +} diff --git a/tests/testdata/jsr/registry/@std/path/0.220.1/posix/_util.ts b/tests/testdata/jsr/registry/@std/path/0.220.1/posix/_util.ts new file mode 100644 index 0000000000000..b446155df5b3f --- /dev/null +++ b/tests/testdata/jsr/registry/@std/path/0.220.1/posix/_util.ts @@ -0,0 +1,10 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +// Copyright the Browserify authors. MIT License. +// Ported from https://github.com/browserify/path-browserify/ +// This module is browser compatible. + +import { CHAR_FORWARD_SLASH } from "../_common/constants.ts"; + +export function isPosixPathSeparator(code: number): boolean { + return code === CHAR_FORWARD_SLASH; +} diff --git a/tests/testdata/jsr/registry/@std/path/0.220.1/posix/join.ts b/tests/testdata/jsr/registry/@std/path/0.220.1/posix/join.ts new file mode 100644 index 0000000000000..625762ab97ace --- /dev/null +++ b/tests/testdata/jsr/registry/@std/path/0.220.1/posix/join.ts @@ -0,0 +1,25 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +// This module is browser compatible. + +import { assertPath } from "../_common/assert_path.ts"; +import { normalize } from "./normalize.ts"; + +/** + * Join all given a sequence of `paths`,then normalizes the resulting path. + * @param paths to be joined and normalized + */ +export function join(...paths: string[]): string { + if (paths.length === 0) return "."; + + let joined: string | undefined; + for (let i = 0; i < paths.length; ++i) { + const path = paths[i]!; + assertPath(path); + if (path.length > 0) { + if (!joined) joined = path; + else joined += `/${path}`; + } + } + if (!joined) return "."; + return normalize(joined); +} diff --git a/tests/testdata/jsr/registry/@std/path/0.220.1/posix/normalize.ts b/tests/testdata/jsr/registry/@std/path/0.220.1/posix/normalize.ts new file mode 100644 index 0000000000000..8e88ad254b036 --- /dev/null +++ b/tests/testdata/jsr/registry/@std/path/0.220.1/posix/normalize.ts @@ -0,0 +1,30 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +// This module is browser compatible. + +import { assertArg } from "../_common/normalize.ts"; +import { normalizeString } from "../_common/normalize_string.ts"; +import { isPosixPathSeparator } from "./_util.ts"; + +/** + * Normalize the `path`, resolving `'..'` and `'.'` segments. + * Note that resolving these segments does not necessarily mean that all will be eliminated. + * A `'..'` at the top-level will be preserved, and an empty path is canonically `'.'`. + * @param path to be normalized + */ +export function normalize(path: string): string { + assertArg(path); + + const isAbsolute = isPosixPathSeparator(path.charCodeAt(0)); + const trailingSeparator = isPosixPathSeparator( + path.charCodeAt(path.length - 1), + ); + + // Normalize the path + path = normalizeString(path, !isAbsolute, "/", isPosixPathSeparator); + + if (path.length === 0 && !isAbsolute) path = "."; + if (path.length > 0 && trailingSeparator) path += "/"; + + if (isAbsolute) return `/${path}`; + return path; +} diff --git a/tests/testdata/jsr/registry/@std/path/0.220.1_meta.json b/tests/testdata/jsr/registry/@std/path/0.220.1_meta.json new file mode 100644 index 0000000000000..2a2f43f96d885 --- /dev/null +++ b/tests/testdata/jsr/registry/@std/path/0.220.1_meta.json @@ -0,0 +1,64 @@ +{ + "exports": { + ".": "./mod.ts", + "./basename": "./basename.ts", + "./common": "./common.ts", + "./constants": "./constants.ts", + "./dirname": "./dirname.ts", + "./extname": "./extname.ts", + "./format": "./format.ts", + "./from_file_url": "./from_file_url.ts", + "./glob_to_regexp": "./glob_to_regexp.ts", + "./is_absolute": "./is_absolute.ts", + "./is_glob": "./is_glob.ts", + "./join": "./join.ts", + "./join_globs": "./join_globs.ts", + "./normalize": "./normalize.ts", + "./normalize_glob": "./normalize_glob.ts", + "./parse": "./parse.ts", + "./posix": "./posix/mod.ts", + "./posix/basename": "./posix/basename.ts", + "./posix/common": "./posix/common.ts", + "./posix/constants": "./posix/constants.ts", + "./posix/dirname": "./posix/dirname.ts", + "./posix/extname": "./posix/extname.ts", + "./posix/format": "./posix/format.ts", + "./posix/from_file_url": "./posix/from_file_url.ts", + "./posix/glob_to_regexp": "./posix/glob_to_regexp.ts", + "./posix/is_absolute": "./posix/is_absolute.ts", + "./posix/is_glob": "./posix/is_glob.ts", + "./posix/join": "./posix/join.ts", + "./posix/join_globs": "./posix/join_globs.ts", + "./posix/normalize": "./posix/normalize.ts", + "./posix/normalize_glob": "./posix/normalize_glob.ts", + "./posix/parse": "./posix/parse.ts", + "./posix/relative": "./posix/relative.ts", + "./posix/resolve": "./posix/resolve.ts", + "./posix/to_file_url": "./posix/to_file_url.ts", + "./posix/to_namespaced_path": "./posix/to_namespaced_path.ts", + "./relative": "./relative.ts", + "./resolve": "./resolve.ts", + "./to_file_url": "./to_file_url.ts", + "./to_namespaced_path": "./to_namespaced_path.ts", + "./windows": "./windows/mod.ts", + "./windows/basename": "./windows/basename.ts", + "./windows/common": "./windows/common.ts", + "./windows/constants": "./windows/constants.ts", + "./windows/dirname": "./windows/dirname.ts", + "./windows/extname": "./windows/extname.ts", + "./windows/format": "./windows/format.ts", + "./windows/from_file_url": "./windows/from_file_url.ts", + "./windows/glob_to_regexp": "./windows/glob_to_regexp.ts", + "./windows/is_absolute": "./windows/is_absolute.ts", + "./windows/is_glob": "./windows/is_glob.ts", + "./windows/join": "./windows/join.ts", + "./windows/join_globs": "./windows/join_globs.ts", + "./windows/normalize": "./windows/normalize.ts", + "./windows/normalize_glob": "./windows/normalize_glob.ts", + "./windows/parse": "./windows/parse.ts", + "./windows/relative": "./windows/relative.ts", + "./windows/resolve": "./windows/resolve.ts", + "./windows/to_file_url": "./windows/to_file_url.ts", + "./windows/to_namespaced_path": "./windows/to_namespaced_path.ts" + } +} diff --git a/tests/testdata/jsr/registry/@std/path/meta.json b/tests/testdata/jsr/registry/@std/path/meta.json new file mode 100644 index 0000000000000..89a4e07f91f02 --- /dev/null +++ b/tests/testdata/jsr/registry/@std/path/meta.json @@ -0,0 +1,8 @@ +{ + "scope": "std", + "name": "path", + "latest": "0.220.1", + "versions": { + "0.220.1": {} + } +} diff --git a/tests/testdata/jsr/registry/@std/url/0.220.1/join.ts b/tests/testdata/jsr/registry/@std/url/0.220.1/join.ts new file mode 100644 index 0000000000000..158994ad3ace8 --- /dev/null +++ b/tests/testdata/jsr/registry/@std/url/0.220.1/join.ts @@ -0,0 +1,28 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +// This module is browser compatible. + +import { join as posixJoin } from "jsr:/@std/path@^0.220.1/posix/join"; + +/** + * Join a base `URL` and a series of `paths`, then normalizes the resulting URL. + * + * @example + * ```ts + * import { join } from "@std/url/join"; + * + * console.log(join("https://deno.land/", "std", "path", "mod.ts").href); + * // Outputs: "https://deno.land/std/path/mod.ts" + * + * console.log(join("https://deno.land", "//std", "path/", "/mod.ts").href); + * // Outputs: "https://deno.land/path/mod.ts" + * ``` + * + * @param url the base URL to be joined with the paths and normalized + * @param paths array of path segments to be joined to the base URL + * @returns a complete URL string containing the base URL joined with the paths + */ +export function join(url: string | URL, ...paths: string[]): URL { + url = new URL(url); + url.pathname = posixJoin(url.pathname, ...paths); + return url; +} diff --git a/tests/testdata/jsr/registry/@std/url/0.220.1/normalize.ts b/tests/testdata/jsr/registry/@std/url/0.220.1/normalize.ts new file mode 100644 index 0000000000000..dc23057019d53 --- /dev/null +++ b/tests/testdata/jsr/registry/@std/url/0.220.1/normalize.ts @@ -0,0 +1,28 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +// This module is browser compatible. + +import { normalize as posixNormalize } from "jsr:/@std/path@^0.220.1/posix/normalize"; + +/** + * Normalize the `URL`, resolving `'..'` and `'.'` segments and multiple + * `'/'`s into `'//'` after protocol and remaining into `'/'`. + * + * @example + * ```ts + * import { normalize } from "@std/url/normalize"; + * + * console.log(normalize("https:///deno.land///std//assert//.//mod.ts").href); + * // Outputs: "https://deno.land/std/path/mod.ts" + * + * console.log(normalize("https://deno.land/std/assert/../async/retry.ts").href); + * // Outputs: "https://deno.land/std/async/retry.ts" + * ``` + * + * @param url to be normalized + * @returns normalized URL + */ +export function normalize(url: string | URL): URL { + url = new URL(url); + url.pathname = posixNormalize(url.pathname); + return url; +} diff --git a/tests/testdata/jsr/registry/@std/url/0.220.1_meta.json b/tests/testdata/jsr/registry/@std/url/0.220.1_meta.json new file mode 100644 index 0000000000000..2a92cc6511cf8 --- /dev/null +++ b/tests/testdata/jsr/registry/@std/url/0.220.1_meta.json @@ -0,0 +1,10 @@ +{ + "exports": { + ".": "./mod.ts", + "./basename": "./basename.ts", + "./dirname": "./dirname.ts", + "./extname": "./extname.ts", + "./join": "./join.ts", + "./normalize": "./normalize.ts" + } +} diff --git a/tests/testdata/jsr/registry/@std/url/meta.json b/tests/testdata/jsr/registry/@std/url/meta.json new file mode 100644 index 0000000000000..3ae97c991db8b --- /dev/null +++ b/tests/testdata/jsr/registry/@std/url/meta.json @@ -0,0 +1,8 @@ +{ + "scope": "std", + "name": "url", + "latest": "0.220.1", + "versions": { + "0.220.1": {} + } +} diff --git a/tests/testdata/lockfile/basic/doc.nolock.out b/tests/testdata/lockfile/basic/doc.nolock.out deleted file mode 100644 index e2d66c027b7eb..0000000000000 --- a/tests/testdata/lockfile/basic/doc.nolock.out +++ /dev/null @@ -1 +0,0 @@ -Download http://localhost:4545/lockfile/basic/mod.ts diff --git a/tests/testdata/lockfile/basic/info.nolock.out b/tests/testdata/lockfile/basic/info.nolock.out deleted file mode 100644 index d1ef82e49f09f..0000000000000 --- a/tests/testdata/lockfile/basic/info.nolock.out +++ /dev/null @@ -1,8 +0,0 @@ -Download http://localhost:4545/lockfile/basic/mod.ts -local: [WILDCARD]main.ts -type: TypeScript -dependencies: 1 unique -size: [WILDCARD] - -file:///[WILDCARD]/main.ts ([WILDCARD]) -└── http://localhost:4545/lockfile/basic/mod.ts ([WILDCARD]) diff --git a/tests/testdata/publish/bare_node_builtins.out b/tests/testdata/publish/bare_node_builtins.out deleted file mode 100644 index c2cf2e2af4025..0000000000000 --- a/tests/testdata/publish/bare_node_builtins.out +++ /dev/null @@ -1,11 +0,0 @@ -Warning: Resolving "url" as "node:url" at file:///[WILDCARD]/publish/bare_node_builtins/mod.ts:1:22. If you want to use a built-in Node module, add a "node:" prefix. -Warning: Resolving "url" as "node:url" at file:///[WILDCARD]/publish/bare_node_builtins/mod.ts:1:22. If you want to use a built-in Node module, add a "node:" prefix. -Download http://localhost:4545/npm/registry/@types/node -Download http://localhost:4545/npm/registry/@types/node/node-18.16.19.tgz -Check file:///[WILDCARD]/publish/bare_node_builtins/mod.ts -Checking for slow types in the public API... -Check file:///[WILDCARD]/publish/bare_node_builtins/mod.ts -Simulating publish of @foo/bar@1.0.0 with files: - file:///[WILDCARD]/publish/bare_node_builtins/deno.json (87B) - file:///[WILDCARD]/publish/bare_node_builtins/mod.ts (121B) -Warning Aborting due to --dry-run diff --git a/tests/testdata/publish/bare_node_builtins_no_warnings.out b/tests/testdata/publish/bare_node_builtins_no_warnings.out deleted file mode 100644 index d8d43eff6855f..0000000000000 --- a/tests/testdata/publish/bare_node_builtins_no_warnings.out +++ /dev/null @@ -1,9 +0,0 @@ -Download http://localhost:4545/npm/registry/@types/node -Download http://localhost:4545/npm/registry/@types/node/node-18.16.19.tgz -Check file:///[WILDCARD]/publish/bare_node_builtins/mod.ts -Checking for slow types in the public API... -Check file:///[WILDCARD]/publish/bare_node_builtins/mod.ts -Simulating publish of @foo/bar@1.0.0 with files: - file:///[WILDCARD]/publish/bare_node_builtins/deno.json (87B) - file:///[WILDCARD]/publish/bare_node_builtins/mod.ts (121B) -Warning Aborting due to --dry-run diff --git a/tests/testdata/publish/sloppy_imports.out b/tests/testdata/publish/sloppy_imports.out deleted file mode 100644 index 342eccdc3e26f..0000000000000 --- a/tests/testdata/publish/sloppy_imports.out +++ /dev/null @@ -1,10 +0,0 @@ -Warning Sloppy module resolution (hint: specify path to index.ts file in directory instead) - at file:///[WILDCARD]/publish/sloppy_imports/mod.ts:1:20 -Check file:///[WILDCARD]/publish/sloppy_imports/mod.ts -Checking for slow types in the public API... -Check file:///[WILDCARD]/publish/sloppy_imports/mod.ts -Simulating publish of @foo/bar@1.0.0 with files: - file:///[WILDCARD]/publish/sloppy_imports/b/index.ts (27B) - file:///[WILDCARD]/publish/sloppy_imports/deno.json (87B) - file:///[WILDCARD]/publish/sloppy_imports/mod.ts (35B) -Warning Aborting due to --dry-run diff --git a/tests/testdata/publish/sloppy_imports_no_warnings.out b/tests/testdata/publish/sloppy_imports_no_warnings.out deleted file mode 100644 index 8659010b7cf12..0000000000000 --- a/tests/testdata/publish/sloppy_imports_no_warnings.out +++ /dev/null @@ -1,8 +0,0 @@ -Check file:///[WILDCARD]/publish/sloppy_imports/mod.ts -Checking for slow types in the public API... -Check file:///[WILDCARD]/publish/sloppy_imports/mod.ts -Simulating publish of @foo/bar@1.0.0 with files: - file:///[WILDCARD]/publish/sloppy_imports/b/index.ts (27B) - file:///[WILDCARD]/publish/sloppy_imports/deno.json (87B) - file:///[WILDCARD]/publish/sloppy_imports/mod.ts (35B) -Warning Aborting due to --dry-run diff --git a/tests/testdata/publish/symlink/symlink b/tests/testdata/publish/symlink/symlink deleted file mode 120000 index 0df9bcd04e336..0000000000000 --- a/tests/testdata/publish/symlink/symlink +++ /dev/null @@ -1 +0,0 @@ -./mod.ts \ No newline at end of file diff --git a/tests/testdata/run/node_process_stdin_unref_with_pty.js b/tests/testdata/run/node_process_stdin_unref_with_pty.js new file mode 100644 index 0000000000000..e8630498107d9 --- /dev/null +++ b/tests/testdata/run/node_process_stdin_unref_with_pty.js @@ -0,0 +1,14 @@ +import process from "node:process"; +import util from "node:util"; + +console.log("START"); +globalThis.addEventListener("unload", () => console.log("END")); + +const args = util.parseArgs({ options: { unref: { type: "boolean" } } }); + +// call stdin.unref if --unref is passed +if (args.values.unref) { + process.stdin.unref(); +} + +process.stdin.pipe(process.stdout); diff --git a/tests/testdata/run/with_package_json/no_deno_json/main.out b/tests/testdata/run/with_package_json/no_deno_json/main.out deleted file mode 100644 index 402b30ed4ed30..0000000000000 --- a/tests/testdata/run/with_package_json/no_deno_json/main.out +++ /dev/null @@ -1,4 +0,0 @@ -[WILDCARD]package.json file found at '[WILDCARD]with_package_json[WILDCARD]no_deno_json[WILDCARD]package.json' -[WILDCARD] -ok -[Function (anonymous)] Chalk [WILDCARD] diff --git a/tests/unit/serve_test.ts b/tests/unit/serve_test.ts index 8978c4f7e0182..74628ace18034 100644 --- a/tests/unit/serve_test.ts +++ b/tests/unit/serve_test.ts @@ -23,6 +23,7 @@ const { addTrailers, serveHttpOnListener, serveHttpOnConnection, + getCachedAbortSignal, // @ts-expect-error TypeScript (as of 3.7) does not support indexing namespaces by symbol } = Deno[Deno.internal]; @@ -2838,6 +2839,34 @@ for (const delay of ["delay", "nodelay"]) { } } +// Test for the internal implementation detail of cached request signals. Ensure that the request's +// signal is aborted if we try to access it after the request has been completed. +Deno.test( + { permissions: { net: true } }, + async function httpServerSignalCancelled() { + let stashedRequest; + const { finished, abort } = await makeServer((req) => { + // The cache signal is `undefined` because it has not been requested + assertEquals(getCachedAbortSignal(req), undefined); + stashedRequest = req; + return new Response("ok"); + }); + await (await fetch(`http://localhost:${servePort}`)).text(); + abort(); + await finished; + + // `false` is a semaphore for a signal that should be aborted on creation + assertEquals(getCachedAbortSignal(stashedRequest!), false); + // Requesting the signal causes it to be materialized + assert(stashedRequest!.signal.aborted); + // The cached signal is now a full `AbortSignal` + assertEquals( + getCachedAbortSignal(stashedRequest!).constructor, + AbortSignal, + ); + }, +); + Deno.test( { permissions: { net: true } }, async function httpServerCancelFetch() { diff --git a/tests/unit_node/crypto/crypto_key_test.ts b/tests/unit_node/crypto/crypto_key_test.ts index c7c741f3e9c8f..0136015728fbc 100644 --- a/tests/unit_node/crypto/crypto_key_test.ts +++ b/tests/unit_node/crypto/crypto_key_test.ts @@ -15,7 +15,7 @@ import { } from "node:crypto"; import { promisify } from "node:util"; import { Buffer } from "node:buffer"; -import { assertEquals, assertThrows } from "@std/assert/mod.ts"; +import { assert, assertEquals, assertThrows } from "@std/assert/mod.ts"; const RUN_SLOW_TESTS = Deno.env.get("SLOW_TESTS") === "1"; @@ -402,3 +402,16 @@ SogaIHQjE81ZkmNtU5gM5Q== `jEwckJ/d5GkF/8TTm+wllq2JNghG/m2JYJIW7vS8Vms53zCTTNSSegTSoIVoxWymwTPw2dTtZi41Lg0O271/WvEmQhiWD2dnjz6D/0F4eyn+QUhcmGCadDFyfp7+8x1XOppSw2YB8vL5WCL0QDdp3TAa/rWI0Hn4OftHMa6HPvatkGs+8XlQOGCCfd3TLg+t1UROgpgmetjoAM67mlwxXMGGu/Tr/EbXnnINKeB0iuSmD1FCxlrgFuYWDKxd79n2jZ74FrS/zto+bqWSI5uUa4Ar7yvXtek1Cu1OFM6vgdN9Y6Po2UD9+IT04EhU03LUDY5paYOO8yohz7p7kqHvpA==`, ); }); + +Deno.test("generate rsa export public key", async function () { + const { publicKey } = await generateKeyPairAsync("rsa", { + modulusLength: 2048, + }); + + const spkiPem = publicKey.export({ format: "pem", type: "spki" }); + assert(typeof spkiPem === "string"); + assert(spkiPem.startsWith("-----BEGIN PUBLIC KEY-----")); + + const der = publicKey.export({ format: "der", type: "spki" }); + assert(der instanceof Uint8Array); +}); diff --git a/tests/util/server/Cargo.toml b/tests/util/server/Cargo.toml index 641cf59939a99..a321501b85fdf 100644 --- a/tests/util/server/Cargo.toml +++ b/tests/util/server/Cargo.toml @@ -19,7 +19,6 @@ async-stream = "0.3.3" base64.workspace = true bytes.workspace = true console_static_text.workspace = true -deno_tls.workspace = true deno_unsync = "0" denokv_proto.workspace = true fastwebsockets.workspace = true @@ -44,6 +43,8 @@ pretty_assertions.workspace = true prost.workspace = true regex.workspace = true reqwest.workspace = true +rustls-pemfile.workspace = true +rustls-tokio-stream.workspace = true semver = "=1.0.14" serde.workspace = true serde_json.workspace = true diff --git a/tests/util/server/src/builders.rs b/tests/util/server/src/builders.rs index 9490c4c44b4a7..b41c684be3a10 100644 --- a/tests/util/server/src/builders.rs +++ b/tests/util/server/src/builders.rs @@ -740,6 +740,8 @@ impl TestCommandBuilder { }; if command_name == "deno" { deno_exe_path() + } else if command_name.starts_with("./") && self.cwd.is_some() { + self.cwd.as_ref().unwrap().join(command_name) } else { PathRef::new(PathBuf::from(command_name)) } diff --git a/tests/util/server/src/https.rs b/tests/util/server/src/https.rs index 0cc58255d5d1a..8a2524dca9622 100644 --- a/tests/util/server/src/https.rs +++ b/tests/util/server/src/https.rs @@ -1,14 +1,12 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use anyhow::anyhow; -use deno_tls::load_certs; -use deno_tls::load_private_keys; -use deno_tls::rustls; -use deno_tls::RootCertStore; -use deno_tls::TlsStream; use futures::Stream; use futures::StreamExt; +use rustls::Certificate; +use rustls::PrivateKey; +use rustls_tokio_stream::rustls; +use rustls_tokio_stream::TlsStream; use std::io; -use std::io::Read; use std::num::NonZeroUsize; use std::result::Result; use std::sync::Arc; @@ -70,43 +68,65 @@ pub fn get_tls_config( let key_file = std::fs::File::open(key_path)?; let ca_file = std::fs::File::open(ca_path)?; - let err_map = |x| io::Error::new(io::ErrorKind::InvalidData, x); - let certs = - load_certs(&mut io::BufReader::new(cert_file)).map_err(err_map)?; + let certs: Vec = { + let mut cert_reader = io::BufReader::new(cert_file); + rustls_pemfile::certs(&mut cert_reader) + .unwrap() + .into_iter() + .map(Certificate) + .collect() + }; let mut ca_cert_reader = io::BufReader::new(ca_file); - let ca_cert = load_certs(&mut ca_cert_reader).map_err(err_map)?.remove(0); + let ca_cert = rustls_pemfile::certs(&mut ca_cert_reader) + .expect("Cannot load CA certificate") + .remove(0); let mut key_reader = io::BufReader::new(key_file); - let mut key = vec![]; - key_reader.read_to_end(&mut key)?; - let key = load_private_keys(&key).map_err(err_map)?.remove(0); - - let mut root_cert_store = RootCertStore::empty(); - root_cert_store.add(&ca_cert).unwrap(); - - // Allow (but do not require) client authentication. - - let mut config = rustls::ServerConfig::builder() - .with_safe_defaults() - .with_client_cert_verifier(Arc::new( - rustls::server::AllowAnyAnonymousOrAuthenticatedClient::new( - root_cert_store, - ), - )) - .with_single_cert(certs, key) - .map_err(|e| anyhow!("Error setting cert: {:?}", e)) - .unwrap(); - - match http_versions { - SupportedHttpVersions::All => { - config.alpn_protocols = vec!["h2".into(), "http/1.1".into()]; + let key = { + let pkcs8_key = rustls_pemfile::pkcs8_private_keys(&mut key_reader) + .expect("Cannot load key file"); + let rsa_key = rustls_pemfile::rsa_private_keys(&mut key_reader) + .expect("Cannot load key file"); + if !pkcs8_key.is_empty() { + Some(pkcs8_key[0].clone()) + } else if !rsa_key.is_empty() { + Some(rsa_key[0].clone()) + } else { + None } - SupportedHttpVersions::Http1Only => {} - SupportedHttpVersions::Http2Only => { - config.alpn_protocols = vec!["h2".into()]; + }; + + match key { + Some(key) => { + let mut root_cert_store = rustls::RootCertStore::empty(); + root_cert_store.add(&rustls::Certificate(ca_cert)).unwrap(); + + // Allow (but do not require) client authentication. + + let mut config = rustls::ServerConfig::builder() + .with_safe_defaults() + .with_client_cert_verifier(Arc::new( + rustls::server::AllowAnyAnonymousOrAuthenticatedClient::new( + root_cert_store, + ), + )) + .with_single_cert(certs, PrivateKey(key)) + .map_err(|e| anyhow!("Error setting cert: {:?}", e)) + .unwrap(); + + match http_versions { + SupportedHttpVersions::All => { + config.alpn_protocols = vec!["h2".into(), "http/1.1".into()]; + } + SupportedHttpVersions::Http1Only => {} + SupportedHttpVersions::Http2Only => { + config.alpn_protocols = vec!["h2".into()]; + } + } + + Ok(Arc::new(config)) } + None => Err(io::Error::new(io::ErrorKind::Other, "Cannot find key")), } - - Ok(Arc::new(config)) } diff --git a/tests/util/server/src/npm.rs b/tests/util/server/src/npm.rs index 7469e9b9e3b06..b747ca2912a46 100644 --- a/tests/util/server/src/npm.rs +++ b/tests/util/server/src/npm.rs @@ -15,8 +15,34 @@ use tar::Builder; use crate::testdata_path; -pub static CUSTOM_NPM_PACKAGE_CACHE: Lazy = - Lazy::new(CustomNpmPackageCache::default); +pub const DENOTEST_SCOPE_NAME: &str = "@denotest"; + +pub static PUBLIC_TEST_NPM_REGISTRY: Lazy = Lazy::new(|| { + TestNpmRegistry::new( + NpmRegistryKind::Public, + &format!("http://localhost:{}", crate::servers::PORT), + "/npm/registry", + ) +}); + +// TODO: rewrite to use config +pub static PRIVATE_TEST_NPM_REGISTRY_1: Lazy = + Lazy::new(|| { + TestNpmRegistry::new( + NpmRegistryKind::Private, + &format!( + "http://localhost:{}", + crate::servers::PRIVATE_NPM_REGISTRY_1_PORT + ), + // TODO: change it + "/npm/registry", + ) + }); + +pub enum NpmRegistryKind { + Public, + Private, +} struct CustomNpmPackage { pub registry_file: String, @@ -25,10 +51,36 @@ struct CustomNpmPackage { /// Creates tarballs and a registry json file for npm packages /// in the `testdata/npm/registry/@denotest` directory. -#[derive(Default)] -pub struct CustomNpmPackageCache(Mutex>); +pub struct TestNpmRegistry { + #[allow(unused)] + kind: NpmRegistryKind, + // Eg. http://localhost:4544/ + hostname: String, + // Eg. /registry/npm/ + path: String, + + cache: Mutex>, +} + +impl TestNpmRegistry { + pub fn new(kind: NpmRegistryKind, hostname: &str, path: &str) -> Self { + let hostname = hostname.strip_suffix('/').unwrap_or(hostname).to_string(); + assert!( + !path.is_empty(), + "npm test registry must have a non-empty path" + ); + let stripped = path.strip_prefix('/').unwrap_or(path); + let stripped = path.strip_suffix('/').unwrap_or(stripped); + let path = format!("/{}/", stripped); + + Self { + hostname, + path, + kind, + cache: Default::default(), + } + } -impl CustomNpmPackageCache { pub fn tarball_bytes( &self, name: &str, @@ -51,19 +103,46 @@ impl CustomNpmPackageCache { func: impl FnOnce(&CustomNpmPackage) -> TResult, ) -> Result> { // it's ok if multiple threads race here as they will do the same work twice - if !self.0.lock().contains_key(package_name) { - match get_npm_package(package_name)? { + if !self.cache.lock().contains_key(package_name) { + match get_npm_package(&self.hostname, &self.path, package_name)? { Some(package) => { - self.0.lock().insert(package_name.to_string(), package); + self.cache.lock().insert(package_name.to_string(), package); } None => return Ok(None), } } - Ok(self.0.lock().get(package_name).map(func)) + Ok(self.cache.lock().get(package_name).map(func)) + } + + pub fn strip_registry_path_prefix_from_uri_path<'s>( + &self, + uri_path: &'s str, + ) -> Option<&'s str> { + uri_path.strip_prefix(&self.path) + } + + pub fn strip_denotest_prefix_from_uri_path<'s>( + &self, + uri_path: &'s str, + ) -> Option<&'s str> { + let prefix1 = format!("{}{}/", self.path, DENOTEST_SCOPE_NAME); + let prefix2 = format!("{}{}%2f", self.path, DENOTEST_SCOPE_NAME); + + uri_path + .strip_prefix(&prefix1) + .or_else(|| uri_path.strip_prefix(&prefix2)) + } + + pub fn uri_path_starts_with_registry_path(&self, uri_path: &str) -> bool { + uri_path.starts_with(&self.path) } } -fn get_npm_package(package_name: &str) -> Result> { +fn get_npm_package( + registry_hostname: &str, + registry_path: &str, + package_name: &str, +) -> Result> { let package_folder = testdata_path().join("npm/registry").join(package_name); if !package_folder.exists() { return Ok(None); @@ -111,10 +190,8 @@ fn get_npm_package(package_name: &str) -> Result> { dist.insert("shasum".to_string(), "dummy-value".into()); dist.insert( "tarball".to_string(), - format!( - "http://localhost:4545/npm/registry/{package_name}/{version}.tgz" - ) - .into(), + format!("{registry_hostname}{registry_path}{package_name}/{version}.tgz") + .into(), ); tarballs.insert(version.clone(), tarball_bytes); diff --git a/tests/util/server/src/servers/grpc.rs b/tests/util/server/src/servers/grpc.rs index ff00cae49b5bf..144afc06a3805 100644 --- a/tests/util/server/src/servers/grpc.rs +++ b/tests/util/server/src/servers/grpc.rs @@ -1,10 +1,10 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -use deno_tls::TlsStream; use futures::StreamExt; use h2; use hyper::header::HeaderName; use hyper::header::HeaderValue; +use rustls_tokio_stream::TlsStream; use tokio::net::TcpStream; use tokio::task::LocalSet; diff --git a/tests/util/server/src/servers/hyper_utils.rs b/tests/util/server/src/servers/hyper_utils.rs index 58b5f0cb9fb88..ea15bba0e576f 100644 --- a/tests/util/server/src/servers/hyper_utils.rs +++ b/tests/util/server/src/servers/hyper_utils.rs @@ -1,7 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use bytes::Bytes; -use deno_tls::TlsStream; use futures::Future; use futures::FutureExt; use futures::Stream; @@ -70,7 +69,7 @@ pub async fn run_server_with_acceptor<'a, A, F, S>( error_msg: &'static str, kind: ServerKind, ) where - A: Stream> + ?Sized, + A: Stream> + ?Sized, F: Fn(Request) -> S + Copy + 'static, S: Future + 'static, { diff --git a/tests/util/server/src/servers/mod.rs b/tests/util/server/src/servers/mod.rs index bc94c668e455c..18f893a118cd4 100644 --- a/tests/util/server/src/servers/mod.rs +++ b/tests/util/server/src/servers/mod.rs @@ -50,11 +50,11 @@ use hyper_utils::ServerOptions; use super::https::get_tls_listener_stream; use super::https::SupportedHttpVersions; -use super::npm::CUSTOM_NPM_PACKAGE_CACHE; +use super::npm; use super::std_path; use super::testdata_path; -const PORT: u16 = 4545; +pub(crate) const PORT: u16 = 4545; const TEST_AUTH_TOKEN: &str = "abcdef123456789"; const TEST_BASIC_AUTH_USERNAME: &str = "testuser123"; const TEST_BASIC_AUTH_PASSWORD: &str = "testpassabc"; @@ -85,7 +85,7 @@ const H2_GRPC_PORT: u16 = 4246; const H2S_GRPC_PORT: u16 = 4247; const REGISTRY_SERVER_PORT: u16 = 4250; const PROVENANCE_MOCK_SERVER_PORT: u16 = 4251; -const PRIVATE_NPM_REGISTRY_1_PORT: u16 = 4252; +pub(crate) const PRIVATE_NPM_REGISTRY_1_PORT: u16 = 4252; // Use the single-threaded scheduler. The hyper server is used as a point of // comparison for the (single-threaded!) benchmarks in cli/bench. We're not @@ -1083,24 +1083,30 @@ async fn main_server( ); } _ => { + let uri_path = req.uri().path(); let mut file_path = testdata_path().to_path_buf(); - file_path.push(&req.uri().path()[1..].replace("%2f", "/")); + file_path.push(&uri_path[1..].replace("%2f", "/")); if let Ok(file) = tokio::fs::read(&file_path).await { - let file_resp = custom_headers(req.uri().path(), file); + let file_resp = custom_headers(uri_path, file); return Ok(file_resp); } // serve npm registry files - if let Some(resp) = try_serve_npm_registry(&req, file_path.clone()).await + if let Some(resp) = try_serve_npm_registry( + uri_path, + file_path.clone(), + &npm::PUBLIC_TEST_NPM_REGISTRY, + ) + .await { return resp; - } else if let Some(suffix) = req.uri().path().strip_prefix("/deno_std/") { + } else if let Some(suffix) = uri_path.strip_prefix("/deno_std/") { let file_path = std_path().join(suffix); if let Ok(file) = tokio::fs::read(&file_path).await { - let file_resp = custom_headers(req.uri().path(), file); + let file_resp = custom_headers(uri_path, file); return Ok(file_resp); } - } else if let Some(suffix) = req.uri().path().strip_prefix("/sleep/") { + } else if let Some(suffix) = uri_path.strip_prefix("/sleep/") { let duration = suffix.parse::().unwrap(); tokio::time::sleep(Duration::from_millis(duration)).await; return Response::builder() @@ -1150,10 +1156,17 @@ async fn private_npm_registry1( ); } - let mut file_path = testdata_path().to_path_buf(); - file_path.push(&req.uri().path()[1..].replace("%2f", "/")); + let uri_path = req.uri().path(); + let mut testdata_file_path = testdata_path().to_path_buf(); + testdata_file_path.push(&uri_path[1..].replace("%2f", "/")); - if let Some(resp) = try_serve_npm_registry(&req, file_path).await { + if let Some(resp) = try_serve_npm_registry( + uri_path, + testdata_file_path, + &npm::PRIVATE_TEST_NPM_REGISTRY_1, + ) + .await + { return resp; } @@ -1165,22 +1178,25 @@ async fn private_npm_registry1( fn handle_custom_npm_registry_path( path: &str, + test_npm_registry: &npm::TestNpmRegistry, ) -> Result>>, anyhow::Error> { let parts = path .split('/') .filter(|p| !p.is_empty()) .collect::>(); - let cache = &CUSTOM_NPM_PACKAGE_CACHE; + let package_name = format!("@denotest/{}", parts[0]); if parts.len() == 2 { - if let Some(file_bytes) = - cache.tarball_bytes(&package_name, parts[1].trim_end_matches(".tgz"))? + if let Some(file_bytes) = test_npm_registry + .tarball_bytes(&package_name, parts[1].trim_end_matches(".tgz"))? { let file_resp = custom_headers("file.tgz", file_bytes); return Ok(Some(file_resp)); } } else if parts.len() == 1 { - if let Some(registry_file) = cache.registry_file(&package_name)? { + if let Some(registry_file) = + test_npm_registry.registry_file(&package_name)? + { let file_resp = custom_headers("registry.json", registry_file); return Ok(Some(file_resp)); } @@ -1196,18 +1212,16 @@ fn should_download_npm_packages() -> bool { } async fn try_serve_npm_registry( - req: &Request, - mut file_path: PathBuf, + uri_path: &str, + mut testdata_file_path: PathBuf, + test_npm_registry: &npm::TestNpmRegistry, ) -> Option>, anyhow::Error>> { - if let Some(suffix) = req - .uri() - .path() - .strip_prefix("/npm/registry/@denotest/") - .or_else(|| req.uri().path().strip_prefix("/npm/registry/@denotest%2f")) + if let Some(suffix) = + test_npm_registry.strip_denotest_prefix_from_uri_path(uri_path) { - // serve all requests to /npm/registry/@deno using the file system + // serve all requests to the `DENOTEST_SCOPE_NAME` using the file system // at that path - match handle_custom_npm_registry_path(suffix) { + match handle_custom_npm_registry_path(suffix, test_npm_registry) { Ok(Some(response)) => return Some(Ok(response)), Ok(None) => {} // ignore, not found Err(err) => { @@ -1219,18 +1233,23 @@ async fn try_serve_npm_registry( ); } } - } else if req.uri().path().starts_with("/npm/registry/") { + } else if test_npm_registry.uri_path_starts_with_registry_path(uri_path) { // otherwise, serve based on registry.json and tgz files - let is_tarball = req.uri().path().ends_with(".tgz"); + let is_tarball = uri_path.ends_with(".tgz"); if !is_tarball { - file_path.push("registry.json"); + testdata_file_path.push("registry.json"); } - if let Ok(file) = tokio::fs::read(&file_path).await { - let file_resp = custom_headers(req.uri().path(), file); + if let Ok(file) = tokio::fs::read(&testdata_file_path).await { + let file_resp = custom_headers(uri_path, file); return Some(Ok(file_resp)); } else if should_download_npm_packages() { - if let Err(err) = - download_npm_registry_file(req.uri(), &file_path, is_tarball).await + if let Err(err) = download_npm_registry_file( + test_npm_registry, + uri_path, + &testdata_file_path, + is_tarball, + ) + .await { return Some( Response::builder() @@ -1241,8 +1260,8 @@ async fn try_serve_npm_registry( }; // serve the file - if let Ok(file) = tokio::fs::read(&file_path).await { - let file_resp = custom_headers(req.uri().path(), file); + if let Ok(file) = tokio::fs::read(&testdata_file_path).await { + let file_resp = custom_headers(uri_path, file); return Some(Ok(file_resp)); } } @@ -1251,14 +1270,32 @@ async fn try_serve_npm_registry( None } +// Replaces URL of public npm registry (`https://registry.npmjs.org/`) with +// the test registry (`http://localhost:4545/npm/registry/`). +// +// These strings end up in `registry.json` files for each downloaded package +// that are stored in `tests/testdata/` directory. +// +// If another npm test registry wants to use them, it should replace +// these values with appropriate URL when serving. +fn replace_default_npm_registry_url_with_test_npm_registry_url( + str_: String, + package_name: &str, +) -> String { + str_.replace( + &format!("https://registry.npmjs.org/{package_name}/-/"), + &format!("http://localhost:4545/npm/registry/{package_name}/"), + ) +} + async fn download_npm_registry_file( - uri: &hyper::Uri, - file_path: &PathBuf, + test_npm_registry: &npm::TestNpmRegistry, + uri_path: &str, + testdata_file_path: &PathBuf, is_tarball: bool, ) -> Result<(), anyhow::Error> { - let url_parts = uri - .path() - .strip_prefix("/npm/registry/") + let url_parts = test_npm_registry + .strip_registry_path_prefix_from_uri_path(uri_path) .unwrap() .split('/') .collect::>(); @@ -1268,7 +1305,7 @@ async fn download_npm_registry_file( url_parts.into_iter().take(1).collect::>().join("/") }; let url = if is_tarball { - let file_name = file_path.file_name().unwrap().to_string_lossy(); + let file_name = testdata_file_path.file_name().unwrap().to_string_lossy(); format!("https://registry.npmjs.org/{package_name}/-/{file_name}") } else { format!("https://registry.npmjs.org/{package_name}") @@ -1279,16 +1316,14 @@ async fn download_npm_registry_file( let bytes = if is_tarball { bytes.to_vec() } else { - String::from_utf8(bytes.to_vec()) - .unwrap() - .replace( - &format!("https://registry.npmjs.org/{package_name}/-/"), - &format!("http://localhost:4545/npm/registry/{package_name}/"), - ) - .into_bytes() + replace_default_npm_registry_url_with_test_npm_registry_url( + String::from_utf8(bytes.to_vec()).unwrap(), + &package_name, + ) + .into_bytes() }; - std::fs::create_dir_all(file_path.parent().unwrap())?; - std::fs::write(file_path, bytes)?; + std::fs::create_dir_all(testdata_file_path.parent().unwrap())?; + std::fs::write(testdata_file_path, bytes)?; Ok(()) } diff --git a/tools/jsdoc_checker.js b/tools/jsdoc_checker.js new file mode 100644 index 0000000000000..733790c4e3066 --- /dev/null +++ b/tools/jsdoc_checker.js @@ -0,0 +1,92 @@ +#!/usr/bin/env -S deno run --allow-read --allow-env --allow-sys +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +import { Node, Project, ts } from "npm:ts-morph@22.0.0"; +import { join, ROOT_PATH } from "./util.js"; + +const libs = [ + join(ROOT_PATH, "ext/cache/lib.deno_cache.d.ts"), + join(ROOT_PATH, "ext/console/lib.deno_console.d.ts"), + join(ROOT_PATH, "ext/url/lib.deno_url.d.ts"), + join(ROOT_PATH, "ext/web/lib.deno_web.d.ts"), + join(ROOT_PATH, "ext/fetch/lib.deno_fetch.d.ts"), + join(ROOT_PATH, "ext/websocket/lib.deno_websocket.d.ts"), + join(ROOT_PATH, "ext/webstorage/lib.deno_webstorage.d.ts"), + join(ROOT_PATH, "ext/canvas/lib.deno_canvas.d.ts"), + join(ROOT_PATH, "ext/crypto/lib.deno_crypto.d.ts"), + join(ROOT_PATH, "ext/net/lib.deno_net.d.ts"), + join(ROOT_PATH, "cli/tsc/dts/lib.deno.ns.d.ts"), + join(ROOT_PATH, "cli/tsc/dts/lib.deno.shared_globals.d.ts"), + join(ROOT_PATH, "cli/tsc/dts/lib.deno.window.d.ts"), +]; + +const unstableLibs = [ + join(ROOT_PATH, "ext/broadcast_channel/lib.deno_broadcast_channel.d.ts"), + join(ROOT_PATH, "cli/tsc/dts/lib.deno_webgpu.d.ts"), + join(ROOT_PATH, "cli/tsc/dts/lib.deno.unstable.d.ts"), +]; + +const errors = []; + +const project = new Project(); +project.addSourceFilesAtPaths(libs); +const unstableFiles = project.addSourceFilesAtPaths(unstableLibs); + +for (const file of project.getSourceFiles()) { + for ( + const node of file.getDescendants().filter((descendant) => + Node.isExportable(descendant) + ) + ) { + if ( + node.getKind() === ts.SyntaxKind.ModuleDeclaration && + node.getName() === "Deno" + ) { + continue; + } + + const parent = node.getFirstAncestorByKind(ts.SyntaxKind.ModuleDeclaration); + + if (parent) { + if (!node.isExported()) { + errors.push(getErrorPrefix(node) + "export keyword"); + continue; + } + } else if (!node.hasDeclareKeyword()) { + errors.push(getErrorPrefix(node) + "declare keyword"); + continue; + } + + const jsDoc = node.getFirstChildIfKind(ts.SyntaxKind.JSDoc); + if (!jsDoc) { + errors.push(getErrorPrefix(node) + "JSDoc comment"); + continue; + } + + const tags = jsDoc.getTags(); + + if (!tags.find((tag) => tag.getTagName() === "category")) { + errors.push(getErrorPrefix(node) + "JSDoc @category tag"); + continue; + } + + if (unstableFiles.includes(file)) { + const tagsTag = tags.find((tag) => tag.getTagName() === "tags"); + if ( + !(tagsTag?.getComment() && + tagsTag.getCommentText().includes("unstable")) + ) { + errors.push( + getErrorPrefix(node) + "JSDoc @tags tag with value 'unstable'", + ); + } + } + } +} + +if (errors.length > 0) { + throw new AggregateError(errors); +} + +function getErrorPrefix(node) { + return `Symbol at file://${node.getSourceFile().getFilePath()}:${node.getStartLineNumber()} is missing a `; +} diff --git a/tools/lint.js b/tools/lint.js index 9a001967e4ca6..760aa9f9284ef 100755 --- a/tools/lint.js +++ b/tools/lint.js @@ -187,36 +187,37 @@ async function ensureNoNewITests() { // This is to help ensure we slowly deprecate these tests and // replace them with spec tests. const iTestCounts = { - "bench_tests.rs": 37, + "bench_tests.rs": 0, "bundle_tests.rs": 12, - "cache_tests.rs": 11, + "cache_tests.rs": 0, "cert_tests.rs": 3, - "check_tests.rs": 28, + "check_tests.rs": 23, "compile_tests.rs": 0, "coverage_tests.rs": 0, - "doc_tests.rs": 17, + "doc_tests.rs": 15, "eval_tests.rs": 9, "flags_tests.rs": 0, "fmt_tests.rs": 17, - "info_tests.rs": 20, + "info_tests.rs": 18, "init_tests.rs": 0, "inspector_tests.rs": 0, "install_tests.rs": 0, "jsr_tests.rs": 0, "js_unit_tests.rs": 0, "jupyter_tests.rs": 0, - "lint_tests.rs": 24, + "lint_tests.rs": 18, + // Read the comment above. Please don't increase these numbers! "lsp_tests.rs": 0, "node_compat_tests.rs": 4, "node_unit_tests.rs": 3, "npm_tests.rs": 98, "pm_tests.rs": 0, - "publish_tests.rs": 28, + "publish_tests.rs": 0, "repl_tests.rs": 0, - "run_tests.rs": 379, + "run_tests.rs": 373, "shared_library_tests.rs": 0, "task_tests.rs": 30, - "test_tests.rs": 80, + "test_tests.rs": 77, "upgrade_tests.rs": 0, "vendor_tests.rs": 1, "watcher_tests.rs": 0, @@ -233,7 +234,7 @@ async function ensureNoNewITests() { // console.log(`"${entry.name}": ${actualCount},`); if (actualCount > expectedCount) { throw new Error( - `New itest added to ${entry.name}! The itest macro is deprecated. Please move this test to ~/tests/specs.`, + `New itest added to ${entry.name}! The itest macro is deprecated. Please move your new test to ~/tests/specs.`, ); } else if (actualCount < expectedCount) { throw new Error( diff --git a/tools/release/release_doc_template.md b/tools/release/release_doc_template.md index bed3a4def4602..ee334352f1ea3 100644 --- a/tools/release/release_doc_template.md +++ b/tools/release/release_doc_template.md @@ -4,7 +4,6 @@ - Forks and local clones of [`denoland/deno`](https://github.com/denoland/deno/), - [`denoland/deno_std`](https://github.com/denoland/deno_std/), [`denoland/dotcom`](https://github.com/denoland/dotcom/), [`denoland/deno_docker`](https://github.com/denoland/deno_docker/), [`denoland/deno-docs`](https://github.com/denoland/deno-docs) @@ -16,7 +15,7 @@ cut.** - [ ] Check https://deno.land/benchmarks?-100 and ensure there's no recent regressions. - [ ] Write a message in company's #cli channel: - `:lock: deno and deno_std are now locked ()` + `:lock: deno is now locked ()` ## Patch release preparation @@ -41,42 +40,6 @@ verify on GitHub that everything looks correct. - [ ] Unstable `feat` commits were merged. - [ ] Internal API commits like `feat(core)` were merged. -## Updating `deno_std` - -- [ ] Go to the "version_bump" workflow in the deno_std repo's actions: - https://github.com/denoland/deno_std/actions/workflows/version_bump.yml - 1. Click on the "Run workflow" button. - 1. For the kind of release, select "minor". - 1. Run the workflow. - -- [ ] A PR will be automatically created. Follow the checklist in the PR, review - it, and merge the PR. - - ⛔ DO NOT create a release tag manually. That will automatically happen. - -
- Failure Steps - - 1. Checkout the latest main. - 2. Manually run `./_tools/release/01_bump_version.ts --minor` - 1. Ensure the version in `version.ts` is updated correctly. - 2. Ensure `Releases.md` is updated correctly. - 3. Ensure all the tests pass with the latest build (examine the repo for - what the command is and run the local built deno binary) - 3. Open a PR with the changes and continue with the steps below. -
- -- Wait for the CI run to complete which will automatically tag the repo and - create a draft release. - - [ ] Review the draft release and then publish it. - -
- Failure Steps - - 1. Tag the repo manually in the format `x.x.x` - 2. Draft a new GH release by copying and pasting the release notes from - `Releases.md` -
- ## Updating `deno` ### Phase 1: Bumping versions @@ -154,7 +117,7 @@ verify on GitHub that everything looks correct. automatically opened that forwards the release commit back to main. If so, merge it. If not and it failed, please manually create one. -## Updating `deno.land/api` & `deno.land/std` symbols +## Updating `deno.land/api` symbols This should occur after the Deno CLI & std are fully published, as the build script generates the symbols based on the latest tags. @@ -163,17 +126,12 @@ script generates the symbols based on the latest tags. branch: https://github.com/denoland/apiland_scripts/actions/workflows/release_cli.yml - [ ] Verify the workflow ran successfully. -- [ ] Run the `release STD` workflow in the apiland_scripts repo on the main - branch: - https://github.com/denoland/apiland_scripts/actions/workflows/release_std.yml - - [ ] Verify the workflow ran successfully.
Failure Steps 1. Clone `deno/apiland_scripts`. 2. Execute `deno task release:cli`. - 3. Execute `deno task release:std`.
## Updating `deno_docker` @@ -193,4 +151,4 @@ script generates the symbols based on the latest tags. ## All done! - [ ] Write a message in company's #cli channel: - `:unlock: deno and deno_std are now unlocked`. + `:unlock: deno is now unlocked`.