2023-01-12 20:59:13 -05:00
|
|
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
|
|
|
|
|
|
// Most of the tests for this are in deno_task_shell.
|
|
|
|
// These tests are intended to only test integration.
|
|
|
|
|
2023-02-22 22:45:35 -05:00
|
|
|
use test_util::env_vars_for_npm_tests;
|
|
|
|
|
2023-01-12 20:59:13 -05:00
|
|
|
itest!(task_no_args {
|
2023-02-22 22:45:35 -05:00
|
|
|
args: "task -q --config task/deno_json/deno.json",
|
|
|
|
output: "task/deno_json/task_no_args.out",
|
2023-01-12 20:59:13 -05:00
|
|
|
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
|
|
|
|
exit_code: 1,
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(task_cwd {
|
2023-02-22 22:45:35 -05:00
|
|
|
args: "task -q --config task/deno_json/deno.json --cwd .. echo_cwd",
|
|
|
|
output: "task/deno_json/task_cwd.out",
|
2023-01-12 20:59:13 -05:00
|
|
|
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
|
|
|
|
exit_code: 0,
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(task_init_cwd {
|
2023-02-22 22:45:35 -05:00
|
|
|
args: "task -q --config task/deno_json/deno.json --cwd .. echo_init_cwd",
|
|
|
|
output: "task/deno_json/task_init_cwd.out",
|
2023-01-12 20:59:13 -05:00
|
|
|
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
|
|
|
|
exit_code: 0,
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(task_init_cwd_already_set {
|
2023-02-22 22:45:35 -05:00
|
|
|
args: "task -q --config task/deno_json/deno.json echo_init_cwd",
|
|
|
|
output: "task/deno_json/task_init_cwd_already_set.out",
|
2023-01-12 20:59:13 -05:00
|
|
|
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 {
|
2023-02-22 22:45:35 -05:00
|
|
|
args: "task -q --cwd task/deno_json",
|
|
|
|
output: "task/deno_json/task_no_args.out",
|
2023-01-12 20:59:13 -05:00
|
|
|
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
|
|
|
|
exit_code: 1,
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(task_non_existent {
|
2023-02-22 22:45:35 -05:00
|
|
|
args: "task --config task/deno_json/deno.json non_existent",
|
|
|
|
output: "task/deno_json/task_non_existent.out",
|
2023-01-12 20:59:13 -05:00
|
|
|
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
|
2023-02-22 22:45:35 -05:00
|
|
|
let args = "task --config task/deno_json/deno.json echo_emoji";
|
2023-01-12 20:59:13 -05:00
|
|
|
use test_util::PtyData::*;
|
|
|
|
test_util::test_pty2(args, vec![Output("Task echo_emoji echo 🔥\r\n🔥")]);
|
|
|
|
}
|
|
|
|
|
|
|
|
itest!(task_boolean_logic {
|
2023-02-22 22:45:35 -05:00
|
|
|
args: "task -q --config task/deno_json/deno.json boolean_logic",
|
|
|
|
output: "task/deno_json/task_boolean_logic.out",
|
2023-01-12 20:59:13 -05:00
|
|
|
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(task_exit_code_5 {
|
2023-02-22 22:45:35 -05:00
|
|
|
args: "task --config task/deno_json/deno.json exit_code_5",
|
|
|
|
output: "task/deno_json/task_exit_code_5.out",
|
2023-01-12 20:59:13 -05:00
|
|
|
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
|
|
|
|
exit_code: 5,
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(task_additional_args {
|
2023-02-22 22:45:35 -05:00
|
|
|
args: "task -q --config task/deno_json/deno.json echo 2",
|
|
|
|
output: "task/deno_json/task_additional_args.out",
|
2023-01-12 20:59:13 -05:00
|
|
|
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(task_additional_args_no_shell_expansion {
|
|
|
|
args_vec: vec![
|
|
|
|
"task",
|
|
|
|
"-q",
|
|
|
|
"--config",
|
2023-02-22 22:45:35 -05:00
|
|
|
"task/deno_json/deno.json",
|
2023-01-12 20:59:13 -05:00
|
|
|
"echo",
|
|
|
|
"$(echo 5)"
|
|
|
|
],
|
2023-02-22 22:45:35 -05:00
|
|
|
output: "task/deno_json/task_additional_args_no_shell_expansion.out",
|
2023-01-12 20:59:13 -05:00
|
|
|
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(task_additional_args_nested_strings {
|
|
|
|
args_vec: vec![
|
|
|
|
"task",
|
|
|
|
"-q",
|
|
|
|
"--config",
|
2023-02-22 22:45:35 -05:00
|
|
|
"task/deno_json/deno.json",
|
2023-01-12 20:59:13 -05:00
|
|
|
"echo",
|
|
|
|
"string \"quoted string\""
|
|
|
|
],
|
2023-02-22 22:45:35 -05:00
|
|
|
output: "task/deno_json/task_additional_args_nested_strings.out",
|
2023-01-12 20:59:13 -05:00
|
|
|
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(task_additional_args_no_logic {
|
|
|
|
args_vec: vec![
|
|
|
|
"task",
|
|
|
|
"-q",
|
|
|
|
"--config",
|
2023-02-22 22:45:35 -05:00
|
|
|
"task/deno_json/deno.json",
|
2023-01-12 20:59:13 -05:00
|
|
|
"echo",
|
|
|
|
"||",
|
|
|
|
"echo",
|
|
|
|
"5"
|
|
|
|
],
|
2023-02-22 22:45:35 -05:00
|
|
|
output: "task/deno_json/task_additional_args_no_logic.out",
|
2023-01-12 20:59:13 -05:00
|
|
|
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(task_deno_exe_no_env {
|
2023-02-22 22:45:35 -05:00
|
|
|
args_vec: vec![
|
|
|
|
"task",
|
|
|
|
"-q",
|
|
|
|
"--config",
|
|
|
|
"task/deno_json/deno.json",
|
|
|
|
"deno_echo"
|
|
|
|
],
|
|
|
|
output: "task/deno_json/task_deno_exe_no_env.out",
|
2023-01-12 20:59:13 -05:00
|
|
|
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
|
|
|
|
env_clear: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(task_piped_stdin {
|
2023-02-22 22:45:35 -05:00
|
|
|
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,
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(task_package_json_npm_bin {
|
|
|
|
args: "task bin extra",
|
|
|
|
cwd: Some("task/package_json/"),
|
|
|
|
output: "task/package_json/bin.out",
|
|
|
|
copy_temp_dir: Some("task/package_json/"),
|
|
|
|
envs: env_vars_for_npm_tests(),
|
|
|
|
exit_code: 0,
|
|
|
|
http_server: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(task_both_no_arg {
|
|
|
|
args: "task",
|
|
|
|
cwd: Some("task/both/"),
|
|
|
|
output: "task/both/no_args.out",
|
2023-01-12 20:59:13 -05:00
|
|
|
envs: vec![("NO_COLOR".to_string(), "1".to_string())],
|
2023-02-22 22:45:35 -05:00
|
|
|
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,
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(task_both_package_json_selected {
|
|
|
|
args: "task bin asdf",
|
|
|
|
cwd: Some("task/both/"),
|
|
|
|
output: "task/both/package_json_selected.out",
|
|
|
|
copy_temp_dir: Some("task/both/"),
|
|
|
|
envs: env_vars_for_npm_tests(),
|
|
|
|
exit_code: 0,
|
|
|
|
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,
|
|
|
|
});
|
|
|
|
|
|
|
|
itest!(task_npx_on_own {
|
|
|
|
args: "task on-own",
|
|
|
|
cwd: Some("task/npx/"),
|
|
|
|
output: "task/npx/on_own.out",
|
|
|
|
copy_temp_dir: Some("task/npx/"),
|
|
|
|
envs: env_vars_for_npm_tests(),
|
|
|
|
exit_code: 1,
|
|
|
|
http_server: true,
|
2023-01-12 20:59:13 -05:00
|
|
|
});
|