diff options
93 files changed, 375 insertions, 264 deletions
diff --git a/tests/integration/task_tests.rs b/tests/integration/task_tests.rs index aba83a66d..895e643a0 100644 --- a/tests/integration/task_tests.rs +++ b/tests/integration/task_tests.rs @@ -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 { @@ -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", @@ -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", @@ -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())], -}); diff --git a/tests/specs/task/additional_args/__test__.jsonc b/tests/specs/task/additional_args/__test__.jsonc new file mode 100644 index 000000000..b75c638ff --- /dev/null +++ b/tests/specs/task/additional_args/__test__.jsonc @@ -0,0 +1,7 @@ +{ + "args": "task -q --config deno.json echo 2", + "output": "task_additional_args.out", + "envs": { + "NO_COLOR": "1" + } +} diff --git a/tests/specs/task/additional_args/deno.json b/tests/specs/task/additional_args/deno.json new file mode 100644 index 000000000..c1a379c46 --- /dev/null +++ b/tests/specs/task/additional_args/deno.json @@ -0,0 +1,5 @@ +{ + "tasks": { + "echo": "echo 1" + } +} diff --git a/tests/testdata/task/deno_json/task_additional_args.out b/tests/specs/task/additional_args/task_additional_args.out index 8d04f961a..8d04f961a 100644 --- a/tests/testdata/task/deno_json/task_additional_args.out +++ b/tests/specs/task/additional_args/task_additional_args.out diff --git a/tests/specs/task/additional_args_nested_strings/__test__.jsonc b/tests/specs/task/additional_args_nested_strings/__test__.jsonc new file mode 100644 index 000000000..e543e31ac --- /dev/null +++ b/tests/specs/task/additional_args_nested_strings/__test__.jsonc @@ -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" + } +} diff --git a/tests/specs/task/additional_args_nested_strings/deno.json b/tests/specs/task/additional_args_nested_strings/deno.json new file mode 100644 index 000000000..c1a379c46 --- /dev/null +++ b/tests/specs/task/additional_args_nested_strings/deno.json @@ -0,0 +1,5 @@ +{ + "tasks": { + "echo": "echo 1" + } +} diff --git a/tests/testdata/task/deno_json/task_additional_args_nested_strings.out b/tests/specs/task/additional_args_nested_strings/task_additional_args_nested_strings.out index 0e5f35c7f..0e5f35c7f 100644 --- a/tests/testdata/task/deno_json/task_additional_args_nested_strings.out +++ b/tests/specs/task/additional_args_nested_strings/task_additional_args_nested_strings.out diff --git a/tests/specs/task/additional_args_no_logic/__test__.jsonc b/tests/specs/task/additional_args_no_logic/__test__.jsonc new file mode 100644 index 000000000..849f8bf66 --- /dev/null +++ b/tests/specs/task/additional_args_no_logic/__test__.jsonc @@ -0,0 +1,7 @@ +{ + "args": "task -q --config deno.json echo || echo 5", + "output": "task_additional_args_no_logic.out", + "envs": { + "NO_COLOR": "1" + } +} diff --git a/tests/specs/task/additional_args_no_logic/deno.json b/tests/specs/task/additional_args_no_logic/deno.json new file mode 100644 index 000000000..c1a379c46 --- /dev/null +++ b/tests/specs/task/additional_args_no_logic/deno.json @@ -0,0 +1,5 @@ +{ + "tasks": { + "echo": "echo 1" + } +} diff --git a/tests/testdata/task/deno_json/task_additional_args_no_logic.out b/tests/specs/task/additional_args_no_logic/task_additional_args_no_logic.out index a4886a60d..a4886a60d 100644 --- a/tests/testdata/task/deno_json/task_additional_args_no_logic.out +++ b/tests/specs/task/additional_args_no_logic/task_additional_args_no_logic.out diff --git a/tests/specs/task/additional_args_no_shell_expansion/__test__.jsonc b/tests/specs/task/additional_args_no_shell_expansion/__test__.jsonc new file mode 100644 index 000000000..202321e39 --- /dev/null +++ b/tests/specs/task/additional_args_no_shell_expansion/__test__.jsonc @@ -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" + } +} diff --git a/tests/specs/task/additional_args_no_shell_expansion/deno.json b/tests/specs/task/additional_args_no_shell_expansion/deno.json new file mode 100644 index 000000000..c1a379c46 --- /dev/null +++ b/tests/specs/task/additional_args_no_shell_expansion/deno.json @@ -0,0 +1,5 @@ +{ + "tasks": { + "echo": "echo 1" + } +} diff --git a/tests/testdata/task/deno_json/task_additional_args_no_shell_expansion.out b/tests/specs/task/additional_args_no_shell_expansion/task_additional_args_no_shell_expansion.out index 826a3aaf1..826a3aaf1 100644 --- a/tests/testdata/task/deno_json/task_additional_args_no_shell_expansion.out +++ b/tests/specs/task/additional_args_no_shell_expansion/task_additional_args_no_shell_expansion.out diff --git a/tests/specs/task/boolean_logic/__test__.jsonc b/tests/specs/task/boolean_logic/__test__.jsonc new file mode 100644 index 000000000..c96e2256c --- /dev/null +++ b/tests/specs/task/boolean_logic/__test__.jsonc @@ -0,0 +1,7 @@ +{ + "args": "task -q --config deno.json boolean_logic", + "output": "task_boolean_logic.out", + "envs": { + "NO_COLOR": "1" + } +} diff --git a/tests/specs/task/boolean_logic/deno.json b/tests/specs/task/boolean_logic/deno.json new file mode 100644 index 000000000..4d3aeb4ce --- /dev/null +++ b/tests/specs/task/boolean_logic/deno.json @@ -0,0 +1,5 @@ +{ + "tasks": { + "boolean_logic": "sleep 0.1 && echo 3 && echo 4 & echo 1 && echo 2 || echo NOPE" + } +} diff --git a/tests/testdata/task/deno_json/task_boolean_logic.out b/tests/specs/task/boolean_logic/task_boolean_logic.out index 94ebaf900..94ebaf900 100644 --- a/tests/testdata/task/deno_json/task_boolean_logic.out +++ b/tests/specs/task/boolean_logic/task_boolean_logic.out diff --git a/tests/specs/task/both_deno_json_selected/__test__.jsonc b/tests/specs/task/both_deno_json_selected/__test__.jsonc new file mode 100644 index 000000000..7b0d31cbc --- /dev/null +++ b/tests/specs/task/both_deno_json_selected/__test__.jsonc @@ -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 +} diff --git a/tests/specs/task/both_deno_json_selected/deno.json b/tests/specs/task/both_deno_json_selected/deno.json new file mode 100644 index 000000000..1038609a4 --- /dev/null +++ b/tests/specs/task/both_deno_json_selected/deno.json @@ -0,0 +1,6 @@ +{ + "tasks": { + "output": "deno eval 'console.log(1)'", + "other": "deno eval 'console.log(2)'" + } +} diff --git a/tests/testdata/task/both/deno_selected.out b/tests/specs/task/both_deno_json_selected/deno_selected.out index f5bbab26d..f5bbab26d 100644 --- a/tests/testdata/task/both/deno_selected.out +++ b/tests/specs/task/both_deno_json_selected/deno_selected.out diff --git a/tests/specs/task/both_no_arg/__test__.jsonc b/tests/specs/task/both_no_arg/__test__.jsonc new file mode 100644 index 000000000..c80db130e --- /dev/null +++ b/tests/specs/task/both_no_arg/__test__.jsonc @@ -0,0 +1,8 @@ +{ + "args": "task --config deno.json", + "output": "no_args.out", + "envs": { + "NO_COLOR": "1" + }, + "exitCode": 1 +} diff --git a/tests/specs/task/both_no_arg/deno.json b/tests/specs/task/both_no_arg/deno.json new file mode 100644 index 000000000..1038609a4 --- /dev/null +++ b/tests/specs/task/both_no_arg/deno.json @@ -0,0 +1,6 @@ +{ + "tasks": { + "output": "deno eval 'console.log(1)'", + "other": "deno eval 'console.log(2)'" + } +} diff --git a/tests/testdata/task/both/no_args.out b/tests/specs/task/both_no_arg/no_args.out index fce690b70..fce690b70 100644 --- a/tests/testdata/task/both/no_args.out +++ b/tests/specs/task/both_no_arg/no_args.out diff --git a/tests/specs/task/both_no_arg/package.json b/tests/specs/task/both_no_arg/package.json new file mode 100644 index 000000000..708ccc6b1 --- /dev/null +++ b/tests/specs/task/both_no_arg/package.json @@ -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" + } +} diff --git a/tests/specs/task/both_prefers_deno/__test__.jsonc b/tests/specs/task/both_prefers_deno/__test__.jsonc new file mode 100644 index 000000000..74bfedf8c --- /dev/null +++ b/tests/specs/task/both_prefers_deno/__test__.jsonc @@ -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 +} diff --git a/tests/specs/task/both_prefers_deno/deno.json b/tests/specs/task/both_prefers_deno/deno.json new file mode 100644 index 000000000..1038609a4 --- /dev/null +++ b/tests/specs/task/both_prefers_deno/deno.json @@ -0,0 +1,6 @@ +{ + "tasks": { + "output": "deno eval 'console.log(1)'", + "other": "deno eval 'console.log(2)'" + } +} diff --git a/tests/testdata/task/both/prefers_deno.out b/tests/specs/task/both_prefers_deno/prefers_deno.out index 391737272..391737272 100644 --- a/tests/testdata/task/both/prefers_deno.out +++ b/tests/specs/task/both_prefers_deno/prefers_deno.out diff --git a/tests/specs/task/cwd/__test__.jsonc b/tests/specs/task/cwd/__test__.jsonc new file mode 100644 index 000000000..c291fe0c9 --- /dev/null +++ b/tests/specs/task/cwd/__test__.jsonc @@ -0,0 +1,8 @@ +{ + "args": "task -q --config deno.json --cwd .. echo_cwd", + "output": "task_cwd.out", + "envs": { + "NO_COLOR": "1" + }, + "exitCode": 0 +} diff --git a/tests/specs/task/cwd/deno.json b/tests/specs/task/cwd/deno.json new file mode 100644 index 000000000..b7f513a3f --- /dev/null +++ b/tests/specs/task/cwd/deno.json @@ -0,0 +1,5 @@ +{ + "tasks": { + "echo_cwd": "echo $(pwd)" + } +} diff --git a/tests/specs/task/cwd/task_cwd.out b/tests/specs/task/cwd/task_cwd.out new file mode 100644 index 000000000..1a8bf6ad0 --- /dev/null +++ b/tests/specs/task/cwd/task_cwd.out @@ -0,0 +1 @@ +[WILDCARD]task diff --git a/tests/specs/task/cwd_resolves_config_from_specified_dir/__test__.jsonc b/tests/specs/task/cwd_resolves_config_from_specified_dir/__test__.jsonc new file mode 100644 index 000000000..97898e14f --- /dev/null +++ b/tests/specs/task/cwd_resolves_config_from_specified_dir/__test__.jsonc @@ -0,0 +1,8 @@ +{ + "args": "task -q --cwd deno.json", + "output": "task_no_args.out", + "envs": { + "NO_COLOR": "1" + }, + "exitCode": 1 +} diff --git a/tests/testdata/task/deno_json/deno.json b/tests/specs/task/cwd_resolves_config_from_specified_dir/deno.json index c57426d25..c57426d25 100644 --- a/tests/testdata/task/deno_json/deno.json +++ b/tests/specs/task/cwd_resolves_config_from_specified_dir/deno.json diff --git a/tests/testdata/task/deno_json/task_no_args.out b/tests/specs/task/cwd_resolves_config_from_specified_dir/task_no_args.out index 18f86fce6..18f86fce6 100644 --- a/tests/testdata/task/deno_json/task_no_args.out +++ b/tests/specs/task/cwd_resolves_config_from_specified_dir/task_no_args.out diff --git a/tests/specs/task/deno_exe_no_env/__test__.jsonc b/tests/specs/task/deno_exe_no_env/__test__.jsonc new file mode 100644 index 000000000..b021669e0 --- /dev/null +++ b/tests/specs/task/deno_exe_no_env/__test__.jsonc @@ -0,0 +1,7 @@ +{ + "args": "task -q --config deno.json deno_echo", + "output": "task_deno_exe_no_env.out", + "envs": { + "NO_COLOR": "1" + } +} diff --git a/tests/specs/task/deno_exe_no_env/deno.json b/tests/specs/task/deno_exe_no_env/deno.json new file mode 100644 index 000000000..d519e2139 --- /dev/null +++ b/tests/specs/task/deno_exe_no_env/deno.json @@ -0,0 +1,5 @@ +{ + "tasks": { + "deno_echo": "deno eval 'console.log(5)'" + } +} diff --git a/tests/testdata/task/deno_json/task_deno_exe_no_env.out b/tests/specs/task/deno_exe_no_env/task_deno_exe_no_env.out index 7ed6ff82d..7ed6ff82d 100644 --- a/tests/testdata/task/deno_json/task_deno_exe_no_env.out +++ b/tests/specs/task/deno_exe_no_env/task_deno_exe_no_env.out diff --git a/tests/specs/task/deno_no_pre_post/__test__.jsonc b/tests/specs/task/deno_no_pre_post/__test__.jsonc new file mode 100644 index 000000000..17bdc9ace --- /dev/null +++ b/tests/specs/task/deno_no_pre_post/__test__.jsonc @@ -0,0 +1,8 @@ +{ + "args": "task --config deno.json test", + "output": "bin.out", + "envs": { + "NO_COLOR": "1" + }, + "exitCode": 0 +} diff --git a/tests/testdata/task/deno_json_pre_post/bin.out b/tests/specs/task/deno_no_pre_post/bin.out index ad66595f1..ad66595f1 100644 --- a/tests/testdata/task/deno_json_pre_post/bin.out +++ b/tests/specs/task/deno_no_pre_post/bin.out diff --git a/tests/testdata/task/deno_json_pre_post/deno.json b/tests/specs/task/deno_no_pre_post/deno.json index 165b92e3a..165b92e3a 100644 --- a/tests/testdata/task/deno_json_pre_post/deno.json +++ b/tests/specs/task/deno_no_pre_post/deno.json diff --git a/tests/specs/task/emoji/__test__.jsonc b/tests/specs/task/emoji/__test__.jsonc new file mode 100644 index 000000000..fde5b1545 --- /dev/null +++ b/tests/specs/task/emoji/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "task -q --cwd deno.json echo_emoji", + "output": "main.out" +} diff --git a/tests/specs/task/emoji/deno.json b/tests/specs/task/emoji/deno.json new file mode 100644 index 000000000..5ef0d014a --- /dev/null +++ b/tests/specs/task/emoji/deno.json @@ -0,0 +1,5 @@ +{ + "tasks": { + "echo_emoji": "echo š„" + } +} diff --git a/tests/specs/task/emoji/main.out b/tests/specs/task/emoji/main.out new file mode 100644 index 000000000..6ece63dc1 --- /dev/null +++ b/tests/specs/task/emoji/main.out @@ -0,0 +1 @@ +š„ diff --git a/tests/specs/task/exit_code_5/__test__.jsonc b/tests/specs/task/exit_code_5/__test__.jsonc new file mode 100644 index 000000000..123710b78 --- /dev/null +++ b/tests/specs/task/exit_code_5/__test__.jsonc @@ -0,0 +1,8 @@ +{ + "args": "task --config deno.json exit_code_5", + "output": "task_exit_code_5.out", + "envs": { + "NO_COLOR": "1" + }, + "exitCode": 5 +} diff --git a/tests/specs/task/exit_code_5/deno.json b/tests/specs/task/exit_code_5/deno.json new file mode 100644 index 000000000..a6e19c031 --- /dev/null +++ b/tests/specs/task/exit_code_5/deno.json @@ -0,0 +1,5 @@ +{ + "tasks": { + "exit_code_5": "echo $(echo 10 ; exit 2) && exit 5" + } +} diff --git a/tests/testdata/task/deno_json/task_exit_code_5.out b/tests/specs/task/exit_code_5/task_exit_code_5.out index 12d171939..12d171939 100644 --- a/tests/testdata/task/deno_json/task_exit_code_5.out +++ b/tests/specs/task/exit_code_5/task_exit_code_5.out diff --git a/tests/specs/task/init_cwd/__test__.jsonc b/tests/specs/task/init_cwd/__test__.jsonc new file mode 100644 index 000000000..e40d7fef3 --- /dev/null +++ b/tests/specs/task/init_cwd/__test__.jsonc @@ -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 +} diff --git a/tests/specs/task/init_cwd/deno.json b/tests/specs/task/init_cwd/deno.json new file mode 100644 index 000000000..93abead1d --- /dev/null +++ b/tests/specs/task/init_cwd/deno.json @@ -0,0 +1,5 @@ +{ + "tasks": { + "echo_init_cwd": "echo $INIT_CWD" + } +} diff --git a/tests/specs/task/init_cwd/task_init_cwd.out b/tests/specs/task/init_cwd/task_init_cwd.out new file mode 100644 index 000000000..fee54862e --- /dev/null +++ b/tests/specs/task/init_cwd/task_init_cwd.out @@ -0,0 +1 @@ +[WILDCARD]init_cwd diff --git a/tests/specs/task/init_cwd_already_set/__test__.jsonc b/tests/specs/task/init_cwd_already_set/__test__.jsonc new file mode 100644 index 000000000..30e2091ea --- /dev/null +++ b/tests/specs/task/init_cwd_already_set/__test__.jsonc @@ -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 +} diff --git a/tests/specs/task/init_cwd_already_set/deno.json b/tests/specs/task/init_cwd_already_set/deno.json new file mode 100644 index 000000000..93abead1d --- /dev/null +++ b/tests/specs/task/init_cwd_already_set/deno.json @@ -0,0 +1,5 @@ +{ + "tasks": { + "echo_init_cwd": "echo $INIT_CWD" + } +} diff --git a/tests/testdata/task/deno_json/task_init_cwd_already_set.out b/tests/specs/task/init_cwd_already_set/task_init_cwd_already_set.out index e427984d4..e427984d4 100644 --- a/tests/testdata/task/deno_json/task_init_cwd_already_set.out +++ b/tests/specs/task/init_cwd_already_set/task_init_cwd_already_set.out diff --git a/tests/specs/task/no_args/__test__.jsonc b/tests/specs/task/no_args/__test__.jsonc new file mode 100644 index 000000000..9ec24d1d2 --- /dev/null +++ b/tests/specs/task/no_args/__test__.jsonc @@ -0,0 +1,8 @@ +{ + "args": "task -q --config deno.json", + "output": "task_no_args.out", + "envs": { + "NO_COLOR": "1" + }, + "exitCode": 1 +} diff --git a/tests/specs/task/no_args/deno.json b/tests/specs/task/no_args/deno.json new file mode 100644 index 000000000..c57426d25 --- /dev/null +++ b/tests/specs/task/no_args/deno.json @@ -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 š„" + } +} diff --git a/tests/specs/task/no_args/task_no_args.out b/tests/specs/task/no_args/task_no_args.out new file mode 100644 index 000000000..18f86fce6 --- /dev/null +++ b/tests/specs/task/no_args/task_no_args.out @@ -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 š„ diff --git a/tests/specs/task/non_existent/__test__.jsonc b/tests/specs/task/non_existent/__test__.jsonc new file mode 100644 index 000000000..e34674bee --- /dev/null +++ b/tests/specs/task/non_existent/__test__.jsonc @@ -0,0 +1,8 @@ +{ + "args": "task --config deno.json non_existent", + "output": "task_non_existent.out", + "envs": { + "NO_COLOR": "1" + }, + "exitCode": 1 +} diff --git a/tests/specs/task/non_existent/deno.json b/tests/specs/task/non_existent/deno.json new file mode 100644 index 000000000..c57426d25 --- /dev/null +++ b/tests/specs/task/non_existent/deno.json @@ -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 š„" + } +} diff --git a/tests/testdata/task/deno_json/task_non_existent.out b/tests/specs/task/non_existent/task_non_existent.out index efe3805f6..efe3805f6 100644 --- a/tests/testdata/task/deno_json/task_non_existent.out +++ b/tests/specs/task/non_existent/task_non_existent.out diff --git a/tests/specs/task/npx_non_existent/__test__.jsonc b/tests/specs/task/npx_non_existent/__test__.jsonc new file mode 100644 index 000000000..8678a37bd --- /dev/null +++ b/tests/specs/task/npx_non_existent/__test__.jsonc @@ -0,0 +1,9 @@ +{ + "args": "task non-existent", + "output": "non_existent.out", + "envs": { + "NO_COLOR": "1", + "NPM_CONFIG_REGISTRY": "http://localhost:4260/" + }, + "exitCode": 1 +} diff --git a/tests/testdata/task/npx/non_existent.out b/tests/specs/task/npx_non_existent/non_existent.out index c079aec4e..c079aec4e 100644 --- a/tests/testdata/task/npx/non_existent.out +++ b/tests/specs/task/npx_non_existent/non_existent.out diff --git a/tests/specs/task/npx_non_existent/package.json b/tests/specs/task/npx_non_existent/package.json new file mode 100644 index 000000000..59602b96f --- /dev/null +++ b/tests/specs/task/npx_non_existent/package.json @@ -0,0 +1,6 @@ +{ + "scripts": { + "non-existent": "npx this-command-should-not-exist-for-you", + "on-own": "npx" + } +} diff --git a/tests/specs/task/package_json_echo/__test__.jsonc b/tests/specs/task/package_json_echo/__test__.jsonc new file mode 100644 index 000000000..616f72f78 --- /dev/null +++ b/tests/specs/task/package_json_echo/__test__.jsonc @@ -0,0 +1,9 @@ +{ + "args": "task --quiet echo", + "output": "echo.out", + "envs": { + "NO_COLOR": "1", + "NPM_CONFIG_REGISTRY": "http://localhost:4260/" + }, + "exitCode": 0 +} diff --git a/tests/testdata/task/package_json/echo.out b/tests/specs/task/package_json_echo/echo.out index d00491fd7..d00491fd7 100644 --- a/tests/testdata/task/package_json/echo.out +++ b/tests/specs/task/package_json_echo/echo.out diff --git a/tests/specs/task/package_json_echo/package.json b/tests/specs/task/package_json_echo/package.json new file mode 100644 index 000000000..cedbe2d5b --- /dev/null +++ b/tests/specs/task/package_json_echo/package.json @@ -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" + } +} diff --git a/tests/specs/task/package_json_no_arg/__test__.jsonc b/tests/specs/task/package_json_no_arg/__test__.jsonc new file mode 100644 index 000000000..2d7b75a2f --- /dev/null +++ b/tests/specs/task/package_json_no_arg/__test__.jsonc @@ -0,0 +1,8 @@ +{ + "args": "task", + "output": "no_args.out", + "envs": { + "NO_COLOR": "1" + }, + "exitCode": 1 +} diff --git a/tests/testdata/task/package_json/no_args.out b/tests/specs/task/package_json_no_arg/no_args.out index de149ccf9..de149ccf9 100644 --- a/tests/testdata/task/package_json/no_args.out +++ b/tests/specs/task/package_json_no_arg/no_args.out diff --git a/tests/specs/task/package_json_no_arg/package.json b/tests/specs/task/package_json_no_arg/package.json new file mode 100644 index 000000000..cedbe2d5b --- /dev/null +++ b/tests/specs/task/package_json_no_arg/package.json @@ -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" + } +} diff --git a/tests/specs/task/piped_stdin/__test__.jsonc b/tests/specs/task/piped_stdin/__test__.jsonc new file mode 100644 index 000000000..73220430a --- /dev/null +++ b/tests/specs/task/piped_stdin/__test__.jsonc @@ -0,0 +1,7 @@ +{ + "args": "task -q --config deno.json piped", + "output": "task_piped_stdin.out", + "envs": { + "NO_COLOR": "1" + } +} diff --git a/tests/specs/task/piped_stdin/deno.json b/tests/specs/task/piped_stdin/deno.json new file mode 100644 index 000000000..bb3d1cd29 --- /dev/null +++ b/tests/specs/task/piped_stdin/deno.json @@ -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)')" + } +} diff --git a/tests/testdata/task/deno_json/task_piped_stdin.out b/tests/specs/task/piped_stdin/task_piped_stdin.out index a0d636f15..a0d636f15 100644 --- a/tests/testdata/task/deno_json/task_piped_stdin.out +++ b/tests/specs/task/piped_stdin/task_piped_stdin.out diff --git a/tests/specs/task/post/__test__.jsonc b/tests/specs/task/post/__test__.jsonc new file mode 100644 index 000000000..3ea55d456 --- /dev/null +++ b/tests/specs/task/post/__test__.jsonc @@ -0,0 +1,8 @@ +{ + "args": "task test", + "output": "bin.out", + "envs": { + "NO_COLOR": "1" + }, + "exitCode": 0 +} diff --git a/tests/testdata/task/package_json_post/bin.out b/tests/specs/task/post/bin.out index 96e5ca910..96e5ca910 100644 --- a/tests/testdata/task/package_json_post/bin.out +++ b/tests/specs/task/post/bin.out diff --git a/tests/testdata/task/package_json_post/package.json b/tests/specs/task/post/package.json index 82689f7d4..82689f7d4 100644 --- a/tests/testdata/task/package_json_post/package.json +++ b/tests/specs/task/post/package.json diff --git a/tests/specs/task/post_only/__test__.jsonc b/tests/specs/task/post_only/__test__.jsonc new file mode 100644 index 000000000..4c37e3e63 --- /dev/null +++ b/tests/specs/task/post_only/__test__.jsonc @@ -0,0 +1,8 @@ +{ + "args": "task test", + "output": "bin.out", + "envs": { + "NO_COLOR": "1" + }, + "exitCode": 1 +} diff --git a/tests/testdata/task/package_json_post_only/bin.out b/tests/specs/task/post_only/bin.out index 9e7cea091..9e7cea091 100644 --- a/tests/testdata/task/package_json_post_only/bin.out +++ b/tests/specs/task/post_only/bin.out diff --git a/tests/testdata/task/package_json_post_only/package.json b/tests/specs/task/post_only/package.json index ce8a6bbd5..ce8a6bbd5 100644 --- a/tests/testdata/task/package_json_post_only/package.json +++ b/tests/specs/task/post_only/package.json diff --git a/tests/specs/task/pre/__test__.jsonc b/tests/specs/task/pre/__test__.jsonc new file mode 100644 index 000000000..3ea55d456 --- /dev/null +++ b/tests/specs/task/pre/__test__.jsonc @@ -0,0 +1,8 @@ +{ + "args": "task test", + "output": "bin.out", + "envs": { + "NO_COLOR": "1" + }, + "exitCode": 0 +} diff --git a/tests/testdata/task/package_json_pre/bin.out b/tests/specs/task/pre/bin.out index f22961832..f22961832 100644 --- a/tests/testdata/task/package_json_pre/bin.out +++ b/tests/specs/task/pre/bin.out diff --git a/tests/testdata/task/package_json_pre/package.json b/tests/specs/task/pre/package.json index d3eba02a1..d3eba02a1 100644 --- a/tests/testdata/task/package_json_pre/package.json +++ b/tests/specs/task/pre/package.json diff --git a/tests/specs/task/pre_only/__test__.jsonc b/tests/specs/task/pre_only/__test__.jsonc new file mode 100644 index 000000000..4c37e3e63 --- /dev/null +++ b/tests/specs/task/pre_only/__test__.jsonc @@ -0,0 +1,8 @@ +{ + "args": "task test", + "output": "bin.out", + "envs": { + "NO_COLOR": "1" + }, + "exitCode": 1 +} diff --git a/tests/testdata/task/package_json_pre_only/bin.out b/tests/specs/task/pre_only/bin.out index e96e8e341..e96e8e341 100644 --- a/tests/testdata/task/package_json_pre_only/bin.out +++ b/tests/specs/task/pre_only/bin.out diff --git a/tests/testdata/task/package_json_pre_only/package.json b/tests/specs/task/pre_only/package.json index 032a5d4ea..032a5d4ea 100644 --- a/tests/testdata/task/package_json_pre_only/package.json +++ b/tests/specs/task/pre_only/package.json diff --git a/tests/specs/task/pre_post/__test__.jsonc b/tests/specs/task/pre_post/__test__.jsonc new file mode 100644 index 000000000..3ea55d456 --- /dev/null +++ b/tests/specs/task/pre_post/__test__.jsonc @@ -0,0 +1,8 @@ +{ + "args": "task test", + "output": "bin.out", + "envs": { + "NO_COLOR": "1" + }, + "exitCode": 0 +} diff --git a/tests/testdata/task/package_json_pre_post/bin.out b/tests/specs/task/pre_post/bin.out index 8c4abc6be..8c4abc6be 100644 --- a/tests/testdata/task/package_json_pre_post/bin.out +++ b/tests/specs/task/pre_post/bin.out diff --git a/tests/testdata/task/package_json_pre_post/package.json b/tests/specs/task/pre_post/package.json index 24a3ff1ed..24a3ff1ed 100644 --- a/tests/testdata/task/package_json_pre_post/package.json +++ b/tests/specs/task/pre_post/package.json diff --git a/tests/testdata/task/both/echo.out b/tests/testdata/task/both/echo.out deleted file mode 100644 index e69de29bb..000000000 --- a/tests/testdata/task/both/echo.out +++ /dev/null diff --git a/tests/testdata/task/deno_json/task_cwd.out b/tests/testdata/task/deno_json/task_cwd.out deleted file mode 100644 index bfe3e7b11..000000000 --- a/tests/testdata/task/deno_json/task_cwd.out +++ /dev/null @@ -1 +0,0 @@ -[WILDCARD]tests diff --git a/tests/testdata/task/deno_json/task_init_cwd.out b/tests/testdata/task/deno_json/task_init_cwd.out deleted file mode 100644 index 95ea8a545..000000000 --- a/tests/testdata/task/deno_json/task_init_cwd.out +++ /dev/null @@ -1 +0,0 @@ -[WILDCARD]testdata diff --git a/tests/testdata/task/deno_json_pre_post/echo.out b/tests/testdata/task/deno_json_pre_post/echo.out deleted file mode 100644 index 573541ac9..000000000 --- a/tests/testdata/task/deno_json_pre_post/echo.out +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/tests/testdata/task/package_json_post/echo.out b/tests/testdata/task/package_json_post/echo.out deleted file mode 100644 index 573541ac9..000000000 --- a/tests/testdata/task/package_json_post/echo.out +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/tests/testdata/task/package_json_post_only/echo.out b/tests/testdata/task/package_json_post_only/echo.out deleted file mode 100644 index 573541ac9..000000000 --- a/tests/testdata/task/package_json_post_only/echo.out +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/tests/testdata/task/package_json_pre/echo.out b/tests/testdata/task/package_json_pre/echo.out deleted file mode 100644 index 573541ac9..000000000 --- a/tests/testdata/task/package_json_pre/echo.out +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/tests/testdata/task/package_json_pre_only/echo.out b/tests/testdata/task/package_json_pre_only/echo.out deleted file mode 100644 index d00491fd7..000000000 --- a/tests/testdata/task/package_json_pre_only/echo.out +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/tests/testdata/task/package_json_pre_post/echo.out b/tests/testdata/task/package_json_pre_post/echo.out deleted file mode 100644 index 573541ac9..000000000 --- a/tests/testdata/task/package_json_pre_post/echo.out +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/tools/lint.js b/tools/lint.js index 2178d4579..c76589c66 100755 --- a/tools/lint.js +++ b/tools/lint.js @@ -222,7 +222,7 @@ async function ensureNoNewITests() { "repl_tests.rs": 0, "run_tests.rs": 338, "shared_library_tests.rs": 0, - "task_tests.rs": 30, + "task_tests.rs": 4, "test_tests.rs": 74, "upgrade_tests.rs": 0, "vendor_tests.rs": 1, |