From aaa33b9580959b503e46286ab1e71b83d6d530d1 Mon Sep 17 00:00:00 2001 From: Marcin Date: Sat, 7 May 2022 13:39:53 +0200 Subject: [PATCH 1/7] build: fixed github actions --- .github/workflows/build.yml | 1 + README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9695d381..b8b3d5ed 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,6 +11,7 @@ on: jobs: build: strategy: + fail-fast: false matrix: os: - ubuntu-20.04 diff --git a/README.md b/README.md index c52c6ba9..529b15c5 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![GitHub release](https://img.shields.io/github/release/holgerbrandl/kscript.svg)](https://github.com/holgerbrandl/kscript/releases) -[![Build Status](https://github.com/holgerbrandl/krangl/workflows/build/badge.svg)](https://github.com/holgerbrandl/krangl/actions?query=workflow%3Abuild) +[![Build Status](https://github.com/holgerbrandl/kscript/workflows/build/badge.svg)](https://github.com/holgerbrandl/kscript/actions?query=workflow%3Abuild) [![Gitter](https://badges.gitter.im/holgerbrandl/kscript.svg)](https://gitter.im/holgerbrandl/kscript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) Enhanced scripting support for [Kotlin](https://kotlinlang.org/) on *nix-based systems. From f0500545c5ed90728811e91e2c79cde20efb29fe Mon Sep 17 00:00:00 2001 From: Marcin Date: Sat, 7 May 2022 15:36:41 +0200 Subject: [PATCH 2/7] test: improved test suite --- test/setup_environment.sh | 19 +- test/suite/annotation_driven_configuration.sh | 22 ++ test/suite/assemble.sh | 14 + test/suite/bootstrap_headers.sh | 19 ++ test/suite/custom_interpreters.sh | 4 + test/suite/environment.sh | 11 + test/suite/idea.sh | 10 + test/suite/kt_support.sh | 18 ++ test/suite/misc.sh | 24 ++ test/suite/packaging.sh | 13 + test/suite/script_input_modes.sh | 49 ++++ test/suite/support_api.sh | 6 + test/test_suite.sh | 275 ++---------------- 13 files changed, 229 insertions(+), 255 deletions(-) create mode 100644 test/suite/annotation_driven_configuration.sh create mode 100644 test/suite/assemble.sh create mode 100644 test/suite/bootstrap_headers.sh create mode 100644 test/suite/custom_interpreters.sh create mode 100644 test/suite/environment.sh create mode 100644 test/suite/idea.sh create mode 100644 test/suite/kt_support.sh create mode 100644 test/suite/misc.sh create mode 100644 test/suite/packaging.sh create mode 100644 test/suite/script_input_modes.sh create mode 100644 test/suite/support_api.sh diff --git a/test/setup_environment.sh b/test/setup_environment.sh index f3045470..1d66d0b7 100644 --- a/test/setup_environment.sh +++ b/test/setup_environment.sh @@ -51,15 +51,26 @@ assert_stderr(){ assert "( $1 ) 2>&1 >/dev/null" "$2" } -# $1 - suite name; $2 - requested suites +# $1 - suite name; $2... - requested suites start_suite() { - if [[ "${2}" =~ "${1}" ]] || [[ "${2}" == "ALL" ]]; then + PARAM_SUITE="$1" + PARAM_REQUESTED_SUITES="${@:2}" + + if [[ "${PARAM_REQUESTED_SUITES}" =~ "${PARAM_SUITE}" ]] || [[ "${PARAM_REQUESTED_SUITES}" == "ALL" ]]; then echo - echo "Starting '$1' tests:" + echo "Starting '$PARAM_SUITE' tests:" + + SUITE_FILE="${PROJECT_DIR}/test/suite/${PARAM_SUITE}.sh" + if [[ -f ${SUITE_FILE} ]]; then + source ${SUITE_FILE} + + assert_end "$PARAM_SUITE" + fi + return 0 fi - echo "Skipping '$1' tests..." + echo "Skipping '$PARAM_SUITE' tests..." return 1 } diff --git a/test/suite/annotation_driven_configuration.sh b/test/suite/annotation_driven_configuration.sh new file mode 100644 index 00000000..6f011cf9 --- /dev/null +++ b/test/suite/annotation_driven_configuration.sh @@ -0,0 +1,22 @@ +## there are some dependencies which are not jar, but maybe pom, aar,... make sure they work, too +assert "kscript ${PROJECT_DIR}/test/resources/depends_on_with_type.kts" "getBigDecimal(1L): 1" + +# make sure that @file:DependsOn is parsed correctly +assert "kscript ${PROJECT_DIR}/test/resources/depends_on_annot.kts" "kscript with annotations rocks!" + +# make sure that @file:DependsOnMaven is parsed correctly +assert "kscript ${PROJECT_DIR}/test/resources/depends_on_maven_annot.kts" "kscript with annotations rocks!" + +# make sure that dynamic versions are matched properly +assert "kscript ${PROJECT_DIR}/test/resources/depends_on_dynamic.kts" "dynamic kscript rocks!" + +# make sure that @file:MavenRepository is parsed correctly +assert "kscript ${PROJECT_DIR}/test/resources/custom_mvn_repo_annot.kts" "kscript with annotations rocks!" +assert_stderr "kscript ${PROJECT_DIR}/test/resources/illegal_depends_on_arg.kts" '[kscript] [ERROR] Artifact locators must be provided as separate annotation arguments and not as comma-separated list: [com.squareup.moshi:moshi:1.5.0,com.squareup.moshi:moshi-adapters:1.5.0]' + +# make sure that @file:MavenRepository is parsed correctly +assert "kscript ${PROJECT_DIR}/test/resources/script_with_compile_flags.kts" "hoo_ray" + +## Ensure dependencies are solved correctly #345 +rm -rf ~/.m2/repository/com/beust +assert "kscript ${PROJECT_DIR}/test/resources/depends_on_klaxon.kts" "Successfully resolved klaxon" diff --git a/test/suite/assemble.sh b/test/suite/assemble.sh new file mode 100644 index 00000000..3b71e813 --- /dev/null +++ b/test/suite/assemble.sh @@ -0,0 +1,14 @@ +cd $PROJECT_DIR +./gradlew clean assemble +EXIT_CODE="$?" +cd - + +assert "echo $EXIT_CODE" "0" + +if [[ "$EXIT_CODE" -ne "0" ]]; then + assert_end "assemble" + + echo + echo "KScript build terminated with invalid exit code $EXIT_CODE..." + exit 1 +fi diff --git a/test/suite/bootstrap_headers.sh b/test/suite/bootstrap_headers.sh new file mode 100644 index 00000000..9b7cfcbe --- /dev/null +++ b/test/suite/bootstrap_headers.sh @@ -0,0 +1,19 @@ +f=/tmp/echo_stdin_args.kts +cp "${PROJECT_DIR}/test/resources/echo_stdin_args.kts" $f + +# ensure script works as is +assert 'echo stdin | '$f' --foo bar' "stdin | script --foo bar" + +# add bootstrap header +assert 'kscript --add-bootstrap-header '$f '' + +# ensure adding it again raises an error +assert_raises 'kscript --add-bootstrap-header '$f 1 + +# ensure scripts works with header, including stdin +assert 'echo stdin | '$f' --foo bar' "stdin | script --foo bar" + +# ensure scripts works with header invoked with explicit `kscript` +assert 'echo stdin | kscript '$f' --foo bar' "stdin | script --foo bar" + +rm $f diff --git a/test/suite/custom_interpreters.sh b/test/suite/custom_interpreters.sh new file mode 100644 index 00000000..84b27486 --- /dev/null +++ b/test/suite/custom_interpreters.sh @@ -0,0 +1,4 @@ +export PATH=${PATH}:${PROJECT_DIR}/test/resources/custom_dsl + +assert "mydsl \"println(foo)\"" "bar" +assert "${PROJECT_DIR}/test/resources/custom_dsl/mydsl_test_with_deps.kts" "foobar" diff --git a/test/suite/environment.sh b/test/suite/environment.sh new file mode 100644 index 00000000..428d13c0 --- /dev/null +++ b/test/suite/environment.sh @@ -0,0 +1,11 @@ +## do not run interactive mode prep without script argument +assert_raises "kscript -i" 1 + +## make sure that KOTLIN_HOME can be guessed from kotlinc correctly +assert "unset KOTLIN_HOME; echo 'println(99)' | kscript -" "99" + +## todo test what happens if kotlin/kotlinc/java/maven is not in PATH + +## run script that tries to find out its own filename via environment variable +f="${PROJECT_DIR}/test/resources/uses_self_file_name.kts" +assert "$f" "Usage: $f [-ae] [--foo] file+" diff --git a/test/suite/idea.sh b/test/suite/idea.sh new file mode 100644 index 00000000..c819af8d --- /dev/null +++ b/test/suite/idea.sh @@ -0,0 +1,10 @@ +kscript_nocall() { kotlin -classpath ${PROJECT_DIR}/build/libs/kscript.jar kscript.app.KscriptKt "$@";} +export -f kscript_nocall + +## temp projects with include symlinks +assert_raises "tmpDir=$(kscript_nocall --idea ${PROJECT_DIR}/test/resources/includes/include_variations.kts | cut -f2 -d ' ' | xargs echo); cd $tmpDir && gradle build" 0 + +## support diamond-shaped include schemes (see #133) +assert_raises "tmpDir=$(kscript_nocall --idea ${PROJECT_DIR}/test/resources/includes/diamond.kts | cut -f2 -d ' ' | xargs echo); cd $tmpDir && gradle build" 0 + +## todo re-enable interactive mode tests using kscript_nocall diff --git a/test/suite/kt_support.sh b/test/suite/kt_support.sh new file mode 100644 index 00000000..485af03a --- /dev/null +++ b/test/suite/kt_support.sh @@ -0,0 +1,18 @@ +## run kt via interpreter mode +assert "${PROJECT_DIR}/test/resources/kt_tests/simple_app.kt" "main was called" + +## run kt via interpreter mode with dependencies +assert "kscript ${PROJECT_DIR}/test/resources/kt_tests/main_with_deps.kt" "made it!" + +## test misc entry point with or without package configurations + +assert "kscript ${PROJECT_DIR}/test/resources/kt_tests/custom_entry_nopckg.kt" "foo companion was called" + +assert "kscript ${PROJECT_DIR}/test/resources/kt_tests/custom_entry_withpckg.kt" "foo companion was called" + +assert "kscript ${PROJECT_DIR}/test/resources/kt_tests/default_entry_nopckg.kt" "main was called" + +assert "kscript ${PROJECT_DIR}/test/resources/kt_tests/default_entry_withpckg.kt" "main was called" + +## also make sure that kts in package can be run via kscript +assert "${PROJECT_DIR}/test/resources/script_in_pckg.kts" "I live in a package!" diff --git a/test/suite/misc.sh b/test/suite/misc.sh new file mode 100644 index 00000000..9826c850 --- /dev/null +++ b/test/suite/misc.sh @@ -0,0 +1,24 @@ +## prevent regressions of #98 (it fails to process empty or space-containing arguments) +assert 'kscript "println(args.size)" foo bar' 2 ## regaular args +assert 'kscript "println(args.size)" "" foo bar' 3 ## accept empty args +assert 'kscript "println(args.size)" "--params foo"' 1 ## make sure dash args are not confused with options +assert 'kscript "println(args.size)" "foo bar"' 1 ## allow for spaces +assert 'kscript "println(args[0])" "foo bar"' "foo bar" ## make sure quotes are not propagated into args + +## prevent regression of #181 +assert "echo \"println(123)\" > $KSCRIPT_TEST_DIR/123foo.kts; kscript $KSCRIPT_TEST_DIR/123foo.kts" "123" + +## prevent regression of #185 +assert "source ${PROJECT_DIR}/test/resources/home_dir_include.sh" "42" + +## prevent regression of #173 +assert "source ${PROJECT_DIR}/test/resources/compiler_opts_with_includes.sh" "hello42" + +## Ensure relative includes with in shebang mode +assert_raises "${PROJECT_DIR}/test/resources/includes/shebang_mode_includes" 0 + +## Ensure that compilation errors are not cached #349 +# first run (not yet cached) +kscript ${PROJECT_DIR}/test/resources/invalid_script.kts &> /dev/null +# real test +assert "kscript ${PROJECT_DIR}/test/resources/invalid_script.kts 2>&1 | grep \"Compilation of scriplet failed\"" "[kscript] [ERROR] Compilation of scriplet failed:" diff --git a/test/suite/packaging.sh b/test/suite/packaging.sh new file mode 100644 index 00000000..7fa3ee0c --- /dev/null +++ b/test/suite/packaging.sh @@ -0,0 +1,13 @@ +## can we resolve relative imports when using tmp-scripts (see #95) +assert "rm -f ${PROJECT_DIR}/test/package_example && kscript --package ${PROJECT_DIR}/test/resources/package_example.kts &>/dev/null && ${PROJECT_DIR}/test/package_example 1" "package_me_args_1_mem_5368709120" + +## https://unix.stackexchange.com/questions/17064/how-to-print-only-last-column +assert 'rm -f kscriptlet* && cmd=$(kscript --package "println(args.size)" 2>&1 | tail -n1 | cut -f 5 -d " ") && $cmd three arg uments' "3" + +#assert "kscript --package test/resources/package_example.kts" "foo" +#assert "./package_example 1" "package_me_args_1_mem_4772593664"da +#assert "echo 1" "package_me_args_1_mem_4772593664" +#assert_statement 'rm -f kscriptlet* && kscript --package "println(args.size)"' "foo" "bar" 0 + +# ensure that the jar file is executable +assert_raises "java -jar build/lib/kscript.jar" 0 diff --git a/test/suite/script_input_modes.sh b/test/suite/script_input_modes.sh new file mode 100644 index 00000000..1fcbe8d3 --- /dev/null +++ b/test/suite/script_input_modes.sh @@ -0,0 +1,49 @@ +## make sure that scripts can be piped into kscript +assert "source ${PROJECT_DIR}/test/resources/direct_script_arg.sh" "kotlin rocks" + +## also allow for empty programs +assert "kscript ''" "" + +## provide script as direct argument +assert 'kscript "println(1+1)"' '2' + +## use dashed arguments (to prevent regression from https://github.com/holgerbrandl/kscript/issues/59) +assert 'kscript "println(args.joinToString(\"\"))" --arg u ments' '--arguments' +assert 'kscript -s "println(args.joinToString(\"\"))" --arg u ments' '--arguments' + +## provide script via stidin +assert "echo 'println(1+1)' | kscript -" "2" + +## provide script via stidin with further switch (to avoid regressions of #94) +assert "echo 'println(1+3)' | kscript - --foo" "4" + +## make sure that heredoc is accepted as argument +assert "source ${PROJECT_DIR}/test/resources/here_doc_test.sh" "hello kotlin" + +## make sure that command substitution works as expected +assert "source ${PROJECT_DIR}/test/resources/cmd_subst_test.sh" "command substitution works as well" + +## make sure that it runs with local script files +assert "source ${PROJECT_DIR}/test/resources/local_script_file.sh" "kscript rocks!" +#assert "echo foo" "bar" # known to fail + +## make sure that it runs with local script files +assert "kscript ${PROJECT_DIR}/test/resources/multi_line_deps.kts" "kscript is cool!" + +## scripts with dashes in the file name should work as well +assert "kscript ${PROJECT_DIR}/test/resources/dash-test.kts" "dash alarm!" + +## scripts with additional dots in the file name should work as well. +## We also test innner uppercase letters in file name here by using .*T*est +assert "kscript ${PROJECT_DIR}/test/resources/dot.Test.kts" "dot alarm!" + +## missing script +assert_raises "kscript i_do_not_exist.kts" 1 +assert "kscript i_do_not_exist.kts 2>&1" "[kscript] [ERROR] Could not read script from 'i_do_not_exist.kts'" + +## make sure that it runs with remote URLs +assert "kscript https://raw.githubusercontent.com/holgerbrandl/kscript/master/test/resources/url_test.kts" "I came from the internet" +assert "kscript https://git.io/fxHBv" "main was called" + +# repeated compilation of buggy same script should end up in error again +assert_raises "kscript '1-'; kscript '1-'" 1 diff --git a/test/suite/support_api.sh b/test/suite/support_api.sh new file mode 100644 index 00000000..259e947e --- /dev/null +++ b/test/suite/support_api.sh @@ -0,0 +1,6 @@ +## make sure that one-liners include support-api +assert 'echo "foo${NL}bar" | kscript -t "stdin.print()"' $'foo\nbar' +assert 'echo "foo${NL}bar" | kscript -t "lines.print()"' $'foo\nbar' +#echo "$'foo\nbar' | kscript 'lines.print()' + +assert_statement 'echo "foo${NL}bar" | kscript -s --text "lines.split().select(1, 2, -3)"' "" "[ERROR] Can not mix positive and negative selections" 1 diff --git a/test/test_suite.sh b/test/test_suite.sh index 09581a36..29e61134 100755 --- a/test/test_suite.sh +++ b/test/test_suite.sh @@ -17,12 +17,21 @@ kscript --clear-cache echo ######################################################################################################################## -echo "Compiling KScript... Please wait..." -cd $PROJECT_DIR -./gradlew clean assemble -EXIT_CODE="$?" -cd - +source "$SCRIPT_DIR/setup_environment.sh" +echo + +######################################################################################################################## +SUITE="assemble" +if start_suite $SUITE $REQUESTED_SUITES; then + cd $PROJECT_DIR + ./gradlew clean assemble + EXIT_CODE="$?" + cd - + + assert "echo $EXIT_CODE" "0" + assert_end "$SUITE" +fi if [[ "$EXIT_CODE" -ne "0" ]]; then echo @@ -30,11 +39,6 @@ if [[ "$EXIT_CODE" -ne "0" ]]; then exit 1 fi -######################################################################################################################## - -source "$SCRIPT_DIR/setup_environment.sh" -echo - ######################################################################################################################## SUITE="junit" if start_suite $SUITE $REQUESTED_SUITES; then @@ -49,60 +53,8 @@ if start_suite $SUITE $REQUESTED_SUITES; then fi ######################################################################################################################## -SUITE="script_input_modes" -if start_suite $SUITE $REQUESTED_SUITES; then - ## make sure that scripts can be piped into kscript - assert "source ${PROJECT_DIR}/test/resources/direct_script_arg.sh" "kotlin rocks" - - ## also allow for empty programs - assert "kscript ''" "" - - ## provide script as direct argument - assert 'kscript "println(1+1)"' '2' - - ## use dashed arguments (to prevent regression from https://github.com/holgerbrandl/kscript/issues/59) - assert 'kscript "println(args.joinToString(\"\"))" --arg u ments' '--arguments' - assert 'kscript -s "println(args.joinToString(\"\"))" --arg u ments' '--arguments' - - ## provide script via stidin - assert "echo 'println(1+1)' | kscript -" "2" - - ## provide script via stidin with further switch (to avoid regressions of #94) - assert "echo 'println(1+3)' | kscript - --foo" "4" - - ## make sure that heredoc is accepted as argument - assert "source ${PROJECT_DIR}/test/resources/here_doc_test.sh" "hello kotlin" - - ## make sure that command substitution works as expected - assert "source ${PROJECT_DIR}/test/resources/cmd_subst_test.sh" "command substitution works as well" - - ## make sure that it runs with local script files - assert "source ${PROJECT_DIR}/test/resources/local_script_file.sh" "kscript rocks!" - #assert "echo foo" "bar" # known to fail - - ## make sure that it runs with local script files - assert "kscript ${PROJECT_DIR}/test/resources/multi_line_deps.kts" "kscript is cool!" - - ## scripts with dashes in the file name should work as well - assert "kscript ${PROJECT_DIR}/test/resources/dash-test.kts" "dash alarm!" - - ## scripts with additional dots in the file name should work as well. - ## We also test innner uppercase letters in file name here by using .*T*est - assert "kscript ${PROJECT_DIR}/test/resources/dot.Test.kts" "dot alarm!" - - ## missing script - assert_raises "kscript i_do_not_exist.kts" 1 - assert "kscript i_do_not_exist.kts 2>&1" "[kscript] [ERROR] Could not read script from 'i_do_not_exist.kts'" - - ## make sure that it runs with remote URLs - assert "kscript https://raw.githubusercontent.com/holgerbrandl/kscript/master/test/resources/url_test.kts" "I came from the internet" - assert "kscript https://git.io/fxHBv" "main was called" - # repeated compilation of buggy same script should end up in error again - assert_raises "kscript '1-'; kscript '1-'" 1 - - assert_end "$SUITE" -fi +start_suite "script_input_modes" $REQUESTED_SUITES ######################################################################################################################## #SUITE="cli_helper" @@ -121,192 +73,13 @@ fi #assert_end "$SUITE" ######################################################################################################################## -SUITE="environment" -if start_suite $SUITE $REQUESTED_SUITES; then - ## do not run interactive mode prep without script argument - assert_raises "kscript -i" 1 - - ## make sure that KOTLIN_HOME can be guessed from kotlinc correctly - assert "unset KOTLIN_HOME; echo 'println(99)' | kscript -" "99" - - ## todo test what happens if kotlin/kotlinc/java/maven is not in PATH - - ## run script that tries to find out its own filename via environment variable - f="${PROJECT_DIR}/test/resources/uses_self_file_name.kts" - assert "$f" "Usage: $f [-ae] [--foo] file+" - - assert_end "$SUITE" -fi - -######################################################################################################################## -SUITE="annotation_driven_configuration" -if start_suite $SUITE $REQUESTED_SUITES; then - ## there are some dependencies which are not jar, but maybe pom, aar,... make sure they work, too - assert "kscript ${PROJECT_DIR}/test/resources/depends_on_with_type.kts" "getBigDecimal(1L): 1" - - # make sure that @file:DependsOn is parsed correctly - assert "kscript ${PROJECT_DIR}/test/resources/depends_on_annot.kts" "kscript with annotations rocks!" - - # make sure that @file:DependsOnMaven is parsed correctly - assert "kscript ${PROJECT_DIR}/test/resources/depends_on_maven_annot.kts" "kscript with annotations rocks!" - - # make sure that dynamic versions are matched properly - assert "kscript ${PROJECT_DIR}/test/resources/depends_on_dynamic.kts" "dynamic kscript rocks!" - - # make sure that @file:MavenRepository is parsed correctly - assert "kscript ${PROJECT_DIR}/test/resources/custom_mvn_repo_annot.kts" "kscript with annotations rocks!" - assert_stderr "kscript ${PROJECT_DIR}/test/resources/illegal_depends_on_arg.kts" '[kscript] [ERROR] Artifact locators must be provided as separate annotation arguments and not as comma-separated list: [com.squareup.moshi:moshi:1.5.0,com.squareup.moshi:moshi-adapters:1.5.0]' - - # make sure that @file:MavenRepository is parsed correctly - assert "kscript ${PROJECT_DIR}/test/resources/script_with_compile_flags.kts" "hoo_ray" - - ## Ensure dependencies are solved correctly #345 - rm -rf ~/.m2/repository/com/beust - assert "kscript ${PROJECT_DIR}/test/resources/depends_on_klaxon.kts" "Successfully resolved klaxon" - - assert_end "$SUITE" -fi - -######################################################################################################################## -SUITE="support_api" -if start_suite $SUITE $REQUESTED_SUITES; then - ## make sure that one-liners include support-api - assert 'echo "foo${NL}bar" | kscript -t "stdin.print()"' $'foo\nbar' - assert 'echo "foo${NL}bar" | kscript -t "lines.print()"' $'foo\nbar' - #echo "$'foo\nbar' | kscript 'lines.print()' - assert_statement 'echo "foo${NL}bar" | kscript -s --text "lines.split().select(1, 2, -3)"' "" "[ERROR] Can not mix positive and negative selections" 1 - - assert_end "$SUITE" -fi - -######################################################################################################################## -SUITE="kt_support" -if start_suite $SUITE $REQUESTED_SUITES; then - ## run kt via interpreter mode - assert "${PROJECT_DIR}/test/resources/kt_tests/simple_app.kt" "main was called" - - ## run kt via interpreter mode with dependencies - assert "kscript ${PROJECT_DIR}/test/resources/kt_tests/main_with_deps.kt" "made it!" - - ## test misc entry point with or without package configurations - - assert "kscript ${PROJECT_DIR}/test/resources/kt_tests/custom_entry_nopckg.kt" "foo companion was called" - - assert "kscript ${PROJECT_DIR}/test/resources/kt_tests/custom_entry_withpckg.kt" "foo companion was called" - - assert "kscript ${PROJECT_DIR}/test/resources/kt_tests/default_entry_nopckg.kt" "main was called" - - assert "kscript ${PROJECT_DIR}/test/resources/kt_tests/default_entry_withpckg.kt" "main was called" - - ## also make sure that kts in package can be run via kscript - assert "${PROJECT_DIR}/test/resources/script_in_pckg.kts" "I live in a package!" - - assert_end "$SUITE" -fi - -######################################################################################################################## -SUITE="custom_interpreters" -if start_suite $SUITE $REQUESTED_SUITES; then - export PATH=${PATH}:${PROJECT_DIR}/test/resources/custom_dsl - - assert "mydsl \"println(foo)\"" "bar" - - assert "${PROJECT_DIR}/test/resources/custom_dsl/mydsl_test_with_deps.kts" "foobar" - - assert_end "$SUITE" -fi - -######################################################################################################################## -SUITE="misc" -if start_suite $SUITE $REQUESTED_SUITES; then - ## prevent regressions of #98 (it fails to process empty or space-containing arguments) - assert 'kscript "println(args.size)" foo bar' 2 ## regaular args - assert 'kscript "println(args.size)" "" foo bar' 3 ## accept empty args - assert 'kscript "println(args.size)" "--params foo"' 1 ## make sure dash args are not confused with options - assert 'kscript "println(args.size)" "foo bar"' 1 ## allow for spaces - assert 'kscript "println(args[0])" "foo bar"' "foo bar" ## make sure quotes are not propagated into args - - ## prevent regression of #181 - assert "echo \"println(123)\" > $KSCRIPT_TEST_DIR/123foo.kts; kscript $KSCRIPT_TEST_DIR/123foo.kts" "123" - - ## prevent regression of #185 - assert "source ${PROJECT_DIR}/test/resources/home_dir_include.sh" "42" - - ## prevent regression of #173 - assert "source ${PROJECT_DIR}/test/resources/compiler_opts_with_includes.sh" "hello42" - - ## Ensure relative includes with in shebang mode - assert_raises "${PROJECT_DIR}/test/resources/includes/shebang_mode_includes" 0 - - ## Ensure that compilation errors are not cached #349 - # first run (not yet cached) - kscript ${PROJECT_DIR}/test/resources/invalid_script.kts &> /dev/null - # real test - assert "kscript ${PROJECT_DIR}/test/resources/invalid_script.kts 2>&1 | grep \"Compilation of scriplet failed\"" "[kscript] [ERROR] Compilation of scriplet failed:" - - assert_end "$SUITE" -fi - -######################################################################################################################## -SUITE="bootstrap_headers" -if start_suite $SUITE $REQUESTED_SUITES; then - f=/tmp/echo_stdin_args.kts - cp "${PROJECT_DIR}/test/resources/echo_stdin_args.kts" $f - - # ensure script works as is - assert 'echo stdin | '$f' --foo bar' "stdin | script --foo bar" - - # add bootstrap header - assert 'kscript --add-bootstrap-header '$f '' - - # ensure adding it again raises an error - assert_raises 'kscript --add-bootstrap-header '$f 1 - - # ensure scripts works with header, including stdin - assert 'echo stdin | '$f' --foo bar' "stdin | script --foo bar" - - # ensure scripts works with header invoked with explicit `kscript` - assert 'echo stdin | kscript '$f' --foo bar' "stdin | script --foo bar" - - rm $f - - assert_end "$SUITE" -fi - -######################################################################################################################## -SUITE="packaging" -if start_suite $SUITE $REQUESTED_SUITES; then - ## can we resolve relative imports when using tmp-scripts (see #95) - assert "rm -f ${PROJECT_DIR}/test/package_example && kscript --package ${PROJECT_DIR}/test/resources/package_example.kts &>/dev/null && ${PROJECT_DIR}/test/package_example 1" "package_me_args_1_mem_5368709120" - - ## https://unix.stackexchange.com/questions/17064/how-to-print-only-last-column - assert 'rm -f kscriptlet* && cmd=$(kscript --package "println(args.size)" 2>&1 | tail -n1 | cut -f 5 -d " ") && $cmd three arg uments' "3" - - #assert "kscript --package test/resources/package_example.kts" "foo" - #assert "./package_example 1" "package_me_args_1_mem_4772593664"da - #assert "echo 1" "package_me_args_1_mem_4772593664" - #assert_statement 'rm -f kscriptlet* && kscript --package "println(args.size)"' "foo" "bar" 0 - - # ensure that the jar file is executable - assert_raises "java -jar build/lib/kscript.jar" 0 - - assert_end "$SUITE" -fi - -######################################################################################################################## -SUITE="idea" -if start_suite $SUITE $REQUESTED_SUITES; then - kscript_nocall() { kotlin -classpath ${PROJECT_DIR}/build/libs/kscript.jar kscript.app.KscriptKt "$@";} - export -f kscript_nocall - - ## temp projects with include symlinks - assert_raises "tmpDir=$(kscript_nocall --idea ${PROJECT_DIR}/test/resources/includes/include_variations.kts | cut -f2 -d ' ' | xargs echo); cd $tmpDir && gradle build" 0 - - ## support diamond-shaped include schemes (see #133) - assert_raises "tmpDir=$(kscript_nocall --idea ${PROJECT_DIR}/test/resources/includes/diamond.kts | cut -f2 -d ' ' | xargs echo); cd $tmpDir && gradle build" 0 - - ## todo re-enable interactive mode tests using kscript_nocall - - assert_end "$SUITE" -fi +start_suite "environment" $REQUESTED_SUITES +start_suite "annotation_driven_configuration" $REQUESTED_SUITES +start_suite "support_api" $REQUESTED_SUITES +start_suite "kt_support" $REQUESTED_SUITES +start_suite "custom_interpreters" $REQUESTED_SUITES +start_suite "misc" $REQUESTED_SUITES +start_suite "bootstrap_headers" $REQUESTED_SUITES +start_suite "packaging" $REQUESTED_SUITES +start_suite "idea" $REQUESTED_SUITES From 5d07803397aad5750b8679ddaa519be66cf686b8 Mon Sep 17 00:00:00 2001 From: Marcin Date: Sat, 7 May 2022 16:47:33 +0200 Subject: [PATCH 3/7] test: improved test suite test: improved git hub actions --- .github/workflows/build.yml | 69 ++----------------- test/resources/compiler_opts_with_includes.sh | 7 +- test/resources/home_dir_include.sh | 4 +- test/resources/local_script_file.sh | 4 +- test/suite/cli_helper.sh | 8 +++ test/suite/junit.sh | 6 ++ test/test_suite.sh | 58 ++-------------- 7 files changed, 30 insertions(+), 126 deletions(-) create mode 100644 test/suite/cli_helper.sh create mode 100644 test/suite/junit.sh mode change 100755 => 100644 test/test_suite.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b8b3d5ed..58d28d25 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,12 +26,11 @@ jobs: steps: - uses: actions/checkout@v2 - # https://stackoverflow.com/questions/56726429/how-to-run-multiple-commands-in-one-github-actions-docker - - - name: Set up JDK 11 - uses: actions/setup-java@v1 + - uses: actions/setup-java@v3 with: - java-version: 11 + distribution: 'zulu' # See 'Supported distributions' for available options + java-version: '11' + - uses: fwilhe2/setup-kotlin@main - name: Install dependencies for ${{ runner.os }} shell: bash @@ -47,70 +46,10 @@ jobs: # sudo apt-get update # sudo apt-get install -y curl unzip zip wget - - name: Install sdkman - shell: bash - run: | - bash -c "curl -s "https://get.sdkman.io" | bash" - source "$HOME/.sdkman/bin/sdkman-init.sh" - - - name: Install kotlin - shell: bash - run: | - source "$HOME/.sdkman/bin/sdkman-init.sh" - sdk install kotlin 1.4.31 - - - name: Install gradle - shell: bash - run: | - source "$HOME/.sdkman/bin/sdkman-init.sh" - sdk install gradle 6.7 - - - # https://stackoverflow.com/questions/50104666/gradle-difference-between-test-and-check - - name: Build and test with Gradle -# working-directory: $GITHUB_WORKSPACE - shell: bash - run: | - echo $GITHUB_WORKSPACE - chmod +x gradlew - ./gradlew clean check --stacktrace --info - - - - name: Build kscript - run: ./gradlew assemble - - - name: Install assert.sh - shell: bash - run: | - curl -sLO https://raw.github.com/lehmannro/assert.sh/v1.1/assert.sh - chmod +x assert.sh - - # https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#adding-a-system-path - - name: Update PATH to include kscript - shell: bash - run: echo "${GITHUB_WORKSPACE}/build/libs" >> $GITHUB_PATH - - - run: which kscript - shell: bash - - - name: Print --version - shell: bash - run: | - source "$HOME/.sdkman/bin/sdkman-init.sh" - kscript --version - - - name: Create mock idea executable - shell: bash - run: | - touch idea - chmod +x idea - echo "${PWD}" >> $GITHUB_PATH - - name: Run tests timeout-minutes: 10 shell: bash if: ${{ runner.os != 'Windows' }} run: | - source "$HOME/.sdkman/bin/sdkman-init.sh" export KSCRIPT_HOME="$GITHUB_WORKSPACE" ./test/test_suite.sh diff --git a/test/resources/compiler_opts_with_includes.sh b/test/resources/compiler_opts_with_includes.sh index df0dcf20..901de12d 100644 --- a/test/resources/compiler_opts_with_includes.sh +++ b/test/resources/compiler_opts_with_includes.sh @@ -1,8 +1,8 @@ ## Prevent regressions of https://github.com/holgerbrandl/kscript/issues/173 -echo "fun foo() = 42" > compiler_opts_with_includes_dep.kts +echo "fun foo() = 42" > $KSCRIPT_TEST_DIR/compiler_opts_with_includes_dep.kts -cat <<"EOF" > compiler_opts_with_includes_master.kt +cat <<"EOF" > $KSCRIPT_TEST_DIR/compiler_opts_with_includes_master.kt @file:CompilerOpts("-jvm-target 1.8") @file:Include("compiler_opts_with_includes_dep.kts") @file:DependsOnMaven("log4j:log4j:1.2.14") @@ -14,5 +14,4 @@ fun main(args: Array) { } EOF -kscript compiler_opts_with_includes_master.kt - +kscript $KSCRIPT_TEST_DIR/compiler_opts_with_includes_master.kt diff --git a/test/resources/home_dir_include.sh b/test/resources/home_dir_include.sh index 9ea0df40..d8c9b362 100644 --- a/test/resources/home_dir_include.sh +++ b/test/resources/home_dir_include.sh @@ -3,6 +3,6 @@ echo "fun foo() = 42" > ~/.kscript_home_include.kts echo ' //INCLUDE ~/.kscript_home_include.kts println(foo()) -' > home_dir_master.kts +' > $KSCRIPT_TEST_DIR/home_dir_master.kts -kscript home_dir_master.kts \ No newline at end of file +kscript $KSCRIPT_TEST_DIR/home_dir_master.kts diff --git a/test/resources/local_script_file.sh b/test/resources/local_script_file.sh index 8c9bb99f..dd0e530e 100644 --- a/test/resources/local_script_file.sh +++ b/test/resources/local_script_file.sh @@ -1,3 +1,3 @@ -scriptFile=test_script.kts +scriptFile=$KSCRIPT_TEST_DIR/test_script.kts echo 'println("kscript rocks!")' > ${scriptFile} -kscript $scriptFile \ No newline at end of file +kscript $scriptFile diff --git a/test/suite/cli_helper.sh b/test/suite/cli_helper.sh new file mode 100644 index 00000000..0ae9b71d --- /dev/null +++ b/test/suite/cli_helper.sh @@ -0,0 +1,8 @@ +## interactive mode without dependencies +#assert "kscript -i 'exitProcess(0)'" "To create a shell with script dependencies run:\nkotlinc -classpath ''" +#assert "echo '' | kscript -i -" "To create a shell with script dependencies run:\nkotlinc -classpath ''" + + +## first version is disabled because support-auto-prefixing kicks in +#assert "kscript -i '//DEPS log4j:log4j:1.2.14'" "To create a shell with script dependencies run:\nkotlinc -classpath '${HOME}/.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14.jar'" +#assert "kscript -i <(echo '//DEPS log4j:log4j:1.2.14')" "To create a shell with script dependencies run:\nkotlinc -classpath '${HOME}/.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14.jar'" diff --git a/test/suite/junit.sh b/test/suite/junit.sh new file mode 100644 index 00000000..4a29e49d --- /dev/null +++ b/test/suite/junit.sh @@ -0,0 +1,6 @@ +cd $PROJECT_DIR +./gradlew test +EXIT_CODE="$?" +cd - + +assert "echo $EXIT_CODE" "0" diff --git a/test/test_suite.sh b/test/test_suite.sh old mode 100755 new mode 100644 index 29e61134..20a670a4 --- a/test/test_suite.sh +++ b/test/test_suite.sh @@ -3,7 +3,6 @@ # Provide suite names which you want to execute as a parameter # Example: # no parameters or 'ALL' - execute all test suites -# '-' (dash) - just compile - no suites executed # 'junit' - execute just unit tests SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" @@ -21,59 +20,12 @@ echo source "$SCRIPT_DIR/setup_environment.sh" echo -######################################################################################################################## -SUITE="assemble" -if start_suite $SUITE $REQUESTED_SUITES; then - cd $PROJECT_DIR - ./gradlew clean assemble - EXIT_CODE="$?" - cd - - - assert "echo $EXIT_CODE" "0" - assert_end "$SUITE" -fi - -if [[ "$EXIT_CODE" -ne "0" ]]; then - echo - echo "KScript build terminated with invalid exit code $EXIT_CODE..." - exit 1 -fi - -######################################################################################################################## -SUITE="junit" -if start_suite $SUITE $REQUESTED_SUITES; then - cd $PROJECT_DIR - ./gradlew test - EXIT_CODE="$?" - cd - - - assert "echo $EXIT_CODE" "0" - - assert_end "$SUITE" -fi - ######################################################################################################################## +start_suite "assemble" $REQUESTED_SUITES +start_suite "junit" $REQUESTED_SUITES start_suite "script_input_modes" $REQUESTED_SUITES - -######################################################################################################################## -#SUITE="cli_helper" -#echo -#echo "Starting $SUITE tests:" - -## interactive mode without dependencies -#assert "kscript -i 'exitProcess(0)'" "To create a shell with script dependencies run:\nkotlinc -classpath ''" -#assert "echo '' | kscript -i -" "To create a shell with script dependencies run:\nkotlinc -classpath ''" - - -## first version is disabled because support-auto-prefixing kicks in -#assert "kscript -i '//DEPS log4j:log4j:1.2.14'" "To create a shell with script dependencies run:\nkotlinc -classpath '${HOME}/.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14.jar'" -#assert "kscript -i <(echo '//DEPS log4j:log4j:1.2.14')" "To create a shell with script dependencies run:\nkotlinc -classpath '${HOME}/.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14.jar'" - -#assert_end "$SUITE" - -######################################################################################################################## - +#start_suite "cli_helper" $REQUESTED_SUITES start_suite "environment" $REQUESTED_SUITES start_suite "annotation_driven_configuration" $REQUESTED_SUITES start_suite "support_api" $REQUESTED_SUITES @@ -81,5 +33,5 @@ start_suite "kt_support" $REQUESTED_SUITES start_suite "custom_interpreters" $REQUESTED_SUITES start_suite "misc" $REQUESTED_SUITES start_suite "bootstrap_headers" $REQUESTED_SUITES -start_suite "packaging" $REQUESTED_SUITES -start_suite "idea" $REQUESTED_SUITES +#start_suite "packaging" $REQUESTED_SUITES +#start_suite "idea" $REQUESTED_SUITES From dd0d36daa0e44c7dbaca034dca159a33fc0f5747 Mon Sep 17 00:00:00 2001 From: Marcin Date: Sat, 7 May 2022 16:56:58 +0200 Subject: [PATCH 4/7] test: make test_suite.sh executable test: simplified git hub actions --- .github/workflows/build.yml | 11 +++-------- test/test_suite.sh | 0 2 files changed, 3 insertions(+), 8 deletions(-) mode change 100644 => 100755 test/test_suite.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 58d28d25..7f9897b8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,5 @@ name: build -# https://docs.github.com/en/free-pro-team@latest/actions/managing-workflow-runs/adding-a-workflow-status-badge - on: push: branches: [ master ] @@ -28,9 +26,11 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-java@v3 with: - distribution: 'zulu' # See 'Supported distributions' for available options + distribution: 'zulu' java-version: '11' - uses: fwilhe2/setup-kotlin@main + with: + version: 1.6.21 - name: Install dependencies for ${{ runner.os }} shell: bash @@ -41,11 +41,6 @@ jobs: cp /c/msys64/usr/bin/bash.exe /c/Windows/System32/bash.exe fi -# - name: Update system dependencies -# run: | -# sudo apt-get update -# sudo apt-get install -y curl unzip zip wget - - name: Run tests timeout-minutes: 10 shell: bash diff --git a/test/test_suite.sh b/test/test_suite.sh old mode 100644 new mode 100755 From d65f22574c0362216860898240677e01f3b16777 Mon Sep 17 00:00:00 2001 From: Marcin Date: Sat, 7 May 2022 17:14:50 +0200 Subject: [PATCH 5/7] test: make test_suite.sh executable test: simplified git hub actions --- .github/workflows/build.yml | 4 ---- README.md | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7f9897b8..480430f5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,10 +17,6 @@ jobs: - windows-2022 runs-on: ${{ matrix.os }} timeout-minutes: 30 -# defaults: -# run: -# shell: bash -# working-directory: $GITHUB_WORKSPACE steps: - uses: actions/checkout@v2 diff --git a/README.md b/README.md index 529b15c5..1c22f0ed 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![GitHub release](https://img.shields.io/github/release/holgerbrandl/kscript.svg)](https://github.com/holgerbrandl/kscript/releases) -[![Build Status](https://github.com/holgerbrandl/kscript/workflows/build/badge.svg)](https://github.com/holgerbrandl/kscript/actions?query=workflow%3Abuild) +[![Build Status](https://github.com/holgerbrandl/kscript/workflows/build/badge.svg)](https://github.com/holgerbrandl/kscript/actions) [![Gitter](https://badges.gitter.im/holgerbrandl/kscript.svg)](https://gitter.im/holgerbrandl/kscript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) Enhanced scripting support for [Kotlin](https://kotlinlang.org/) on *nix-based systems. From 7c8089567cd403a3a07f0ee5ac3b388f9ccee59f Mon Sep 17 00:00:00 2001 From: Marcin Date: Sat, 7 May 2022 17:24:19 +0200 Subject: [PATCH 6/7] docs: formatting & improvements --- NEWS.md | 163 +++++++++++++++++++------------- README.md | 271 +++++++++++++++++++++++++++++++++++------------------- 2 files changed, 276 insertions(+), 158 deletions(-) diff --git a/NEWS.md b/NEWS.md index ede88495..74342f4e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,135 +2,158 @@ ## 4.0.0 -Rewrite by https://github.com/aartiPl +Rewrite by https://github.com/aartiPl Functionality: - * Recursive inclusion of dependant scripts without hardcoded limits + +* Recursive inclusion of dependant scripts without hardcoded limits Improved test_suite.sh - * Automatic setting up of test environment (assert.sh, test directories) - * Automatic compilation - * idea - script to help to test idea use cases - * Script setup_environment.sh can be used for local testing - * Some script tests moved to Unit Tests - * Ability to start test suites by name + +* Automatic setting up of test environment (assert.sh, test directories) +* Automatic compilation +* idea - script to help to test idea use cases +* Script setup_environment.sh can be used for local testing +* Some script tests moved to Unit Tests +* Ability to start test suites by name Improved Unit Tests + * Several new Unit tests * New Unit Tests can be created much easier (Major point why modularization makes sense) Improved Logging + * Silent mode / Development mode logging Modularisation of source code + * Removed duplication * Code divided in logical pieces and moved to packages * Script resolution creates immutable objects Build script -* Updated Gradle to version 7.3 and shadowJar to 6.1.0 + +* Updated Gradle to version 7.4.3 and shadowJar to 7.1.2 * Fixes in build file Performance + * Much less IO operations - that should contribute to better performance - + Misc -* Updated Kotlin to 1.5.31, but only for compiler, not kotlin-scripting. It's far from optimal, but it is not possible to move fully to Kotlin 1.5 or even 1.6, because of the issues with resolution of artifacts in latest kotlin-scripting. I have put report here: https://youtrack.jetbrains.com/issue/KT-49511 + +* Updated Kotlin to 1.5.31, but only for compiler, not kotlin-scripting. It's far from optimal, but it is not possible + to move fully to Kotlin 1.5 or even 1.6, because of the issues with resolution of artifacts in latest + kotlin-scripting. I have put report here: https://youtrack.jetbrains.com/issue/KT-49511 * Fixed a lot of IDE warnings in code * Packaging - gradle file converted to Kotlin; still does not work, but it was like that before anyway -* Changes for kscript dir allow simple implementation of config file if needed. (.kscript/kscript.config); Not implemented by me, but might be useful e.g. for storing preambles +* Changes for kscript dir allow simple implementation of config file if needed. (.kscript/kscript.config); Not + implemented by me, but might be useful e.g. for storing preambles INCOMPATIBLE CHANGES: + * In annotations the only allowed delimiter is coma "," (to allow options with arguments, separated by space) -* Resolution of env variables is more restrictive - only vars expected by kscript can be resolved (for security - it's not good to include arbitrary strings from user env into the script) +* Resolution of env variables is more restrictive - only vars expected by kscript can be resolved (for security - it's + not good to include arbitrary strings from user env into the script) * Reworked caching mechanism -## 3.2 +## 3.2 Not released - incorporated in 4.0 Major changes & enhancements -* Improved for relative script inclusions (Thanks to PR by **aartiPI** [#330](https://github.com/holgerbrandl/kscript/pull/330)) -* Fixed bootstrap header support ([#324](https://github.com/holgerbrandl/kscript/issues/324)) +* Improved for relative script inclusions (Thanks to PR by ** + aartiPI** [#330](https://github.com/holgerbrandl/kscript/pull/330)) +* Fixed bootstrap header support ([#324](https://github.com/holgerbrandl/kscript/issues/324)) ## 3.1 Major changes & enhancements -* Removed jcenter as default dependency repository -* Updated tests and build integration to function without jcenter +* Removed jcenter as default dependency repository +* Updated tests and build integration to function without jcenter ## 3.0 Major Enhancements -* New dependency resolver based on [kotlin-scripting](https://kotlinlang.org/docs/reference/whatsnew14.html#scripting-and-repl) + +* New dependency resolver based + on [kotlin-scripting](https://kotlinlang.org/docs/reference/whatsnew14.html#scripting-and-repl) * Java11 support (fixes #239) Minor improvements + * Forward jvm target to --idea generated build.gradle.kts (#258) * Add maven repo credentials to build.gradle.kts generated by --idea (#262) -* Add option to launch temp intellij as custom command through env property (#264). E.g on ubuntu we could use `export KSCRIPT_IDEA_COMMAND=/snap/bin/intellij-idea-ultimate` to enable `kscript --idea ` +* Add option to launch temp intellij as custom command through env property (#264). E.g on ubuntu we could + use `export KSCRIPT_IDEA_COMMAND=/snap/bin/intellij-idea-ultimate` to enable `kscript --idea ` * Fixed idea project symlinks for complex projects (#268) * Fixed bootstrap script env variable issue (#271) * Fixed parsing of named arguments in @MavenRepository (fixes #274) * Added executable docker container to release plan (fixes #224) * Updated Kotlin to 1.4.10 (#283) * Updated gradle in temporary projects to 6.7 (#282) -* Add Kotlin run configuration for .kt based scripts. (#284) +* Add Kotlin run configuration for .kt based scripts. (#284) * Use absolute paths to avoid issues with relative paths and relativize (#285) Incompatible API changes -* Pom dependencies must be now declared as `org.javamoney:moneta:pom:1.3` (and no longer as `org.javamoney:moneta:1.3@pom`) + +* Pom dependencies must be now declared as `org.javamoney:moneta:pom:1.3` (and no longer + as `org.javamoney:moneta:1.3@pom`) * Dynamic version dependencies must be now declared as `log4j:log4j:[1.2,)` (and no longer as `log4j:log4j:1.2+`) ## 2.9 - Support environment variables in repository credentials ([#248](https://github.com/holgerbrandl/kscript/issues/159)) + * Make INCLUDE directive files relative to script dir * Create a default Run Configuration for Idea ([#244](https://github.com/holgerbrandl/kscript/issues/159)) Minor enhancements & fixes: + * Support whitespace around maven repo credentials (fixes [#228](https://github.com/holgerbrandl/kscript/issues/159)) * Make INCLUDE directive files relative to script dir * Fixed support for gitbash * Fixed bootstrap header ([#234](https://github.com/holgerbrandl/kscript/issues/159)) * Improved and documented basic testing support ([#247](https://github.com/holgerbrandl/kscript/issues/159)) - ## 2.8 Improvements & Fixes -* [#214](https://github.com/holgerbrandl/kscript/pull/214) Added credentials support for `@file:MavenRepository` annotation (thanks to [@meonlol](https://github.com/meonlol) - for providing the PR and his patience) +* [#214](https://github.com/holgerbrandl/kscript/pull/214) Added credentials support for `@file:MavenRepository` + annotation (thanks to [@meonlol](https://github.com/meonlol) + for providing the PR and his patience) ## 2.7 Improvements & Fixes + * [#159](https://github.com/holgerbrandl/kscript/issues/159) Use aether instead of maven to pull dependencies * [#210](https://github.com/holgerbrandl/kscript/issues/210): Updated gradle capsule plugin * [#102](https://github.com/holgerbrandl/kscript/issues/102): Removed `--self-update` * Use resource from repo for resolve boostrap header * [#203](https://github.com/holgerbrandl/kscript/issues/203): Fix cache check bug on Windows -* [#199](https://github.com/holgerbrandl/kscript/issues/199): Allow to bootstrap kscript installation with `--add-bootstrap-header` +* [#199](https://github.com/holgerbrandl/kscript/issues/199): Allow to bootstrap kscript installation + with `--add-bootstrap-header` * [#200](https://github.com/holgerbrandl/kscript/issues/200): Expose script file name to script - ## v2.6 - Major Improvements * [#166](https://github.com/holgerbrandl/kscript/issues/166): Support dynamic versions ending with `+` * [#185](https://github.com/holgerbrandl/kscript/issues/185): Support "~" in INCLUDE () * [#187](https://github.com/holgerbrandl/kscript/issues/187): Added support for shortened URLs -* [#146](https://github.com/holgerbrandl/kscript/issues/146): Allow kscript cache directory to be configurable via `KSCRIPT_CACHE_DIR` environment variable +* [#146](https://github.com/holgerbrandl/kscript/issues/146): Allow kscript cache directory to be configurable + via `KSCRIPT_CACHE_DIR` environment variable * [#175](https://github.com/holgerbrandl/kscript/issues/175): `cygwin` support improvements * Improved `kshell` launcher to also launch scripts with invalid code Notable Bug Fixes + * Confusing error when filename starts with a number * Fixed usage `@file:CompilerOpts` in combination with `@file:Include` * Renamed `kshell_from_kscript` to `kshell_kts` @@ -151,12 +174,14 @@ Minor Enhancements * Allow to include same file from multiple files * Fixed: Space-containing argument propagation - ## v2.4 Major Enhancements: -* Allow to set `kotlinc` compiler flags with `@file:CompilerOpts` or `//COMPILER_OPTS` (#84). See [here](https://github.com/holgerbrandl/kscript#deploy-scripts-as-standalone-binaries). -* Provide a way to _package_ kscripts (#63). See [here](https://github.com/holgerbrandl/kscript#configure-the-runtime--with-kotlin_opts). + +* Allow to set `kotlinc` compiler flags with `@file:CompilerOpts` or `//COMPILER_OPTS` (#84). + See [here](https://github.com/holgerbrandl/kscript#deploy-scripts-as-standalone-binaries). +* Provide a way to _package_ kscripts (#63). + See [here](https://github.com/holgerbrandl/kscript#configure-the-runtime--with-kotlin_opts). Minor Enhancements: @@ -171,42 +196,46 @@ Minor Enhancements: * Simplify Gradle config for script bootstrapping with IDEA (#86) * Added Gradle wrapper to the project (#87 and #88) - ## v2.3 - Major Enhancements: * Replaced `javac` with `kotlinc` for faster script compilation * Added symlink support -* Allow to derive [custom DSL interpreters](https://github.com/holgerbrandl/kscript/blob/master/docs/user_guide.md#create-interpreters-for-custom-dsls) from kscript (fixes [#67](https://github.com/holgerbrandl/kscript/issues/67)) -* Implemented `@file:Include` and `@EntryPoint` as [documented](https://github.com/holgerbrandl/kscript#annotation-driven-script-configuration) in README (fixes [#73](https://github.com/holgerbrandl/kscript/issues/73)) +* Allow to + derive [custom DSL interpreters](https://github.com/holgerbrandl/kscript/blob/master/docs/user_guide.md#create-interpreters-for-custom-dsls) + from kscript (fixes [#67](https://github.com/holgerbrandl/kscript/issues/67)) +* Implemented `@file:Include` and `@EntryPoint` + as [documented](https://github.com/holgerbrandl/kscript#annotation-driven-script-configuration) in README ( + fixes [#73](https://github.com/holgerbrandl/kscript/issues/73)) * Added [gitter](https://gitter.im/holgerbrandl/kscript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) channel Minor Enhancements: -* Consolidate imports and dependencies when `//INCLUDE` is used (fixes [#75](https://github.com/holgerbrandl/kscript/pull/75)) … + +* Consolidate imports and dependencies when `//INCLUDE` is used ( + fixes [#75](https://github.com/holgerbrandl/kscript/pull/75)) … * Support artifact should have better namespace (fixes [#57](https://github.com/holgerbrandl/kscript/issues/57)) * Fixed [#76](https://github.com/holgerbrandl/kscript/issues/76): Unspecific error when dependency resolution fails * Fixed [#66](https://github.com/holgerbrandl/kscript/issues/66): It should die more gracefully if `idea` is not present * Fixed [#81](https://github.com/holgerbrandl/kscript/issues/81): Allow package declarations for scripts -* Fixed [#78](https://github.com/holgerbrandl/kscript/issues/78): When using `--idea` the script argument should be symlinked +* Fixed [#78](https://github.com/holgerbrandl/kscript/issues/78): When using `--idea` the script argument should be + symlinked * Fixed [#79](https://github.com/holgerbrandl/kscript/pull/79): Provide setup instructions if idea launcher is missing * Simplified build instructions (fixes [#60](https://github.com/holgerbrandl/kscript/issues/60)) * Document dependencies of kscript (fixes [#69](https://github.com/holgerbrandl/kscript/issues/69)) - ## v2.2 * Logging of maven artifact downloads to stderr (fixes [#23](https://github.com/holgerbrandl/kscript/issues/23)) * Added `-s` / `--silent` to suppress all logging -* Fixed [#55](https://github.com/holgerbrandl/kscript/issues/55): dependency resolution fails on travis ci and within docker containers -* Added alternative `@DependsOnMaven(val artifactId: String)` annotaiton to declare dependencies. This has been implemented to make kscripts compatible with https://github.com/ligee/kotlin-jupyter +* Fixed [#55](https://github.com/holgerbrandl/kscript/issues/55): dependency resolution fails on travis ci and within + docker containers +* Added alternative `@DependsOnMaven(val artifactId: String)` annotaiton to declare dependencies. This has been + implemented to make kscripts compatible with https://github.com/ligee/kotlin-jupyter * Added support for custom maven repositories (fixes [#22](https://github.com/holgerbrandl/kscript/issues/22)) - See [README.md](README.md) for usage details. - ## v2.1 * support for annotation-driven script configuration @@ -217,59 +246,67 @@ See [README.md](README.md) for usage details. * Reimplemented in kotlin (fixes [#36](https://github.com/holgerbrandl/kscript/issues/36)) * Added cygwin support (fixes [#39](https://github.com/holgerbrandl/kscript/issues/39)) * Added `//INCLUDE` directive (fixes [#34](https://github.com/holgerbrandl/kscript/issues/34) -* Fixed: interactive mode is not correctly started when using stdin as script argument ([#40](https://github.com/holgerbrandl/kscript/issues/40) +* Fixed: interactive mode is not correctly started when using stdin as script + argument ([#40](https://github.com/holgerbrandl/kscript/issues/40) * Fixed compatibility with java9 ([#41](https://github.com/holgerbrandl/kscript/issues/41)) - ## v1.5.1 * Fixed `--self-update` * More robust self-update on OSses with file-locking (e.g. windows) - - ## v1.5 * removed `curl` dependency * more streamlined dependency lookup - ## v1.4 Major new features -* Redesigned [support library](https://github.com/holgerbrandl/kscript-support-api) for streamlined tabular data processing. See [here](http://holgerbrandl.github.io/kotlin/2017/05/08/kscript_as_awk_substitute.html) for an overview. +* Redesigned [support library](https://github.com/holgerbrandl/kscript-support-api) for streamlined tabular data + processing. See [here](http://holgerbrandl.github.io/kotlin/2017/05/08/kscript_as_awk_substitute.html) for an + overview. ## v1.3 Major new features -* Dramatically reduced overhead by using dependency lookup cache more efficiently. After the initial scriptlet-jar-building, `kscript` runs with almost **zero overhead** now (fixes [#4](https://github.com/holgerbrandl/kscript/issues/4)) -* Dependencies can now declared in multiple lines for better readability (fixes [#2](https://github.com/holgerbrandl/kscript/issues/2)) +* Dramatically reduced overhead by using dependency lookup cache more efficiently. After the initial + scriptlet-jar-building, `kscript` runs with almost **zero overhead** now ( + fixes [#4](https://github.com/holgerbrandl/kscript/issues/4)) +* Dependencies can now declared in multiple lines for better readability ( + fixes [#2](https://github.com/holgerbrandl/kscript/issues/2)) * Automatic inclusion of support library for one-liners (fixes [#19](https://github.com/holgerbrandl/kscript/issues/19)) -* Direct script arguments `kscript 'println("hello kotlin")'` (fixes [#18](https://github.com/holgerbrandl/kscript/issues/18)) +* Direct script arguments `kscript 'println("hello kotlin")'` ( + fixes [#18](https://github.com/holgerbrandl/kscript/issues/18)) * More robust dependency resolution with more informative error messages - Support API improvements -* Kotlin DocOpt helpers to build CLIs ([example](https://github.com/holgerbrandl/kscript-support-api/blob/master/src/test/kotlin/kscript/test/DocOptTest.kt)) -* New [utilities](https://github.com/holgerbrandl/kscript-support-api/blob/master/src/main/kotlin/kscript/StreamUtil.kt) to automatically resolve arguments files and stdin to `Sequence`. -The `