diff --git a/tests/integration/task_tests.rs b/tests/integration/task_tests.rs index aba83a66d7..895e643a05 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 0000000000..b75c638ff2 --- /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 0000000000..c1a379c46a --- /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 similarity index 100% rename from tests/testdata/task/deno_json/task_additional_args.out rename to 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 0000000000..e543e31acf --- /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 0000000000..c1a379c46a --- /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 similarity index 100% rename from tests/testdata/task/deno_json/task_additional_args_nested_strings.out rename to 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 0000000000..849f8bf66f --- /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 0000000000..c1a379c46a --- /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 similarity index 100% rename from tests/testdata/task/deno_json/task_additional_args_no_logic.out rename to 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 0000000000..202321e39f --- /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 0000000000..c1a379c46a --- /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 similarity index 100% rename from tests/testdata/task/deno_json/task_additional_args_no_shell_expansion.out rename to 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 0000000000..c96e2256ca --- /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 0000000000..4d3aeb4ce2 --- /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 similarity index 100% rename from tests/testdata/task/deno_json/task_boolean_logic.out rename to 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 0000000000..7b0d31cbce --- /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 0000000000..1038609a4a --- /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 similarity index 100% rename from tests/testdata/task/both/deno_selected.out rename to 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 0000000000..c80db130e9 --- /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 0000000000..1038609a4a --- /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 similarity index 100% rename from tests/testdata/task/both/no_args.out rename to 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 0000000000..708ccc6b19 --- /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 0000000000..74bfedf8c2 --- /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 0000000000..1038609a4a --- /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 similarity index 100% rename from tests/testdata/task/both/prefers_deno.out rename to 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 0000000000..c291fe0c9b --- /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 0000000000..b7f513a3f9 --- /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 0000000000..1a8bf6ad05 --- /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 0000000000..97898e14ff --- /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 similarity index 100% rename from tests/testdata/task/deno_json/deno.json rename to 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 similarity index 100% rename from tests/testdata/task/deno_json/task_no_args.out rename to 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 0000000000..b021669e06 --- /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 0000000000..d519e21392 --- /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 similarity index 100% rename from tests/testdata/task/deno_json/task_deno_exe_no_env.out rename to 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 0000000000..17bdc9acef --- /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 similarity index 100% rename from tests/testdata/task/deno_json_pre_post/bin.out rename to 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 similarity index 100% rename from tests/testdata/task/deno_json_pre_post/deno.json rename to 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 0000000000..fde5b1545f --- /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 0000000000..5ef0d014a7 --- /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 0000000000..6ece63dc1f --- /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 0000000000..123710b788 --- /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 0000000000..a6e19c031c --- /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 similarity index 100% rename from tests/testdata/task/deno_json/task_exit_code_5.out rename to 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 0000000000..e40d7fef3d --- /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 0000000000..93abead1dd --- /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 0000000000..fee54862e3 --- /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 0000000000..30e2091ea7 --- /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 0000000000..93abead1dd --- /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 similarity index 100% rename from tests/testdata/task/deno_json/task_init_cwd_already_set.out rename to 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 0000000000..9ec24d1d21 --- /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 0000000000..c57426d250 --- /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 0000000000..18f86fce6c --- /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 0000000000..e34674beef --- /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 0000000000..c57426d250 --- /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 similarity index 100% rename from tests/testdata/task/deno_json/task_non_existent.out rename to 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 0000000000..8678a37bd3 --- /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 similarity index 100% rename from tests/testdata/task/npx/non_existent.out rename to 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 0000000000..59602b96fe --- /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 0000000000..616f72f78f --- /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 similarity index 100% rename from tests/testdata/task/package_json/echo.out rename to 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 0000000000..cedbe2d5bd --- /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 0000000000..2d7b75a2f2 --- /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 similarity index 100% rename from tests/testdata/task/package_json/no_args.out rename to 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 0000000000..cedbe2d5bd --- /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 0000000000..73220430a2 --- /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 0000000000..bb3d1cd29e --- /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 similarity index 100% rename from tests/testdata/task/deno_json/task_piped_stdin.out rename to 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 0000000000..3ea55d4561 --- /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 similarity index 100% rename from tests/testdata/task/package_json_post/bin.out rename to tests/specs/task/post/bin.out diff --git a/tests/testdata/task/package_json_post/package.json b/tests/specs/task/post/package.json similarity index 100% rename from tests/testdata/task/package_json_post/package.json rename to 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 0000000000..4c37e3e63e --- /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 similarity index 100% rename from tests/testdata/task/package_json_post_only/bin.out rename to 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 similarity index 100% rename from tests/testdata/task/package_json_post_only/package.json rename to 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 0000000000..3ea55d4561 --- /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 similarity index 100% rename from tests/testdata/task/package_json_pre/bin.out rename to tests/specs/task/pre/bin.out diff --git a/tests/testdata/task/package_json_pre/package.json b/tests/specs/task/pre/package.json similarity index 100% rename from tests/testdata/task/package_json_pre/package.json rename to 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 0000000000..4c37e3e63e --- /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 similarity index 100% rename from tests/testdata/task/package_json_pre_only/bin.out rename to 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 similarity index 100% rename from tests/testdata/task/package_json_pre_only/package.json rename to 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 0000000000..3ea55d4561 --- /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 similarity index 100% rename from tests/testdata/task/package_json_pre_post/bin.out rename to 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 similarity index 100% rename from tests/testdata/task/package_json_pre_post/package.json rename to 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 e69de29bb2..0000000000 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 bfe3e7b111..0000000000 --- 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 95ea8a5458..0000000000 --- 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 573541ac97..0000000000 --- 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 573541ac97..0000000000 --- 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 573541ac97..0000000000 --- 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 573541ac97..0000000000 --- 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 d00491fd7e..0000000000 --- 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 573541ac97..0000000000 --- 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 2178d45792..c76589c666 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,