mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
parent
392579b5a6
commit
e40f9a5c14
45 changed files with 112 additions and 178 deletions
|
@ -3,7 +3,6 @@
|
|||
use deno_core::serde_json;
|
||||
use std::fs;
|
||||
use test_util as util;
|
||||
use test_util::itest;
|
||||
use test_util::TempDir;
|
||||
use util::assert_starts_with;
|
||||
use util::env_vars_for_npm_tests;
|
||||
|
@ -631,9 +630,3 @@ File | Branch % | Line % |
|
|||
",
|
||||
);
|
||||
}
|
||||
|
||||
itest!(no_files_found {
|
||||
args: "coverage doesnt_exist.js",
|
||||
exit_code: 1,
|
||||
output: "coverage/doesnt_exist.out",
|
||||
});
|
||||
|
|
|
@ -1,21 +1,8 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use test_util as util;
|
||||
use test_util::itest;
|
||||
use util::assert_contains;
|
||||
|
||||
#[test]
|
||||
fn help_flag() {
|
||||
let status = util::deno_cmd()
|
||||
.current_dir(util::testdata_path())
|
||||
.arg("--help")
|
||||
.spawn()
|
||||
.unwrap()
|
||||
.wait()
|
||||
.unwrap();
|
||||
assert!(status.success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn help_output() {
|
||||
let output = util::deno_cmd()
|
||||
|
@ -56,32 +43,3 @@ fn help_output() {
|
|||
assert_contains!(stdout, description);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn version_short_flag() {
|
||||
let status = util::deno_cmd()
|
||||
.current_dir(util::testdata_path())
|
||||
.arg("-V")
|
||||
.spawn()
|
||||
.unwrap()
|
||||
.wait()
|
||||
.unwrap();
|
||||
assert!(status.success());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn version_long_flag() {
|
||||
let status = util::deno_cmd()
|
||||
.current_dir(util::testdata_path())
|
||||
.arg("--version")
|
||||
.spawn()
|
||||
.unwrap()
|
||||
.wait()
|
||||
.unwrap();
|
||||
assert!(status.success());
|
||||
}
|
||||
|
||||
itest!(types {
|
||||
args: "types",
|
||||
output: "types/types.out",
|
||||
});
|
||||
|
|
|
@ -4,87 +4,11 @@ use deno_core::serde_json::json;
|
|||
use deno_core::serde_json::Value;
|
||||
use deno_lockfile::Lockfile;
|
||||
use test_util as util;
|
||||
use test_util::itest;
|
||||
use url::Url;
|
||||
use util::assert_contains;
|
||||
use util::assert_not_contains;
|
||||
use util::env_vars_for_jsr_npm_tests;
|
||||
use util::env_vars_for_jsr_tests;
|
||||
use util::TestContextBuilder;
|
||||
|
||||
itest!(no_module_graph_run {
|
||||
args: "run jsr/no_module_graph/main.ts",
|
||||
output: "jsr/no_module_graph/main.out",
|
||||
envs: env_vars_for_jsr_tests(),
|
||||
http_server: true,
|
||||
});
|
||||
|
||||
itest!(no_module_graph_info {
|
||||
args: "info jsr/no_module_graph/main.ts",
|
||||
output: "jsr/no_module_graph/main_info.out",
|
||||
envs: env_vars_for_jsr_tests(),
|
||||
http_server: true,
|
||||
});
|
||||
|
||||
itest!(same_package_multiple_versions {
|
||||
args: "run --quiet jsr/no_module_graph/multiple.ts",
|
||||
output: "jsr/no_module_graph/multiple.out",
|
||||
envs: env_vars_for_jsr_tests(),
|
||||
http_server: true,
|
||||
});
|
||||
|
||||
itest!(module_graph_run {
|
||||
args: "run jsr/module_graph/main.ts",
|
||||
output: "jsr/module_graph/main.out",
|
||||
envs: env_vars_for_jsr_tests(),
|
||||
http_server: true,
|
||||
});
|
||||
|
||||
itest!(module_graph_info {
|
||||
args: "info jsr/module_graph/main.ts",
|
||||
output: "jsr/module_graph/main_info.out",
|
||||
envs: env_vars_for_jsr_tests(),
|
||||
http_server: true,
|
||||
});
|
||||
|
||||
itest!(deps_run {
|
||||
args: "run jsr/deps/main.ts",
|
||||
output: "jsr/deps/main.out",
|
||||
envs: env_vars_for_jsr_tests(),
|
||||
http_server: true,
|
||||
});
|
||||
|
||||
itest!(deps_info {
|
||||
args: "info jsr/deps/main.ts",
|
||||
output: "jsr/deps/main_info.out",
|
||||
envs: env_vars_for_jsr_tests(),
|
||||
http_server: true,
|
||||
});
|
||||
|
||||
itest!(import_https_url_analyzable {
|
||||
args: "run -A jsr/import_https_url/analyzable.ts",
|
||||
output: "jsr/import_https_url/analyzable.out",
|
||||
envs: env_vars_for_jsr_tests(),
|
||||
http_server: true,
|
||||
exit_code: 1,
|
||||
});
|
||||
|
||||
itest!(import_https_url_unanalyzable {
|
||||
args: "run -A jsr/import_https_url/unanalyzable.ts",
|
||||
output: "jsr/import_https_url/unanalyzable.out",
|
||||
envs: env_vars_for_jsr_tests(),
|
||||
http_server: true,
|
||||
exit_code: 1,
|
||||
});
|
||||
|
||||
itest!(subset_type_graph {
|
||||
args: "check --all jsr/subset_type_graph/main.ts",
|
||||
output: "jsr/subset_type_graph/main.check.out",
|
||||
envs: env_vars_for_jsr_tests(),
|
||||
http_server: true,
|
||||
exit_code: 1,
|
||||
});
|
||||
|
||||
#[test]
|
||||
fn fast_check_cache() {
|
||||
let test_context = TestContextBuilder::for_jsr().use_temp_cwd().build();
|
||||
|
@ -197,14 +121,6 @@ export function asdf(a: number) { let err: number = ''; return Math.random(); }
|
|||
);
|
||||
}
|
||||
|
||||
itest!(version_not_found {
|
||||
args: "run jsr/version_not_found/main.ts",
|
||||
output: "jsr/version_not_found/main.out",
|
||||
envs: env_vars_for_jsr_tests(),
|
||||
http_server: true,
|
||||
exit_code: 1,
|
||||
});
|
||||
|
||||
#[test]
|
||||
fn specifiers_in_lockfile() {
|
||||
let test_context = TestContextBuilder::for_jsr().use_temp_cwd().build();
|
||||
|
@ -478,19 +394,3 @@ fn set_lockfile_pkg_integrity(
|
|||
.unwrap()
|
||||
.integrity = integrity.to_string();
|
||||
}
|
||||
|
||||
itest!(jsx_with_no_pragmas {
|
||||
args: "run jsr/jsx_with_no_pragmas/main.ts",
|
||||
output: "jsr/jsx_with_no_pragmas/main.out",
|
||||
envs: env_vars_for_jsr_npm_tests(),
|
||||
http_server: true,
|
||||
exit_code: 1,
|
||||
});
|
||||
|
||||
itest!(jsx_with_pragmas {
|
||||
args: "run jsr/jsx_with_pragmas/main.ts",
|
||||
output: "jsr/jsx_with_pragmas/main.out",
|
||||
envs: env_vars_for_jsr_npm_tests(),
|
||||
http_server: true,
|
||||
exit_code: 0,
|
||||
});
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use test_util::itest;
|
||||
|
||||
itest!(jupyter_install_command_not_exists {
|
||||
args: "jupyter --install",
|
||||
output: "jupyter/install_command_not_exists.out",
|
||||
envs: vec![("PATH".to_string(), "".to_string())],
|
||||
exit_code: 1,
|
||||
});
|
|
@ -38,8 +38,6 @@ mod install;
|
|||
mod js_unit_tests;
|
||||
#[path = "jsr_tests.rs"]
|
||||
mod jsr;
|
||||
#[path = "jupyter_tests.rs"]
|
||||
mod jupyter;
|
||||
#[path = "lint_tests.rs"]
|
||||
mod lint;
|
||||
#[path = "lsp_tests.rs"]
|
||||
|
|
5
tests/specs/coverage/no_files_found/__test__.jsonc
Normal file
5
tests/specs/coverage/no_files_found/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"args": "coverage does_not_exit.js",
|
||||
"output": "does_not_exist.out",
|
||||
"exitCode": 1
|
||||
}
|
4
tests/specs/flags/help_flag/__test__.jsonc
Normal file
4
tests/specs/flags/help_flag/__test__.jsonc
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"args": "--help",
|
||||
"output": "[WILDCARD]"
|
||||
}
|
4
tests/specs/flags/types/__test__.jsonc
Normal file
4
tests/specs/flags/types/__test__.jsonc
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"args": "types",
|
||||
"output": "types.out"
|
||||
}
|
9
tests/specs/flags/version_flag/__test__.jsonc
Normal file
9
tests/specs/flags/version_flag/__test__.jsonc
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"steps": [{
|
||||
"args": "-V",
|
||||
"output": "[WILDCARD]"
|
||||
}, {
|
||||
"args": "--version",
|
||||
"output": "[WILDCARD]"
|
||||
}]
|
||||
}
|
11
tests/specs/jsr/deps/__test__.jsonc
Normal file
11
tests/specs/jsr/deps/__test__.jsonc
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"base": "jsr",
|
||||
"steps": [{
|
||||
"args": "run main.ts",
|
||||
"output": "main.out"
|
||||
}, {
|
||||
"cleanDenoDir": true,
|
||||
"args": "info main.ts",
|
||||
"output": "main_info.out"
|
||||
}]
|
||||
}
|
13
tests/specs/jsr/import_https_url/__test__.jsonc
Normal file
13
tests/specs/jsr/import_https_url/__test__.jsonc
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"base": "jsr",
|
||||
"steps": [{
|
||||
"args": "run -A analyzable.ts",
|
||||
"output": "analyzable.out",
|
||||
"exitCode": 1
|
||||
}, {
|
||||
"cleanDenoDir": true,
|
||||
"args": "run -A nonanalyzable.ts",
|
||||
"output": "nonanalyzable.out",
|
||||
"exitCode": 1
|
||||
}]
|
||||
}
|
6
tests/specs/jsr/jsx_with_no_pragmas/__test__.jsonc
Normal file
6
tests/specs/jsr/jsx_with_no_pragmas/__test__.jsonc
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"base": "jsr",
|
||||
"args": "run main.ts",
|
||||
"output": "main.out",
|
||||
"exitCode": 1
|
||||
}
|
5
tests/specs/jsr/jsx_with_pragmas/__test__.jsonc
Normal file
5
tests/specs/jsr/jsx_with_pragmas/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"base": "jsr",
|
||||
"args": "run main.ts",
|
||||
"output": "main.out"
|
||||
}
|
11
tests/specs/jsr/module_graph/__test__.jsonc
Normal file
11
tests/specs/jsr/module_graph/__test__.jsonc
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"base": "jsr",
|
||||
"steps": [{
|
||||
"args": "run main.ts",
|
||||
"output": "main.out"
|
||||
}, {
|
||||
"cleanDenoDir": true,
|
||||
"args": "info main.ts",
|
||||
"output": "main_info.out"
|
||||
}]
|
||||
}
|
14
tests/specs/jsr/no_module_graph/__test__.jsonc
Normal file
14
tests/specs/jsr/no_module_graph/__test__.jsonc
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"base": "jsr",
|
||||
"steps": [{
|
||||
"args": "run main.ts",
|
||||
"output": "main.out"
|
||||
}, {
|
||||
"cleanDenoDir": true,
|
||||
"args": "info main.ts",
|
||||
"output": "main_info.out"
|
||||
}, {
|
||||
"args": "run --quiet multiple.ts",
|
||||
"output": "multiple.out"
|
||||
}]
|
||||
}
|
6
tests/specs/jsr/subset_type_graph/__test__.jsonc
Normal file
6
tests/specs/jsr/subset_type_graph/__test__.jsonc
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"base": "jsr",
|
||||
"args": "check --all main.ts",
|
||||
"output": "main.check.out",
|
||||
"exitCode": 1
|
||||
}
|
6
tests/specs/jsr/version_not_found/__test__.jsonc
Normal file
6
tests/specs/jsr/version_not_found/__test__.jsonc
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"base": "jsr",
|
||||
"args": "run -A main.ts",
|
||||
"output": "main.out",
|
||||
"exitCode": 1
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"args": "jupyter --install",
|
||||
"output": "install_command_not_exists.out",
|
||||
"envs": {
|
||||
"PATH": ""
|
||||
},
|
||||
"exitCode": 1
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::HashSet;
|
||||
use std::panic::AssertUnwindSafe;
|
||||
use std::rc::Rc;
|
||||
|
@ -127,15 +128,13 @@ fn run_test(test: &Test, diagnostic_logger: Rc<RefCell<Vec<u8>>>) {
|
|||
context.deno_dir().path().remove_dir_all();
|
||||
}
|
||||
|
||||
let test_output_path = cwd.join(&step.output);
|
||||
if !test_output_path.to_string_lossy().ends_with(".out") {
|
||||
panic!(
|
||||
"Use the .out extension for output files (invalid: {})",
|
||||
test_output_path
|
||||
);
|
||||
}
|
||||
let expected_output = test_output_path.read_to_string();
|
||||
let command = context.new_command();
|
||||
let expected_output = if step.output.ends_with(".out") {
|
||||
let test_output_path = cwd.join(&step.output);
|
||||
test_output_path.read_to_string()
|
||||
} else {
|
||||
step.output.clone()
|
||||
};
|
||||
let command = context.new_command().envs(&step.envs);
|
||||
let command = match &step.args {
|
||||
VecOrString::Vec(args) => command.args_vec(args),
|
||||
VecOrString::String(text) => command.args(text),
|
||||
|
@ -195,6 +194,8 @@ struct StepMetaData {
|
|||
#[serde(default)]
|
||||
pub clean_deno_dir: bool,
|
||||
pub args: VecOrString,
|
||||
#[serde(default)]
|
||||
pub envs: HashMap<String, String>,
|
||||
pub output: String,
|
||||
#[serde(default)]
|
||||
pub exit_code: i32,
|
||||
|
@ -283,14 +284,6 @@ fn collect_tests() -> Vec<TestCategory> {
|
|||
|
||||
let test_dir = PathRef::new(entry.path());
|
||||
let metadata_path = test_dir.join("__test__.jsonc");
|
||||
if !metadata_path.is_file() {
|
||||
let json_path = test_dir.join("__test__.json");
|
||||
if json_path.is_file() {
|
||||
// automatically rename to jsonc
|
||||
json_path.rename(&metadata_path);
|
||||
}
|
||||
}
|
||||
|
||||
let metadata_value = metadata_path.read_jsonc_value();
|
||||
// checking for "steps" leads to a more targeted error message
|
||||
// instead of when deserializing an untagged enum
|
||||
|
|
Loading…
Reference in a new issue