diff --git a/entrypoint.sh b/entrypoint.sh index e847c0a..8ca5d3e 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,11 +1,13 @@ -#! /bin/bash +#! /usr/bin/env bash # shellcheck disable=SC2155 input_paths="$1" -severity_mode="${2-style}" +severity_mode="${2}" execution_mode="$3" my_dir=$(pwd) status_code="0" +invalid_files=() +scan_regex="#!.*[/ ](sh|bash|dash|ksh)$" process_input(){ [ -n "$execution_mode" ] && my_dir="./test_data" @@ -13,7 +15,7 @@ process_input(){ severity_mode="$(echo $severity_mode | tr '[:upper:]' '[:lower:]')" if [[ "$severity_mode" != "style" && "$severity_mode" != "info" && "$severity_mode" != "warning" && "$severity_mode" != "error" ]]; then - echo "Error setting unknown severity mode. Defaulting severity mode to style." + echo "Warning: unknown severity mode. Defaulting severity mode to style." severity_mode="style" fi @@ -25,9 +27,11 @@ process_input(){ scan_file "$path" fi done + [[ ${#invalid_files[@]} -gt 0 ]] && log_invalid_files [ -z "$execution_mode" ] && exit $status_code else scan_all "$my_dir" + [[ ${#invalid_files[@]} -gt 0 ]] && log_invalid_files [ -z "$execution_mode" ] && exit $status_code fi } @@ -36,7 +40,8 @@ scan_file(){ local file_path=$1 local file=$(basename -- "$file_path") local first_line=$(head -n 1 "$file_path") - if [[ "$first_line" == "#!"* ]]; then + + if [[ "$first_line" =~ $scan_regex ]]; then echo echo "###############################################" echo " Scanning $file" @@ -50,7 +55,7 @@ scan_file(){ printf "\e[31m ERROR: ShellCheck detected issues in %s.\e[0m\n" "${file_path} 🐛" fi else - printf "\n\e[33m ⚠️ Warning: '%s' is not a valid shell script. Make sure shebang is on the first line.\e[0m\n" "$file_path" + invalid_files+=( $file_path ) fi } @@ -59,12 +64,21 @@ scan_all(){ while IFS= read -r script do local first_line=$(head -n 1 "$script") - if [[ "$first_line" == "#!"* ]]; then + if [[ "$first_line" =~ $scan_regex ]]; then scan_file "$script" else - printf "\n\e[33m ⚠️ Warning: '%s' is not scanned. If it is a shell script, make sure shebang is on the first line.\e[0m\n" "$script" + invalid_files+=( $script ) fi - done < <(find "$1" -name '*.sh' -o ! -name '*.*' -type f ! -path "$1/.git/*") + done < <(find "$1" -iname '*.sh' -o -iname '*.bash' -o -iname '*.ksh' -o ! -iname '*.*' -type f ! -path "$1/.git/*") +} + +# Logging files with no extension that are not amongst the supported scripts or scripts that are supported but don't have a shebang. +log_invalid_files(){ + printf "\n\e[33m ⚠️ Found %d unscanned files that could potentially be supported: \e[0m\n" "${#invalid_files[@]}" + for file in ${invalid_files[@]}; do + printf "\n\t\e[33m %s \e[0m\n" "$file" + done + printf "\n\e[33m ShellCheck only supports sh/bash/dash/ksh scripts. For supported scripts to be scanned, make sure to add a proper shebang on the first line of the script.\e[0m\n" } # To avoid execution when sourcing this script for testing diff --git a/test_data/script_type/sample.bash b/test_data/script_type/sample.bash new file mode 100644 index 0000000..a9bf588 --- /dev/null +++ b/test_data/script_type/sample.bash @@ -0,0 +1 @@ +#!/bin/bash diff --git a/test_data/script_type/test.zsh b/test_data/script_type/test.zsh new file mode 100644 index 0000000..6daf4f1 --- /dev/null +++ b/test_data/script_type/test.zsh @@ -0,0 +1,3 @@ +#!/bin/zsh + +echo "hello" \ No newline at end of file diff --git a/test_data/script_type/test_python b/test_data/script_type/test_python new file mode 100644 index 0000000..ad45154 --- /dev/null +++ b/test_data/script_type/test_python @@ -0,0 +1,3 @@ +#!/bin/python3 + +print("hello, world!") \ No newline at end of file diff --git a/test_data/script_type/test_script.js b/test_data/script_type/test_script.js new file mode 100644 index 0000000..ab35cba --- /dev/null +++ b/test_data/script_type/test_script.js @@ -0,0 +1,4 @@ +// hello.js +function hello(string) { + return 'hello ' + string; +} \ No newline at end of file diff --git a/test_data/script_type/test_script_wosh.sh b/test_data/script_type/test_script_wosh.sh new file mode 100755 index 0000000..e69de29 diff --git a/test_data/test_dir_1/executable_script b/test_data/script_type/test_script_wsh.sh similarity index 100% rename from test_data/test_dir_1/executable_script rename to test_data/script_type/test_script_wsh.sh diff --git a/test_data/script_type/test_zsh_wsh b/test_data/script_type/test_zsh_wsh new file mode 100644 index 0000000..53f53af --- /dev/null +++ b/test_data/script_type/test_zsh_wsh @@ -0,0 +1 @@ +#!/bin/zsh \ No newline at end of file diff --git a/test_data/test_dir_3/test_script_error.sh b/test_data/severity_mode/test_script_error.sh similarity index 100% rename from test_data/test_dir_3/test_script_error.sh rename to test_data/severity_mode/test_script_error.sh diff --git a/test_data/test_dir_3/test_script_info.sh b/test_data/severity_mode/test_script_info.sh similarity index 100% rename from test_data/test_dir_3/test_script_info.sh rename to test_data/severity_mode/test_script_info.sh diff --git a/test_data/test_dir_3/test_script_no_error.sh b/test_data/severity_mode/test_script_no_error.sh similarity index 100% rename from test_data/test_dir_3/test_script_no_error.sh rename to test_data/severity_mode/test_script_no_error.sh diff --git a/test_data/test_dir_3/test_script_style.sh b/test_data/severity_mode/test_script_style.sh similarity index 100% rename from test_data/test_dir_3/test_script_style.sh rename to test_data/severity_mode/test_script_style.sh diff --git a/test_data/test_dir_3/test_script_warning.sh b/test_data/severity_mode/test_script_warning.sh similarity index 100% rename from test_data/test_dir_3/test_script_warning.sh rename to test_data/severity_mode/test_script_warning.sh diff --git a/test_data/test.txt b/test_data/test.txt deleted file mode 100644 index e670cdf..0000000 --- a/test_data/test.txt +++ /dev/null @@ -1 +0,0 @@ -This is a test document. \ No newline at end of file diff --git a/test_data/test_dir_1/example_script.sh b/test_data/test_dir/example_script.sh similarity index 100% rename from test_data/test_dir_1/example_script.sh rename to test_data/test_dir/example_script.sh diff --git a/test_data/test_dir/executable_script b/test_data/test_dir/executable_script new file mode 100755 index 0000000..36ac368 --- /dev/null +++ b/test_data/test_dir/executable_script @@ -0,0 +1 @@ +#! /bin/bash diff --git a/test_data/test_dir_1/invalid_script b/test_data/test_dir/invalid_script similarity index 100% rename from test_data/test_dir_1/invalid_script rename to test_data/test_dir/invalid_script diff --git a/test_data/test_dir_2/test_script_1.sh b/test_data/test_dir_2/test_script_1.sh deleted file mode 100755 index efcbaec..0000000 --- a/test_data/test_dir_2/test_script_1.sh +++ /dev/null @@ -1 +0,0 @@ -#! /bin/bash \ No newline at end of file diff --git a/test_data/test_dir_2/test_script_2.sh b/test_data/test_dir_2/test_script_2.sh deleted file mode 100755 index efcbaec..0000000 --- a/test_data/test_dir_2/test_script_2.sh +++ /dev/null @@ -1 +0,0 @@ -#! /bin/bash \ No newline at end of file diff --git a/tests/integration_tests/input_path_tests.sh b/tests/integration_tests/input_path_tests.sh new file mode 100755 index 0000000..7318fb7 --- /dev/null +++ b/tests/integration_tests/input_path_tests.sh @@ -0,0 +1,122 @@ +#! /bin/bash +# shellcheck disable=SC2155 + +source ./entrypoint.sh "" "" "--test" + +test_execution_mode(){ + local expected_path=./test_data + process_input > /dev/null + local actual_path=$my_dir + + assertEquals "ERROR: Values did not match." "$expected_path" "$actual_path" +} + +test_invalid_script_with_extension(){ + input_paths="./test_data/script_type/test_script.js" + local expected1="Found 1 unscanned files that could potentially be supported" + local expected2="ShellCheck only supports sh/bash/dash/ksh scripts. For supported scripts to be scanned, make sure to add a proper shebang on the first line of the script." + local actual=$(process_input) + + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected1" + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected2" + +} + +test_invalid_script_without_extension(){ + input_paths="./test_data/script_type/test_python" + local expected1="Found 1 unscanned files that could potentially be supported" + local expected2="ShellCheck only supports sh/bash/dash/ksh scripts. For supported scripts to be scanned, make sure to add a proper shebang on the first line of the script." + local actual=$(process_input) + + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected1" + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected2" + +} + +test_unsupported_script_without_extension(){ + input_paths="./test_data/script_type/test_zsh_wsh" + local expect1="Found 1 unscanned files that could potentially be supported" + local expect2="ShellCheck only supports sh/bash/dash/ksh scripts. For supported scripts to be scanned, make sure to add a proper shebang on the first line of the script." + local actual=$(process_input) + + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expect1" + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expect2" +} + +test_unsupported_script_with_extension(){ + input_paths="./test_data/script_type/test.zsh" + local expect1="Found 1 unscanned files that could potentially be supported" + local expect2="ShellCheck only supports sh/bash/dash/ksh scripts. For supported scripts to be scanned, make sure to add a proper shebang on the first line of the script." + local actual=$(process_input) + + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expect1" + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expect2" +} + +test_valid_file_without_shebang(){ + input_paths="./test_data/script_type/test_script_wosh.sh" + local expected1="Found 1 unscanned files that could potentially be supported" + local expected2="ShellCheck only supports sh/bash/dash/ksh scripts. For supported scripts to be scanned, make sure to add a proper shebang on the first line of the script." + local actual=$(process_input) + + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected1" + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected2" + +} + +test_valid_file_input(){ + input_paths="./test_data/test_dir/example_script.sh" + local expected="Scanning example_script.sh" + local actual=$(process_input) + + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected" +} + +test_default_input_file(){ + input_paths="." + local expected_expect="Scanning all the shell scripts at ./test_data" + local actual=$(process_input) + + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected_expect" +} + +test_input_directory(){ + input_paths="./test_data/test_dir" + local expect1="Scanning all the shell scripts at ./test_data/test_dir" + local expect2="Scanning example_script.sh" + local expect3="Scanning executable_script" + local expect4="Found 1 unscanned files that could potentially be supported" + local actual=$(process_input) + + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expect1" + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expect2" + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expect3" + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expect4" +} + +test_multiple_input_directories(){ + input_paths="./test_data/test_dir,./test_data/script_type" + local expected1="Scanning all the shell scripts at ./test_data/test_dir" + local expected2="Scanning all the shell scripts at ./test_data/script_type" + local actual=$(process_input) + + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expect1" + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected2" +} + +test_input_files_with_wildcard() { + input_paths="./test_data/script_type/test*.sh" + local expected1="Scanning test_script_wsh.sh" + local expected2="Found 1 unscanned files that could potentially be supported" + local actual=$(process_input) + + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected1" + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected2" +} + + + +tearDown(){ + input_paths="" +} +source ./tests/shunit2 \ No newline at end of file diff --git a/tests/integration_tests/process_input_tests.sh b/tests/integration_tests/process_input_tests.sh deleted file mode 100755 index d2e68ff..0000000 --- a/tests/integration_tests/process_input_tests.sh +++ /dev/null @@ -1,149 +0,0 @@ -#! /bin/bash -# shellcheck disable=SC2155 - -source ./entrypoint.sh "" "" "--debug" - -test_debug_mode(){ - local expected_path=./test_data - process_input > /dev/null - local actual_path=$my_dir - - assertEquals "ERROR: Values did not match." "$expected_path" "$actual_path" -} - -test_valid_file_input(){ - input_paths="./test_data/test_dir_1/example_script.sh" - local expected="Scanning example_script.sh" - local actual=$(process_input) - - assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected" -} - -test_invalid_file1_input(){ - input_paths="./test_data/test.txt" - local expected="Warning: './test_data/test.txt' is not a valid shell script. Make sure shebang is on the first line." - local actual=$(process_input) - - assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected" -} - -test_invalid_file2_input(){ - input_paths="./test_data/test_dir_1/invalid_script" - local expected="Warning: './test_data/test_dir_1/invalid_script' is not a valid shell script. Make sure shebang is on the first line." - local actual=$(process_input) - - assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected" -} - -test_default_input_file(){ - input_paths="." - local expected_message="Scanning all the shell scripts at ./test_data" - local actual_message=$(process_input) - - assertContains "Actual messages:$actual_message Did not contain the expected message.\n" "$actual_message" "$expected_message" -} - -test_input_directory(){ - input_paths="./test_data/test_dir_1" - local message1="Scanning all the shell scripts at ./test_data/test_dir_1" - local message2="Scanning example_script.sh" - local message3="Scanning executable_script" - local message4="Scanning not_executable_script" - local actual_message=$(process_input) - - assertContains "Actual messages:$actual_message Did not contain the expected message.\n" "$actual_message" "$message1" - assertContains "Actual messages:$actual_message Did not contain the expected message.\n" "$actual_message" "$message2" - assertContains "Actual messages:$actual_message Did not contain the expected message.\n" "$actual_message" "$message3" - assertNotContains "Actual messages:$actual_message contains the expected message.\n" "$actual_message" "$message4" -} - -test_multiple_input_directories(){ - input_paths="./test_data/test_dir_1,./test_data/test_dir_2" - local expected_message1="Scanning all the shell scripts at ./test_data/test_dir_1" - local expected_message2="Scanning all the shell scripts at ./test_data/test_dir_2" - local actual_message=$(process_input) - - assertContains "Actual messages:$actual_message Did not contain the expected message.\n" "$actual_message" "$expected_message1" - assertContains "Actual messages:$actual_message Did not contain the expected message.\n" "$actual_message" "$expected_message2" -} - -test_input_files_with_wildcard() { - input_paths="./test_data/test_dir_2/test*.sh" - local expected_message1="Scanning test_script_1.sh" - local expected_message2="Scanning test_script_2.sh" - local actual_message=$(process_input) - - assertContains "Actual messages:$actual_message Did not contain the expected message.\n" "$actual_message" "$expected_message1" - assertContains "Actual messages:$actual_message Did not contain the expected message.\n" "$actual_message" "$expected_message2" -} - -test_input_directories_with_wildcard() { - input_paths="./test_data/test_dir*" - local expected_message1="Scanning all the shell scripts at ./test_data/test_dir_1" - local expected_message2="Scanning all the shell scripts at ./test_data/test_dir_2" - local actual_message=$(process_input) - - assertContains "Actual messages:$actual_message Did not contain the expected message.\n" "$actual_message" "$expected_message1" - assertContains "Actual messages:$actual_message Did not contain the expected message.\n" "$actual_message" "$expected_message2" -} - -test_severity_mode_invalid(){ - input_paths="./test_data/test_dir_3/test_script_warning.sh" - severity_mode="verbose" - local expected_message1="Error setting unknown severity mode. Defaulting severity mode to style." - local expected_message2="SC2143" - local actual_message=$(process_input) - - assertContains "Did not find the message." "$actual_message" "$expected_message1" - assertContains "Did not find the message." "$actual_message" "$expected_message2" -} - -test_severity_mode_error(){ - input_paths="./test_data/test_dir_3/test_script_error.sh" - severity_mode="error" - local expected_message="SC1050" - local actual_message=$(process_input) - - assertContains "Did not find the message." "$actual_message" "$expected_message" -} - -test_severity_mode_no_error(){ - input_paths="./test_data/test_dir_3/test_script_no_error.sh" - severity_mode="error" - local expected_message="Successfully scanned" - local actual_message=$(process_input) - - assertContains "Did not find the message." "$actual_message" "$expected_message" -} - -test_severity_mode_warning(){ - input_paths="./test_data/test_dir_3/test_script_warning.sh" - severity_mode="warning" - local expected_message="SC2053" - local actual_message=$(process_input) - - assertContains "Did not find the message." "$actual_message" "$expected_message" -} - -test_severity_mode_info(){ - input_paths="./test_data/test_dir_3/test_script_info.sh" - severity_mode="info" - local expected_message="SC2035" - local actual_message=$(process_input) - - assertContains "Did not find the message." "$actual_message" "$expected_message" -} - -test_severity_mode_style(){ - input_paths="./test_data/test_dir_3/test_script_style.sh" - severity_mode="style" - local expected_message="SC2005" - local actual_message=$(process_input) - - assertContains "Did not find the message." "$actual_message" "$expected_message" -} - -tearDown(){ - input_paths="" -} -source ./tests/shunit2 \ No newline at end of file diff --git a/tests/integration_tests/severity_mode_tests.sh b/tests/integration_tests/severity_mode_tests.sh new file mode 100755 index 0000000..5b6b6bd --- /dev/null +++ b/tests/integration_tests/severity_mode_tests.sh @@ -0,0 +1,61 @@ +#! /bin/bash + +source ./entrypoint.sh "" "" "--test" + +test_severity_mode_invalid(){ + input_paths="./test_data/severity_mode/test_script_warning.sh" + severity_mode="verbose" + local expected_message1="Warning: unknown severity mode. Defaulting severity mode to style." + local expected_message2="SC2143" + local actual_message=$(process_input) + + assertContains "Did not find the message." "$actual_message" "$expected_message1" + assertContains "Did not find the message." "$actual_message" "$expected_message2" +} + +test_severity_mode_error(){ + input_paths="./test_data/severity_mode/test_script_error.sh" + severity_mode="error" + local expected_message="SC1050" + local actual_message=$(process_input) + + assertContains "Did not find the message." "$actual_message" "$expected_message" +} + +test_severity_mode_no_error(){ + input_paths="./test_data/severity_mode/test_script_no_error.sh" + severity_mode="error" + local expected_message="Successfully scanned" + local actual_message=$(process_input) + + assertContains "Did not find the message." "$actual_message" "$expected_message" +} + +test_severity_mode_warning(){ + input_paths="./test_data/severity_mode/test_script_warning.sh" + severity_mode="warning" + local expected_message="SC2053" + local actual_message=$(process_input) + + assertContains "Did not find the message." "$actual_message" "$expected_message" +} + +test_severity_mode_info(){ + input_paths="./test_data/severity_mode/test_script_info.sh" + severity_mode="info" + local expected_message="SC2035" + local actual_message=$(process_input) + + assertContains "Did not find the message." "$actual_message" "$expected_message" +} + +test_severity_mode_style(){ + input_paths="./test_data/severity_mode/test_script_style.sh" + severity_mode="style" + local expected_message="SC2005" + local actual_message=$(process_input) + + assertContains "Did not find the message." "$actual_message" "$expected_message" +} + +source ./tests/shunit2 diff --git a/tests/unit_tests/input_scan_tests.sh b/tests/unit_tests/input_scan_tests.sh deleted file mode 100755 index eeef25e..0000000 --- a/tests/unit_tests/input_scan_tests.sh +++ /dev/null @@ -1,38 +0,0 @@ -#! /bin/bash -# shellcheck disable=SC2155 - -source ./entrypoint.sh "" "" "--debug" - - -test_scan_valid_file_1(){ - local expected="Scanning example_script.sh" - local actual=$(scan_file ./test_data/test_dir_1/example_script.sh) - assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected" -} - -test_scan_valid_file2(){ - local expected="Scanning executable_script" - local actual=$(scan_file ./test_data/test_dir_1/executable_script) - assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected" -} - -test_scan_invalid_file1(){ - local expected="Warning: './test_data/test.txt' is not a valid shell script. Make sure shebang is on the first line." - local actual=$(scan_file ./test_data/test.txt) - assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected" -} - -test_scan_a_directory(){ - local message1="Scanning all the shell scripts at ./test_data/test_dir_1" - local message2="Scanning example_script.sh" - local message3="Scanning executable_script" - local message4="Warning: './test_data/test_dir_1/invalid_script' is not scanned. If it is a shell script, make sure shebang is on the first line." - local actual_message=$(scan_all ./test_data/test_dir_1) - - assertContains "Actual messages:$actual_message Did not contain the expected message.\n" "$actual_message" "$message1" - assertContains "Actual messages:$actual_message Did not contain the expected message.\n" "$actual_message" "$message2" - assertContains "Actual messages:$actual_message Did not contain the expected message.\n" "$actual_message" "$message3" - assertContains "Actual messages:$actual_message contains the expected message.\n" "$actual_message" "$message4" -} - -source ./tests/shunit2 \ No newline at end of file diff --git a/tests/unit_tests/scan_tests.sh b/tests/unit_tests/scan_tests.sh new file mode 100755 index 0000000..1ef1252 --- /dev/null +++ b/tests/unit_tests/scan_tests.sh @@ -0,0 +1,50 @@ +#! /bin/bash +# shellcheck disable=SC2155 + +source ./entrypoint.sh "" "style" "--test" + +# scan_file() tests +test_scan_valid_script_with_extension(){ + local expected="Scanning sample.bash" + local actual=$(scan_file ./test_data/script_type/sample.bash) + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected" +} + +test_scan_valid_script_without_extension(){ + local expected="Scanning executable_script" + local actual=$(scan_file ./test_data/test_dir/executable_script) + assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected" +} + +test_scan_unsuppoted_script(){ + local expected1="Scanning test.zsh" + local expected2="ShellCheck only supports sh/bash/dash/ksh scripts. For supported scripts to be scanned, make sure to add a proper shebang on the first line of the script." + local actual=$(scan_file ./test_data/script_type/test.zsh) + assertNotContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected1" + assertNotContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected2" +} + +# scan_all() tests +test_scan_a_directory(){ + local message1="Scanning all the shell scripts at ./test_data/script_type" + local message2="Scanning sample.bash" + local message3="Scanning test_script_wsh.sh" + local message4="ShellCheck only supports sh/bash/dash/ksh scripts. For supported scripts to be scanned, make sure to add a proper shebang on the first line of the script." + local actual_message=$(scan_all ./test_data/script_type) + + assertContains "Actual messages:$actual_message Did not contain the expected message.\n" "$actual_message" "$message1" + assertContains "Actual messages:$actual_message Did not contain the expected message.\n" "$actual_message" "$message2" + assertContains "Actual messages:$actual_message Did not contain the expected message.\n" "$actual_message" "$message3" + assertNotContains "Actual messages:$actual_message contain the expected message.\n" "$actual_message" "$message4" + +} + +test_unscanned_files_count(){ + local expected_count=3 + scan_all ./test_data/script_type > /dev/null + local actual_count="${#invalid_files[@]}" + + assertEquals "$expected_count" "$actual_count" +} + +source ./tests/shunit2 \ No newline at end of file