1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

chore: deprecate task itests (#25558)

This PR is part of #22907
This commit is contained in:
HasanAlrimawi 2024-09-11 18:39:47 +03:00 committed by GitHub
parent c64aa50c0e
commit 1463a4ad58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
93 changed files with 375 additions and 264 deletions

View file

@ -3,169 +3,9 @@
// Most of the tests for this are in deno_task_shell. // Most of the tests for this are in deno_task_shell.
// These tests are intended to only test integration. // These tests are intended to only test integration.
use test_util::env_vars_for_npm_tests; // use test_util::env_vars_for_npm_tests;
use test_util::itest; // use test_util::itest;
use test_util::TestContext; // use test_util::TestContext;
itest!(task_no_args {
args: "task -q --config task/deno_json/deno.json",
output: "task/deno_json/task_no_args.out",
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
exit_code: 1,
});
itest!(task_cwd {
args: "task -q --config task/deno_json/deno.json --cwd .. echo_cwd",
output: "task/deno_json/task_cwd.out",
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
exit_code: 0,
});
itest!(task_init_cwd {
args: "task -q --config task/deno_json/deno.json --cwd .. echo_init_cwd",
output: "task/deno_json/task_init_cwd.out",
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
exit_code: 0,
});
itest!(task_init_cwd_already_set {
args: "task -q --config task/deno_json/deno.json echo_init_cwd",
output: "task/deno_json/task_init_cwd_already_set.out",
envs: vec![
("NO_COLOR".to_string(), "1".to_string()),
("INIT_CWD".to_string(), "HELLO".to_string())
],
exit_code: 0,
});
itest!(task_cwd_resolves_config_from_specified_dir {
args: "task -q --cwd task/deno_json",
output: "task/deno_json/task_no_args.out",
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
exit_code: 1,
});
itest!(task_non_existent {
args: "task --config task/deno_json/deno.json non_existent",
output: "task/deno_json/task_non_existent.out",
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
exit_code: 1,
});
#[test]
fn task_emoji() {
// this bug only appears when using a pty/tty
TestContext::default()
.new_command()
.args_vec(["task", "--config", "task/deno_json/deno.json", "echo_emoji"])
.with_pty(|mut console| {
console.expect("Task echo_emoji echo 🔥\r\n🔥");
});
}
itest!(task_boolean_logic {
args: "task -q --config task/deno_json/deno.json boolean_logic",
output: "task/deno_json/task_boolean_logic.out",
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
});
itest!(task_exit_code_5 {
args: "task --config task/deno_json/deno.json exit_code_5",
output: "task/deno_json/task_exit_code_5.out",
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
exit_code: 5,
});
itest!(task_additional_args {
args: "task -q --config task/deno_json/deno.json echo 2",
output: "task/deno_json/task_additional_args.out",
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
});
itest!(task_additional_args_no_shell_expansion {
args_vec: vec![
"task",
"-q",
"--config",
"task/deno_json/deno.json",
"echo",
"$(echo 5)"
],
output: "task/deno_json/task_additional_args_no_shell_expansion.out",
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
});
itest!(task_additional_args_nested_strings {
args_vec: vec![
"task",
"-q",
"--config",
"task/deno_json/deno.json",
"echo",
"string \"quoted string\""
],
output: "task/deno_json/task_additional_args_nested_strings.out",
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
});
itest!(task_additional_args_no_logic {
args_vec: vec![
"task",
"-q",
"--config",
"task/deno_json/deno.json",
"echo",
"||",
"echo",
"5"
],
output: "task/deno_json/task_additional_args_no_logic.out",
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
});
itest!(task_deno_exe_no_env {
args_vec: vec![
"task",
"-q",
"--config",
"task/deno_json/deno.json",
"deno_echo"
],
output: "task/deno_json/task_deno_exe_no_env.out",
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
env_clear: true,
});
itest!(task_piped_stdin {
args_vec: vec![
"task",
"-q",
"--config",
"task/deno_json/deno.json",
"piped"
],
output: "task/deno_json/task_piped_stdin.out",
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
});
itest!(task_package_json_no_arg {
args: "task",
cwd: Some("task/package_json/"),
output: "task/package_json/no_args.out",
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
exit_code: 1,
});
itest!(task_package_json_echo {
args: "task --quiet echo",
cwd: Some("task/package_json/"),
output: "task/package_json/echo.out",
// use a temp dir because the node_modules folder will be created
copy_temp_dir: Some("task/package_json/"),
envs: env_vars_for_npm_tests(),
exit_code: 0,
http_server: true,
});
// TODO(2.0): this should first run `deno install` // TODO(2.0): this should first run `deno install`
// itest!(task_package_json_npm_bin { // itest!(task_package_json_npm_bin {
@ -191,24 +31,6 @@ itest!(task_package_json_echo {
// http_server: true, // http_server: true,
// }); // });
itest!(task_both_no_arg {
args: "task",
cwd: Some("task/both/"),
output: "task/both/no_args.out",
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
exit_code: 1,
});
itest!(task_both_deno_json_selected {
args: "task other",
cwd: Some("task/both/"),
output: "task/both/deno_selected.out",
copy_temp_dir: Some("task/both/"),
envs: env_vars_for_npm_tests(),
exit_code: 0,
http_server: true,
});
// TODO(2.0): not entirely clear what's wrong with this test // TODO(2.0): not entirely clear what's wrong with this test
// itest!(task_both_package_json_selected { // itest!(task_both_package_json_selected {
// args: "task bin asdf", // args: "task bin asdf",
@ -220,26 +42,6 @@ itest!(task_both_deno_json_selected {
// http_server: true, // http_server: true,
// }); // });
itest!(task_both_prefers_deno {
args: "task output some text",
cwd: Some("task/both/"),
output: "task/both/prefers_deno.out",
copy_temp_dir: Some("task/both/"),
envs: env_vars_for_npm_tests(),
exit_code: 0,
http_server: true,
});
itest!(task_npx_non_existent {
args: "task non-existent",
cwd: Some("task/npx/"),
output: "task/npx/non_existent.out",
copy_temp_dir: Some("task/npx/"),
envs: env_vars_for_npm_tests(),
exit_code: 1,
http_server: true,
});
// TODO(2.0): not entirely clear what's wrong with this test but it hangs for more than 60s // TODO(2.0): not entirely clear what's wrong with this test but it hangs for more than 60s
// itest!(task_npx_on_own { // itest!(task_npx_on_own {
// args: "task on-own", // args: "task on-own",
@ -250,57 +52,3 @@ itest!(task_npx_non_existent {
// exit_code: 1, // exit_code: 1,
// http_server: true, // http_server: true,
// }); // });
itest!(task_pre_post {
args: "task test",
cwd: Some("task/package_json_pre_post/"),
output: "task/package_json_pre_post/bin.out",
copy_temp_dir: Some("task/package_json_pre_post/"),
exit_code: 0,
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
});
itest!(task_pre {
args: "task test",
cwd: Some("task/package_json_pre/"),
output: "task/package_json_pre/bin.out",
copy_temp_dir: Some("task/package_json_pre/"),
exit_code: 0,
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
});
itest!(task_post {
args: "task test",
cwd: Some("task/package_json_post/"),
output: "task/package_json_post/bin.out",
copy_temp_dir: Some("task/package_json_post/"),
exit_code: 0,
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
});
itest!(task_post_only {
args: "task test",
cwd: Some("task/package_json_post_only/"),
output: "task/package_json_post_only/bin.out",
copy_temp_dir: Some("task/package_json_post_only/"),
exit_code: 1,
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
});
itest!(task_pre_only {
args: "task test",
cwd: Some("task/package_json_pre_only/"),
output: "task/package_json_pre_only/bin.out",
copy_temp_dir: Some("task/package_json_pre_only/"),
exit_code: 1,
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
});
itest!(task_deno_no_pre_post {
args: "task test",
cwd: Some("task/deno_json_pre_post/"),
output: "task/deno_json_pre_post/bin.out",
copy_temp_dir: Some("task/deno_json_pre_post/"),
exit_code: 0,
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
});

View file

@ -0,0 +1,7 @@
{
"args": "task -q --config deno.json echo 2",
"output": "task_additional_args.out",
"envs": {
"NO_COLOR": "1"
}
}

View file

@ -0,0 +1,5 @@
{
"tasks": {
"echo": "echo 1"
}
}

View file

@ -0,0 +1,7 @@
{
"args": "task -q --config deno.json echo string \"quoted string\"",
"output": "task_additional_args_nested_strings.out",
"envs": {
"NO_COLOR": "1"
}
}

View file

@ -0,0 +1,5 @@
{
"tasks": {
"echo": "echo 1"
}
}

View file

@ -0,0 +1,7 @@
{
"args": "task -q --config deno.json echo || echo 5",
"output": "task_additional_args_no_logic.out",
"envs": {
"NO_COLOR": "1"
}
}

View file

@ -0,0 +1,5 @@
{
"tasks": {
"echo": "echo 1"
}
}

View file

@ -0,0 +1,7 @@
{
"args": "task -q --config deno.json echo $(echo 5)",
"output": "task_additional_args_no_shell_expansion.out",
"envs": {
"NO_COLOR": "1"
}
}

View file

@ -0,0 +1,5 @@
{
"tasks": {
"echo": "echo 1"
}
}

View file

@ -0,0 +1,7 @@
{
"args": "task -q --config deno.json boolean_logic",
"output": "task_boolean_logic.out",
"envs": {
"NO_COLOR": "1"
}
}

View file

@ -0,0 +1,5 @@
{
"tasks": {
"boolean_logic": "sleep 0.1 && echo 3 && echo 4 & echo 1 && echo 2 || echo NOPE"
}
}

View file

@ -0,0 +1,9 @@
{
"args": "task --config deno.json other",
"output": "deno_selected.out",
"envs": {
"NO_COLOR": "1",
"NPM_CONFIG_REGISTRY": "http://localhost:4260/"
},
"exitCode": 0
}

View file

@ -0,0 +1,6 @@
{
"tasks": {
"output": "deno eval 'console.log(1)'",
"other": "deno eval 'console.log(2)'"
}
}

View file

@ -0,0 +1,8 @@
{
"args": "task --config deno.json",
"output": "no_args.out",
"envs": {
"NO_COLOR": "1"
},
"exitCode": 1
}

View file

@ -0,0 +1,6 @@
{
"tasks": {
"output": "deno eval 'console.log(1)'",
"other": "deno eval 'console.log(2)'"
}
}

View file

@ -0,0 +1,9 @@
{
"scripts": {
"bin": "cli-esm testing this out",
"output": "echo should never be called or shown"
},
"dependencies": {
"other": "npm:@denotest/bin@1.0"
}
}

View file

@ -0,0 +1,9 @@
{
"args": "task --config deno.json output some text",
"output": "prefers_deno.out",
"envs": {
"NO_COLOR": "1",
"NPM_CONFIG_REGISTRY": "http://localhost:4260/"
},
"exitCode": 0
}

View file

@ -0,0 +1,6 @@
{
"tasks": {
"output": "deno eval 'console.log(1)'",
"other": "deno eval 'console.log(2)'"
}
}

View file

@ -0,0 +1,8 @@
{
"args": "task -q --config deno.json --cwd .. echo_cwd",
"output": "task_cwd.out",
"envs": {
"NO_COLOR": "1"
},
"exitCode": 0
}

View file

@ -0,0 +1,5 @@
{
"tasks": {
"echo_cwd": "echo $(pwd)"
}
}

View file

@ -0,0 +1 @@
[WILDCARD]task

View file

@ -0,0 +1,8 @@
{
"args": "task -q --cwd deno.json",
"output": "task_no_args.out",
"envs": {
"NO_COLOR": "1"
},
"exitCode": 1
}

View file

@ -0,0 +1,7 @@
{
"args": "task -q --config deno.json deno_echo",
"output": "task_deno_exe_no_env.out",
"envs": {
"NO_COLOR": "1"
}
}

View file

@ -0,0 +1,5 @@
{
"tasks": {
"deno_echo": "deno eval 'console.log(5)'"
}
}

View file

@ -0,0 +1,8 @@
{
"args": "task --config deno.json test",
"output": "bin.out",
"envs": {
"NO_COLOR": "1"
},
"exitCode": 0
}

View file

@ -0,0 +1,4 @@
{
"args": "task -q --cwd deno.json echo_emoji",
"output": "main.out"
}

View file

@ -0,0 +1,5 @@
{
"tasks": {
"echo_emoji": "echo 🔥"
}
}

View file

@ -0,0 +1 @@
🔥

View file

@ -0,0 +1,8 @@
{
"args": "task --config deno.json exit_code_5",
"output": "task_exit_code_5.out",
"envs": {
"NO_COLOR": "1"
},
"exitCode": 5
}

View file

@ -0,0 +1,5 @@
{
"tasks": {
"exit_code_5": "echo $(echo 10 ; exit 2) && exit 5"
}
}

View file

@ -0,0 +1,8 @@
{
"args": "task -q --config deno.json --cwd .. echo_init_cwd",
"output": "task_init_cwd.out",
"envs": {
"NO_COLOR": "1"
},
"exitCode": 0
}

View file

@ -0,0 +1,5 @@
{
"tasks": {
"echo_init_cwd": "echo $INIT_CWD"
}
}

View file

@ -0,0 +1 @@
[WILDCARD]init_cwd

View file

@ -0,0 +1,9 @@
{
"args": "task -q --config deno.json echo_init_cwd",
"output": "task_init_cwd_already_set.out",
"envs": {
"NO_COLOR": "1",
"INIT_CWD": "HELLO"
},
"exitCode": 0
}

View file

@ -0,0 +1,5 @@
{
"tasks": {
"echo_init_cwd": "echo $INIT_CWD"
}
}

View file

@ -0,0 +1,8 @@
{
"args": "task -q --config deno.json",
"output": "task_no_args.out",
"envs": {
"NO_COLOR": "1"
},
"exitCode": 1
}

View file

@ -0,0 +1,13 @@
{
"tasks": {
"boolean_logic": "sleep 0.1 && echo 3 && echo 4 & echo 1 && echo 2 || echo NOPE",
"echo": "echo 1",
"deno_echo": "deno eval 'console.log(5)'",
"strings": "deno run main.ts && deno eval \"console.log(\\\"test\\\")\"",
"piped": "echo 12345 | (deno eval 'const b = new Uint8Array(1);Deno.stdin.readSync(b);console.log(b)' && deno eval 'const b = new Uint8Array(1);Deno.stdin.readSync(b);console.log(b)')",
"exit_code_5": "echo $(echo 10 ; exit 2) && exit 5",
"echo_cwd": "echo $(pwd)",
"echo_init_cwd": "echo $INIT_CWD",
"echo_emoji": "echo 🔥"
}
}

View file

@ -0,0 +1,19 @@
Available tasks:
- boolean_logic
sleep 0.1 && echo 3 && echo 4 & echo 1 && echo 2 || echo NOPE
- echo
echo 1
- deno_echo
deno eval 'console.log(5)'
- strings
deno run main.ts && deno eval "console.log(\"test\")"
- piped
echo 12345 | (deno eval 'const b = new Uint8Array(1);Deno.stdin.readSync(b);console.log(b)' && deno eval 'const b = new Uint8Array(1);Deno.stdin.readSync(b);console.log(b)')
- exit_code_5
echo $(echo 10 ; exit 2) && exit 5
- echo_cwd
echo $(pwd)
- echo_init_cwd
echo $INIT_CWD
- echo_emoji
echo 🔥

View file

@ -0,0 +1,8 @@
{
"args": "task --config deno.json non_existent",
"output": "task_non_existent.out",
"envs": {
"NO_COLOR": "1"
},
"exitCode": 1
}

View file

@ -0,0 +1,13 @@
{
"tasks": {
"boolean_logic": "sleep 0.1 && echo 3 && echo 4 & echo 1 && echo 2 || echo NOPE",
"echo": "echo 1",
"deno_echo": "deno eval 'console.log(5)'",
"strings": "deno run main.ts && deno eval \"console.log(\\\"test\\\")\"",
"piped": "echo 12345 | (deno eval 'const b = new Uint8Array(1);Deno.stdin.readSync(b);console.log(b)' && deno eval 'const b = new Uint8Array(1);Deno.stdin.readSync(b);console.log(b)')",
"exit_code_5": "echo $(echo 10 ; exit 2) && exit 5",
"echo_cwd": "echo $(pwd)",
"echo_init_cwd": "echo $INIT_CWD",
"echo_emoji": "echo 🔥"
}
}

View file

@ -0,0 +1,9 @@
{
"args": "task non-existent",
"output": "non_existent.out",
"envs": {
"NO_COLOR": "1",
"NPM_CONFIG_REGISTRY": "http://localhost:4260/"
},
"exitCode": 1
}

View file

@ -0,0 +1,6 @@
{
"scripts": {
"non-existent": "npx this-command-should-not-exist-for-you",
"on-own": "npx"
}
}

View file

@ -0,0 +1,9 @@
{
"args": "task --quiet echo",
"output": "echo.out",
"envs": {
"NO_COLOR": "1",
"NPM_CONFIG_REGISTRY": "http://localhost:4260/"
},
"exitCode": 0
}

View file

@ -0,0 +1,10 @@
{
"scripts": {
"echo": "deno eval 'console.log(1)'",
"bin": "@denotest/bin hi && cli-esm testing this out && npx cli-cjs test"
},
"dependencies": {
"@denotest/bin": "0.5",
"other": "npm:@denotest/bin@1.0"
}
}

View file

@ -0,0 +1,8 @@
{
"args": "task",
"output": "no_args.out",
"envs": {
"NO_COLOR": "1"
},
"exitCode": 1
}

View file

@ -0,0 +1,10 @@
{
"scripts": {
"echo": "deno eval 'console.log(1)'",
"bin": "@denotest/bin hi && cli-esm testing this out && npx cli-cjs test"
},
"dependencies": {
"@denotest/bin": "0.5",
"other": "npm:@denotest/bin@1.0"
}
}

View file

@ -0,0 +1,7 @@
{
"args": "task -q --config deno.json piped",
"output": "task_piped_stdin.out",
"envs": {
"NO_COLOR": "1"
}
}

View file

@ -0,0 +1,5 @@
{
"tasks": {
"piped": "echo 12345 | (deno eval 'const b = new Uint8Array(1);Deno.stdin.readSync(b);console.log(b)' && deno eval 'const b = new Uint8Array(1);Deno.stdin.readSync(b);console.log(b)')"
}
}

View file

@ -0,0 +1,8 @@
{
"args": "task test",
"output": "bin.out",
"envs": {
"NO_COLOR": "1"
},
"exitCode": 0
}

View file

@ -0,0 +1,8 @@
{
"args": "task test",
"output": "bin.out",
"envs": {
"NO_COLOR": "1"
},
"exitCode": 1
}

View file

@ -0,0 +1,8 @@
{
"args": "task test",
"output": "bin.out",
"envs": {
"NO_COLOR": "1"
},
"exitCode": 0
}

View file

@ -0,0 +1,8 @@
{
"args": "task test",
"output": "bin.out",
"envs": {
"NO_COLOR": "1"
},
"exitCode": 1
}

View file

@ -0,0 +1,8 @@
{
"args": "task test",
"output": "bin.out",
"envs": {
"NO_COLOR": "1"
},
"exitCode": 0
}

View file

View file

@ -1 +0,0 @@
[WILDCARD]tests

View file

@ -1 +0,0 @@
[WILDCARD]testdata

View file

@ -1 +0,0 @@
0

View file

@ -1 +0,0 @@
0

View file

@ -1 +0,0 @@
0

View file

@ -1 +0,0 @@
0

View file

@ -1 +0,0 @@
1

View file

@ -1 +0,0 @@
0

View file

@ -222,7 +222,7 @@ async function ensureNoNewITests() {
"repl_tests.rs": 0, "repl_tests.rs": 0,
"run_tests.rs": 338, "run_tests.rs": 338,
"shared_library_tests.rs": 0, "shared_library_tests.rs": 0,
"task_tests.rs": 30, "task_tests.rs": 4,
"test_tests.rs": 74, "test_tests.rs": 74,
"upgrade_tests.rs": 0, "upgrade_tests.rs": 0,
"vendor_tests.rs": 1, "vendor_tests.rs": 1,