From b15f9e60a040e2e450e7ca9971a5fc07dbf8b94c Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 22 Feb 2023 22:45:35 -0500 Subject: feat(task): support scripts in package.json (#17887) This is a super basic initial implementation. We don't create a `node_modules/.bin` folder at the moment and add it to the PATH like we should which is necessary to make command name resolution in the subprocess work properly (ex. you run a script that launches another script that then tries to launch an "npx command"... this won't work atm). Closes #17492 --- cli/tests/integration/run_tests.rs | 8 +- cli/tests/integration/task_tests.rs | 159 +++++++++++++++++---- .../npm/registry/@denotest/bin/0.5.0/cli.mjs | 5 + .../npm/registry/@denotest/bin/0.5.0/package.json | 5 + cli/tests/testdata/task/both/deno.json | 6 + cli/tests/testdata/task/both/deno_selected.out | 4 + cli/tests/testdata/task/both/echo.out | 0 cli/tests/testdata/task/both/no_args.out | 7 + cli/tests/testdata/task/both/package.json | 9 ++ .../testdata/task/both/package_json_selected.out | 7 + cli/tests/testdata/task/both/prefers_deno.out | 4 + cli/tests/testdata/task/deno.json | 13 -- cli/tests/testdata/task/deno_json/deno.json | 13 ++ .../task/deno_json/task_additional_args.out | 1 + .../task_additional_args_nested_strings.out | 1 + .../deno_json/task_additional_args_no_logic.out | 1 + .../task_additional_args_no_shell_expansion.out | 1 + .../testdata/task/deno_json/task_boolean_logic.out | 4 + cli/tests/testdata/task/deno_json/task_cwd.out | 1 + .../task/deno_json/task_deno_exe_no_env.out | 2 + .../testdata/task/deno_json/task_exit_code_5.out | 2 + .../testdata/task/deno_json/task_init_cwd.out | 1 + .../task/deno_json/task_init_cwd_already_set.out | 1 + cli/tests/testdata/task/deno_json/task_no_args.out | 19 +++ .../testdata/task/deno_json/task_non_existent.out | 20 +++ .../testdata/task/deno_json/task_piped_stdin.out | 3 + cli/tests/testdata/task/npx/non_existent.out | 2 + cli/tests/testdata/task/npx/on_own.out | 2 + cli/tests/testdata/task/npx/package.json | 6 + cli/tests/testdata/task/package_json/bin.out | 10 ++ cli/tests/testdata/task/package_json/echo.out | 1 + cli/tests/testdata/task/package_json/no_args.out | 5 + cli/tests/testdata/task/package_json/package.json | 10 ++ cli/tests/testdata/task/task_additional_args.out | 1 - .../task/task_additional_args_nested_strings.out | 1 - .../task/task_additional_args_no_logic.out | 1 - .../task_additional_args_no_shell_expansion.out | 1 - cli/tests/testdata/task/task_boolean_logic.out | 4 - cli/tests/testdata/task/task_cwd.out | 1 - cli/tests/testdata/task/task_deno_exe_no_env.out | 2 - cli/tests/testdata/task/task_exit_code_5.out | 2 - cli/tests/testdata/task/task_init_cwd.out | 1 - .../testdata/task/task_init_cwd_already_set.out | 1 - cli/tests/testdata/task/task_no_args.out | 19 --- cli/tests/testdata/task/task_non_existent.out | 20 --- cli/tests/testdata/task/task_piped_stdin.out | 3 - 46 files changed, 287 insertions(+), 103 deletions(-) create mode 100644 cli/tests/testdata/npm/registry/@denotest/bin/0.5.0/cli.mjs create mode 100644 cli/tests/testdata/npm/registry/@denotest/bin/0.5.0/package.json create mode 100644 cli/tests/testdata/task/both/deno.json create mode 100644 cli/tests/testdata/task/both/deno_selected.out create mode 100644 cli/tests/testdata/task/both/echo.out create mode 100644 cli/tests/testdata/task/both/no_args.out create mode 100644 cli/tests/testdata/task/both/package.json create mode 100644 cli/tests/testdata/task/both/package_json_selected.out create mode 100644 cli/tests/testdata/task/both/prefers_deno.out delete mode 100644 cli/tests/testdata/task/deno.json create mode 100644 cli/tests/testdata/task/deno_json/deno.json create mode 100644 cli/tests/testdata/task/deno_json/task_additional_args.out create mode 100644 cli/tests/testdata/task/deno_json/task_additional_args_nested_strings.out create mode 100644 cli/tests/testdata/task/deno_json/task_additional_args_no_logic.out create mode 100644 cli/tests/testdata/task/deno_json/task_additional_args_no_shell_expansion.out create mode 100644 cli/tests/testdata/task/deno_json/task_boolean_logic.out create mode 100644 cli/tests/testdata/task/deno_json/task_cwd.out create mode 100644 cli/tests/testdata/task/deno_json/task_deno_exe_no_env.out create mode 100644 cli/tests/testdata/task/deno_json/task_exit_code_5.out create mode 100644 cli/tests/testdata/task/deno_json/task_init_cwd.out create mode 100644 cli/tests/testdata/task/deno_json/task_init_cwd_already_set.out create mode 100644 cli/tests/testdata/task/deno_json/task_no_args.out create mode 100644 cli/tests/testdata/task/deno_json/task_non_existent.out create mode 100644 cli/tests/testdata/task/deno_json/task_piped_stdin.out create mode 100644 cli/tests/testdata/task/npx/non_existent.out create mode 100644 cli/tests/testdata/task/npx/on_own.out create mode 100644 cli/tests/testdata/task/npx/package.json create mode 100644 cli/tests/testdata/task/package_json/bin.out create mode 100644 cli/tests/testdata/task/package_json/echo.out create mode 100644 cli/tests/testdata/task/package_json/no_args.out create mode 100644 cli/tests/testdata/task/package_json/package.json delete mode 100644 cli/tests/testdata/task/task_additional_args.out delete mode 100644 cli/tests/testdata/task/task_additional_args_nested_strings.out delete mode 100644 cli/tests/testdata/task/task_additional_args_no_logic.out delete mode 100644 cli/tests/testdata/task/task_additional_args_no_shell_expansion.out delete mode 100644 cli/tests/testdata/task/task_boolean_logic.out delete mode 100644 cli/tests/testdata/task/task_cwd.out delete mode 100644 cli/tests/testdata/task/task_deno_exe_no_env.out delete mode 100644 cli/tests/testdata/task/task_exit_code_5.out delete mode 100644 cli/tests/testdata/task/task_init_cwd.out delete mode 100644 cli/tests/testdata/task/task_init_cwd_already_set.out delete mode 100644 cli/tests/testdata/task/task_no_args.out delete mode 100644 cli/tests/testdata/task/task_non_existent.out delete mode 100644 cli/tests/testdata/task/task_piped_stdin.out (limited to 'cli/tests') diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index 7dbf9c74c..d89142c21 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -2752,7 +2752,7 @@ itest!(config_not_auto_discovered_for_remote_script { itest!(package_json_auto_discovered_for_local_script_log { args: "run -L debug -A no_deno_json/main.ts", output: "run/with_package_json/no_deno_json/main.out", - maybe_cwd: Some("run/with_package_json/"), + cwd: Some("run/with_package_json/"), // prevent creating a node_modules dir in the code directory copy_temp_dir: Some("run/with_package_json/"), envs: env_vars_for_npm_tests_no_sync_download(), @@ -2765,7 +2765,7 @@ itest!( package_json_auto_discovered_for_local_script_log_with_stop { args: "run -L debug with_stop/some/nested/dir/main.ts", output: "run/with_package_json/with_stop/main.out", - maybe_cwd: Some("run/with_package_json/"), + cwd: Some("run/with_package_json/"), copy_temp_dir: Some("run/with_package_json/"), envs: env_vars_for_npm_tests_no_sync_download(), http_server: true, @@ -2777,7 +2777,7 @@ itest!( package_json_auto_discovered_node_modules_relative_package_json { args: "run -A main.js", output: "run/with_package_json/no_deno_json/sub_dir/main.out", - maybe_cwd: Some("run/with_package_json/no_deno_json/sub_dir"), + cwd: Some("run/with_package_json/no_deno_json/sub_dir"), copy_temp_dir: Some("run/with_package_json/"), envs: env_vars_for_npm_tests_no_sync_download(), http_server: true, @@ -2787,7 +2787,7 @@ itest!( itest!(package_json_auto_discovered_for_npm_binary { args: "run -L debug -A npm:@denotest/bin/cli-esm this is a test", output: "run/with_package_json/npm_binary/main.out", - maybe_cwd: Some("run/with_package_json/npm_binary/"), + cwd: Some("run/with_package_json/npm_binary/"), copy_temp_dir: Some("run/with_package_json/"), envs: env_vars_for_npm_tests_no_sync_download(), http_server: true, diff --git a/cli/tests/integration/task_tests.rs b/cli/tests/integration/task_tests.rs index 47c3b6b6b..3dce90a0c 100644 --- a/cli/tests/integration/task_tests.rs +++ b/cli/tests/integration/task_tests.rs @@ -3,30 +3,32 @@ // 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; + itest!(task_no_args { - args: "task -q --config task/deno.json", - output: "task/task_no_args.out", + 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 --cwd .. echo_cwd", - output: "task/task_cwd.out", + 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 --cwd .. echo_init_cwd", - output: "task/task_init_cwd.out", + 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 echo_init_cwd", - output: "task/task_init_cwd_already_set.out", + 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()) @@ -35,15 +37,15 @@ itest!(task_init_cwd_already_set { }); itest!(task_cwd_resolves_config_from_specified_dir { - args: "task -q --cwd task", - output: "task/task_no_args.out", + 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 non_existent", - output: "task/task_non_existent.out", + 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, }); @@ -51,27 +53,27 @@ itest!(task_non_existent { #[test] fn task_emoji() { // this bug only appears when using a pty/tty - let args = "task --config task/deno.json echo_emoji"; + let args = "task --config task/deno_json/deno.json echo_emoji"; use test_util::PtyData::*; test_util::test_pty2(args, vec![Output("Task echo_emoji echo šŸ”„\r\nšŸ”„")]); } itest!(task_boolean_logic { - args: "task -q --config task/deno.json boolean_logic", - output: "task/task_boolean_logic.out", + 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 exit_code_5", - output: "task/task_exit_code_5.out", + 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 echo 2", - output: "task/task_additional_args.out", + 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())], }); @@ -80,11 +82,11 @@ itest!(task_additional_args_no_shell_expansion { "task", "-q", "--config", - "task/deno.json", + "task/deno_json/deno.json", "echo", "$(echo 5)" ], - output: "task/task_additional_args_no_shell_expansion.out", + output: "task/deno_json/task_additional_args_no_shell_expansion.out", envs: vec![("NO_COLOR".to_string(), "1".to_string())], }); @@ -93,11 +95,11 @@ itest!(task_additional_args_nested_strings { "task", "-q", "--config", - "task/deno.json", + "task/deno_json/deno.json", "echo", "string \"quoted string\"" ], - output: "task/task_additional_args_nested_strings.out", + output: "task/deno_json/task_additional_args_nested_strings.out", envs: vec![("NO_COLOR".to_string(), "1".to_string())], }); @@ -106,25 +108,124 @@ itest!(task_additional_args_no_logic { "task", "-q", "--config", - "task/deno.json", + "task/deno_json/deno.json", "echo", "||", "echo", "5" ], - output: "task/task_additional_args_no_logic.out", + 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_echo"], - output: "task/task_deno_exe_no_env.out", + 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", "piped"], - output: "task/task_piped_stdin.out", + 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", 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, +}); + +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, }); diff --git a/cli/tests/testdata/npm/registry/@denotest/bin/0.5.0/cli.mjs b/cli/tests/testdata/npm/registry/@denotest/bin/0.5.0/cli.mjs new file mode 100644 index 000000000..0ae8e9190 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/bin/0.5.0/cli.mjs @@ -0,0 +1,5 @@ +import process from "node:process"; + +for (const arg of process.argv.slice(2)) { + console.log(arg); +} diff --git a/cli/tests/testdata/npm/registry/@denotest/bin/0.5.0/package.json b/cli/tests/testdata/npm/registry/@denotest/bin/0.5.0/package.json new file mode 100644 index 000000000..caa2ef538 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/bin/0.5.0/package.json @@ -0,0 +1,5 @@ +{ + "name": "@deno/bin", + "version": "0.5.0", + "bin": "./cli.mjs" +} diff --git a/cli/tests/testdata/task/both/deno.json b/cli/tests/testdata/task/both/deno.json new file mode 100644 index 000000000..1038609a4 --- /dev/null +++ b/cli/tests/testdata/task/both/deno.json @@ -0,0 +1,6 @@ +{ + "tasks": { + "output": "deno eval 'console.log(1)'", + "other": "deno eval 'console.log(2)'" + } +} diff --git a/cli/tests/testdata/task/both/deno_selected.out b/cli/tests/testdata/task/both/deno_selected.out new file mode 100644 index 000000000..f55a74f5b --- /dev/null +++ b/cli/tests/testdata/task/both/deno_selected.out @@ -0,0 +1,4 @@ +Download http://localhost:4545/npm/registry/@denotest/bin +Download http://localhost:4545/npm/registry/@denotest/bin/1.0.0.tgz +Task other deno eval 'console.log(2)' +2 diff --git a/cli/tests/testdata/task/both/echo.out b/cli/tests/testdata/task/both/echo.out new file mode 100644 index 000000000..e69de29bb diff --git a/cli/tests/testdata/task/both/no_args.out b/cli/tests/testdata/task/both/no_args.out new file mode 100644 index 000000000..fce690b70 --- /dev/null +++ b/cli/tests/testdata/task/both/no_args.out @@ -0,0 +1,7 @@ +Available tasks: +- output + deno eval 'console.log(1)' +- other + deno eval 'console.log(2)' +- bin (package.json) + cli-esm testing this out diff --git a/cli/tests/testdata/task/both/package.json b/cli/tests/testdata/task/both/package.json new file mode 100644 index 000000000..708ccc6b1 --- /dev/null +++ b/cli/tests/testdata/task/both/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/cli/tests/testdata/task/both/package_json_selected.out b/cli/tests/testdata/task/both/package_json_selected.out new file mode 100644 index 000000000..76b3a9227 --- /dev/null +++ b/cli/tests/testdata/task/both/package_json_selected.out @@ -0,0 +1,7 @@ +Download http://localhost:4545/npm/registry/@denotest/bin +Download http://localhost:4545/npm/registry/@denotest/bin/1.0.0.tgz +Task bin cli-esm testing this out "asdf" +testing +this +out +asdf diff --git a/cli/tests/testdata/task/both/prefers_deno.out b/cli/tests/testdata/task/both/prefers_deno.out new file mode 100644 index 000000000..cd6798e6d --- /dev/null +++ b/cli/tests/testdata/task/both/prefers_deno.out @@ -0,0 +1,4 @@ +Download http://localhost:4545/npm/registry/@denotest/bin +Download http://localhost:4545/npm/registry/@denotest/bin/1.0.0.tgz +Task output deno eval 'console.log(1)' "some" "text" +1 diff --git a/cli/tests/testdata/task/deno.json b/cli/tests/testdata/task/deno.json deleted file mode 100644 index c57426d25..000000000 --- a/cli/tests/testdata/task/deno.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "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/cli/tests/testdata/task/deno_json/deno.json b/cli/tests/testdata/task/deno_json/deno.json new file mode 100644 index 000000000..c57426d25 --- /dev/null +++ b/cli/tests/testdata/task/deno_json/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/cli/tests/testdata/task/deno_json/task_additional_args.out b/cli/tests/testdata/task/deno_json/task_additional_args.out new file mode 100644 index 000000000..8d04f961a --- /dev/null +++ b/cli/tests/testdata/task/deno_json/task_additional_args.out @@ -0,0 +1 @@ +1 2 diff --git a/cli/tests/testdata/task/deno_json/task_additional_args_nested_strings.out b/cli/tests/testdata/task/deno_json/task_additional_args_nested_strings.out new file mode 100644 index 000000000..0e5f35c7f --- /dev/null +++ b/cli/tests/testdata/task/deno_json/task_additional_args_nested_strings.out @@ -0,0 +1 @@ +1 string "quoted string" diff --git a/cli/tests/testdata/task/deno_json/task_additional_args_no_logic.out b/cli/tests/testdata/task/deno_json/task_additional_args_no_logic.out new file mode 100644 index 000000000..a4886a60d --- /dev/null +++ b/cli/tests/testdata/task/deno_json/task_additional_args_no_logic.out @@ -0,0 +1 @@ +1 || echo 5 diff --git a/cli/tests/testdata/task/deno_json/task_additional_args_no_shell_expansion.out b/cli/tests/testdata/task/deno_json/task_additional_args_no_shell_expansion.out new file mode 100644 index 000000000..826a3aaf1 --- /dev/null +++ b/cli/tests/testdata/task/deno_json/task_additional_args_no_shell_expansion.out @@ -0,0 +1 @@ +1 $(echo 5) diff --git a/cli/tests/testdata/task/deno_json/task_boolean_logic.out b/cli/tests/testdata/task/deno_json/task_boolean_logic.out new file mode 100644 index 000000000..94ebaf900 --- /dev/null +++ b/cli/tests/testdata/task/deno_json/task_boolean_logic.out @@ -0,0 +1,4 @@ +1 +2 +3 +4 diff --git a/cli/tests/testdata/task/deno_json/task_cwd.out b/cli/tests/testdata/task/deno_json/task_cwd.out new file mode 100644 index 000000000..bfe3e7b11 --- /dev/null +++ b/cli/tests/testdata/task/deno_json/task_cwd.out @@ -0,0 +1 @@ +[WILDCARD]tests diff --git a/cli/tests/testdata/task/deno_json/task_deno_exe_no_env.out b/cli/tests/testdata/task/deno_json/task_deno_exe_no_env.out new file mode 100644 index 000000000..cf4a51b68 --- /dev/null +++ b/cli/tests/testdata/task/deno_json/task_deno_exe_no_env.out @@ -0,0 +1,2 @@ +[WILDCARD] +5 diff --git a/cli/tests/testdata/task/deno_json/task_exit_code_5.out b/cli/tests/testdata/task/deno_json/task_exit_code_5.out new file mode 100644 index 000000000..12d171939 --- /dev/null +++ b/cli/tests/testdata/task/deno_json/task_exit_code_5.out @@ -0,0 +1,2 @@ +Task exit_code_5 echo $(echo 10 ; exit 2) && exit 5 +10 diff --git a/cli/tests/testdata/task/deno_json/task_init_cwd.out b/cli/tests/testdata/task/deno_json/task_init_cwd.out new file mode 100644 index 000000000..95ea8a545 --- /dev/null +++ b/cli/tests/testdata/task/deno_json/task_init_cwd.out @@ -0,0 +1 @@ +[WILDCARD]testdata diff --git a/cli/tests/testdata/task/deno_json/task_init_cwd_already_set.out b/cli/tests/testdata/task/deno_json/task_init_cwd_already_set.out new file mode 100644 index 000000000..e427984d4 --- /dev/null +++ b/cli/tests/testdata/task/deno_json/task_init_cwd_already_set.out @@ -0,0 +1 @@ +HELLO diff --git a/cli/tests/testdata/task/deno_json/task_no_args.out b/cli/tests/testdata/task/deno_json/task_no_args.out new file mode 100644 index 000000000..18f86fce6 --- /dev/null +++ b/cli/tests/testdata/task/deno_json/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/cli/tests/testdata/task/deno_json/task_non_existent.out b/cli/tests/testdata/task/deno_json/task_non_existent.out new file mode 100644 index 000000000..efe3805f6 --- /dev/null +++ b/cli/tests/testdata/task/deno_json/task_non_existent.out @@ -0,0 +1,20 @@ +Task not found: non_existent +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/cli/tests/testdata/task/deno_json/task_piped_stdin.out b/cli/tests/testdata/task/deno_json/task_piped_stdin.out new file mode 100644 index 000000000..f0a236c86 --- /dev/null +++ b/cli/tests/testdata/task/deno_json/task_piped_stdin.out @@ -0,0 +1,3 @@ +[WILDCARD] +Uint8Array(1) [ 49 ] +Uint8Array(1) [ 50 ] diff --git a/cli/tests/testdata/task/npx/non_existent.out b/cli/tests/testdata/task/npx/non_existent.out new file mode 100644 index 000000000..5df04917e --- /dev/null +++ b/cli/tests/testdata/task/npx/non_existent.out @@ -0,0 +1,2 @@ +Task non-existent npx this-command-should-not-exist-for-you +npx: could not resolve command 'this-command-should-not-exist-for-you' diff --git a/cli/tests/testdata/task/npx/on_own.out b/cli/tests/testdata/task/npx/on_own.out new file mode 100644 index 000000000..67491f7b0 --- /dev/null +++ b/cli/tests/testdata/task/npx/on_own.out @@ -0,0 +1,2 @@ +Task on-own npx +npx: missing command diff --git a/cli/tests/testdata/task/npx/package.json b/cli/tests/testdata/task/npx/package.json new file mode 100644 index 000000000..59602b96f --- /dev/null +++ b/cli/tests/testdata/task/npx/package.json @@ -0,0 +1,6 @@ +{ + "scripts": { + "non-existent": "npx this-command-should-not-exist-for-you", + "on-own": "npx" + } +} diff --git a/cli/tests/testdata/task/package_json/bin.out b/cli/tests/testdata/task/package_json/bin.out new file mode 100644 index 000000000..ed1b6b8a2 --- /dev/null +++ b/cli/tests/testdata/task/package_json/bin.out @@ -0,0 +1,10 @@ +Download http://localhost:4545/npm/registry/@denotest/bin +Download http://localhost:4545/npm/registry/@denotest/bin/0.5.0.tgz +Download http://localhost:4545/npm/registry/@denotest/bin/1.0.0.tgz +Task bin @denotest/bin hi && cli-esm testing this out && npx cli-cjs test "extra" +hi +testing +this +out +test +extra diff --git a/cli/tests/testdata/task/package_json/echo.out b/cli/tests/testdata/task/package_json/echo.out new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/cli/tests/testdata/task/package_json/echo.out @@ -0,0 +1 @@ +1 diff --git a/cli/tests/testdata/task/package_json/no_args.out b/cli/tests/testdata/task/package_json/no_args.out new file mode 100644 index 000000000..de149ccf9 --- /dev/null +++ b/cli/tests/testdata/task/package_json/no_args.out @@ -0,0 +1,5 @@ +Available tasks: +- echo (package.json) + deno eval 'console.log(1)' +- bin (package.json) + @denotest/bin hi && cli-esm testing this out && npx cli-cjs test diff --git a/cli/tests/testdata/task/package_json/package.json b/cli/tests/testdata/task/package_json/package.json new file mode 100644 index 000000000..cedbe2d5b --- /dev/null +++ b/cli/tests/testdata/task/package_json/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/cli/tests/testdata/task/task_additional_args.out b/cli/tests/testdata/task/task_additional_args.out deleted file mode 100644 index 8d04f961a..000000000 --- a/cli/tests/testdata/task/task_additional_args.out +++ /dev/null @@ -1 +0,0 @@ -1 2 diff --git a/cli/tests/testdata/task/task_additional_args_nested_strings.out b/cli/tests/testdata/task/task_additional_args_nested_strings.out deleted file mode 100644 index 0e5f35c7f..000000000 --- a/cli/tests/testdata/task/task_additional_args_nested_strings.out +++ /dev/null @@ -1 +0,0 @@ -1 string "quoted string" diff --git a/cli/tests/testdata/task/task_additional_args_no_logic.out b/cli/tests/testdata/task/task_additional_args_no_logic.out deleted file mode 100644 index a4886a60d..000000000 --- a/cli/tests/testdata/task/task_additional_args_no_logic.out +++ /dev/null @@ -1 +0,0 @@ -1 || echo 5 diff --git a/cli/tests/testdata/task/task_additional_args_no_shell_expansion.out b/cli/tests/testdata/task/task_additional_args_no_shell_expansion.out deleted file mode 100644 index 826a3aaf1..000000000 --- a/cli/tests/testdata/task/task_additional_args_no_shell_expansion.out +++ /dev/null @@ -1 +0,0 @@ -1 $(echo 5) diff --git a/cli/tests/testdata/task/task_boolean_logic.out b/cli/tests/testdata/task/task_boolean_logic.out deleted file mode 100644 index 94ebaf900..000000000 --- a/cli/tests/testdata/task/task_boolean_logic.out +++ /dev/null @@ -1,4 +0,0 @@ -1 -2 -3 -4 diff --git a/cli/tests/testdata/task/task_cwd.out b/cli/tests/testdata/task/task_cwd.out deleted file mode 100644 index bfe3e7b11..000000000 --- a/cli/tests/testdata/task/task_cwd.out +++ /dev/null @@ -1 +0,0 @@ -[WILDCARD]tests diff --git a/cli/tests/testdata/task/task_deno_exe_no_env.out b/cli/tests/testdata/task/task_deno_exe_no_env.out deleted file mode 100644 index cf4a51b68..000000000 --- a/cli/tests/testdata/task/task_deno_exe_no_env.out +++ /dev/null @@ -1,2 +0,0 @@ -[WILDCARD] -5 diff --git a/cli/tests/testdata/task/task_exit_code_5.out b/cli/tests/testdata/task/task_exit_code_5.out deleted file mode 100644 index 12d171939..000000000 --- a/cli/tests/testdata/task/task_exit_code_5.out +++ /dev/null @@ -1,2 +0,0 @@ -Task exit_code_5 echo $(echo 10 ; exit 2) && exit 5 -10 diff --git a/cli/tests/testdata/task/task_init_cwd.out b/cli/tests/testdata/task/task_init_cwd.out deleted file mode 100644 index 95ea8a545..000000000 --- a/cli/tests/testdata/task/task_init_cwd.out +++ /dev/null @@ -1 +0,0 @@ -[WILDCARD]testdata diff --git a/cli/tests/testdata/task/task_init_cwd_already_set.out b/cli/tests/testdata/task/task_init_cwd_already_set.out deleted file mode 100644 index e427984d4..000000000 --- a/cli/tests/testdata/task/task_init_cwd_already_set.out +++ /dev/null @@ -1 +0,0 @@ -HELLO diff --git a/cli/tests/testdata/task/task_no_args.out b/cli/tests/testdata/task/task_no_args.out deleted file mode 100644 index e41b3edd5..000000000 --- a/cli/tests/testdata/task/task_no_args.out +++ /dev/null @@ -1,19 +0,0 @@ -Available tasks: -- boolean_logic - sleep 0.1 && echo 3 && echo 4 & echo 1 && echo 2 || echo NOPE -- deno_echo - deno eval 'console.log(5)' -- echo - echo 1 -- echo_cwd - echo $(pwd) -- echo_emoji - echo šŸ”„ -- echo_init_cwd - echo $INIT_CWD -- exit_code_5 - echo $(echo 10 ; exit 2) && exit 5 -- 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)') -- strings - deno run main.ts && deno eval "console.log(\"test\")" diff --git a/cli/tests/testdata/task/task_non_existent.out b/cli/tests/testdata/task/task_non_existent.out deleted file mode 100644 index 0e70f24d9..000000000 --- a/cli/tests/testdata/task/task_non_existent.out +++ /dev/null @@ -1,20 +0,0 @@ -Task not found: non_existent -Available tasks: -- boolean_logic - sleep 0.1 && echo 3 && echo 4 & echo 1 && echo 2 || echo NOPE -- deno_echo - deno eval 'console.log(5)' -- echo - echo 1 -- echo_cwd - echo $(pwd) -- echo_emoji - echo šŸ”„ -- echo_init_cwd - echo $INIT_CWD -- exit_code_5 - echo $(echo 10 ; exit 2) && exit 5 -- 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)') -- strings - deno run main.ts && deno eval "console.log(\"test\")" diff --git a/cli/tests/testdata/task/task_piped_stdin.out b/cli/tests/testdata/task/task_piped_stdin.out deleted file mode 100644 index f0a236c86..000000000 --- a/cli/tests/testdata/task/task_piped_stdin.out +++ /dev/null @@ -1,3 +0,0 @@ -[WILDCARD] -Uint8Array(1) [ 49 ] -Uint8Array(1) [ 50 ] -- cgit v1.2.3