Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: deprecate task itests #25558

Merged
merged 5 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
258 changes: 3 additions & 255 deletions tests/integration/task_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,169 +3,9 @@
// Most of the tests for this are in deno_task_shell.
// These tests are intended to only test integration.

use test_util::env_vars_for_npm_tests;
use test_util::itest;
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,
});
// use test_util::env_vars_for_npm_tests;
// use test_util::itest;
// use test_util::TestContext;

// TODO(2.0): this should first run `deno install`
// itest!(task_package_json_npm_bin {
Expand All @@ -191,24 +31,6 @@ itest!(task_package_json_echo {
// 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
// itest!(task_both_package_json_selected {
// args: "task bin asdf",
Expand All @@ -220,26 +42,6 @@ itest!(task_both_deno_json_selected {
// 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
// itest!(task_npx_on_own {
// args: "task on-own",
Expand All @@ -250,57 +52,3 @@ itest!(task_npx_non_existent {
// exit_code: 1,
// 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())],
});
7 changes: 7 additions & 0 deletions tests/specs/task/additional_args/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"args": "task -q --config deno.json echo 2",
"output": "task_additional_args.out",
"envs": {
"NO_COLOR": "1"
}
}
5 changes: 5 additions & 0 deletions tests/specs/task/additional_args/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tasks": {
"echo": "echo 1"
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
5 changes: 5 additions & 0 deletions tests/specs/task/additional_args_nested_strings/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tasks": {
"echo": "echo 1"
}
}
7 changes: 7 additions & 0 deletions tests/specs/task/additional_args_no_logic/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"args": "task -q --config deno.json echo || echo 5",
"output": "task_additional_args_no_logic.out",
"envs": {
"NO_COLOR": "1"
}
}
5 changes: 5 additions & 0 deletions tests/specs/task/additional_args_no_logic/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tasks": {
"echo": "echo 1"
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
5 changes: 5 additions & 0 deletions tests/specs/task/additional_args_no_shell_expansion/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tasks": {
"echo": "echo 1"
}
}
7 changes: 7 additions & 0 deletions tests/specs/task/boolean_logic/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"args": "task -q --config deno.json boolean_logic",
"output": "task_boolean_logic.out",
"envs": {
"NO_COLOR": "1"
}
}
5 changes: 5 additions & 0 deletions tests/specs/task/boolean_logic/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tasks": {
"boolean_logic": "sleep 0.1 && echo 3 && echo 4 & echo 1 && echo 2 || echo NOPE"
}
}
9 changes: 9 additions & 0 deletions tests/specs/task/both_deno_json_selected/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -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
}
6 changes: 6 additions & 0 deletions tests/specs/task/both_deno_json_selected/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"tasks": {
"output": "deno eval 'console.log(1)'",
"other": "deno eval 'console.log(2)'"
}
}
8 changes: 8 additions & 0 deletions tests/specs/task/both_no_arg/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"args": "task --config deno.json",
"output": "no_args.out",
"envs": {
"NO_COLOR": "1"
},
"exitCode": 1
}
6 changes: 6 additions & 0 deletions tests/specs/task/both_no_arg/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"tasks": {
"output": "deno eval 'console.log(1)'",
"other": "deno eval 'console.log(2)'"
}
}
9 changes: 9 additions & 0 deletions tests/specs/task/both_no_arg/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
Loading