From 1280773c42722dcb386e8c7c5f173cc1eed8ebb6 Mon Sep 17 00:00:00 2001 From: Chemaclass Date: Sat, 1 Aug 2026 21:13:47 +0200 Subject: [PATCH] refactor(tests): mirror the src/ module layout in tests/unit/ Closes #957. tests/unit/ was 71 flat files with the module encoded in a filename prefix; src/ has been seventeen modules since #948. Now the tree matches: tests/unit/coverage/engine_test.sh for src/coverage/engine.sh tests/unit/runner/exec_test.sh for src/runner/exec.sh Sixteen directories named for their source module, plus tests/unit/project/ for the ten tests that cover the repo's own tooling and invariants rather than a module: the five release_*, package_json, build, bash_version, bash_compatibility and redirect_error. Naming that honestly beats filing them under a module name that would be a lie. Three classes of breakage, all found by running rather than by reading: - Fifteen tests resolve paths from their own location. Moving them one level deeper broke `$(bashunit::current_dir)/fixtures/...`. Fixtures stay shared at tests/unit/fixtures/, so those become ../fixtures/. The four find_files_recursive tests now pass a repo-relative input instead, because a ../ in the input reappears in the output they assert on. - The assert_snapshot snapshots had to move and be renamed with their test. Two of them had already been auto-recorded at the new path by the failing runs, with the wrong content: the "unsuccessful" cases record the expected text rather than the actual, which would have inverted the two tests that exist to demonstrate a mismatch. The originals were restored and diffed. - Renaming introduced three duplicate basenames, which cost 52 tests under --parallel. That is a real bashunit bug, filed as #959: results are bucketed by basename in runner/result.sh, so same-named files in different directories share a bucket and overwrite each other, silently and green. Same class as #923. Worked around here by keeping basenames unique; the fix belongs to #959. Verified by the number the whole issue was designed around: the sequential total is 1629 before and after, and --parallel --simple --strict is 1588, which is the 1585 baseline plus the three collection-guard tests from #958. --- .../unit/{ => api}/custom_assertions_test.sh | 0 tests/unit/{ => api}/globals_test.sh | 4 +- tests/unit/{ => api}/skip_todo_test.sh | 0 tests/unit/{ => api}/test_title_test.sh | 0 .../advanced_test.sh} | 0 .../assertions_test.sh} | 0 .../basic_test.sh} | 0 .../dates_test.sh} | 0 .../duration_test.sh} | 0 .../{file_test.sh => assert/files_test.sh} | 0 .../folders_test.sh} | 0 .../json_test.sh} | 0 .../numeric_test.sh} | 0 .../once_test.sh} | 0 .../snapshot_test.sh} | 0 ...successful_assert_match_snapshot.snapshot} | 0 ...ert_match_snapshot_ignore_colors.snapshot} | 0 ...successful_assert_match_snapshot.snapshot} | 0 ...ert_match_snapshot_ignore_colors.snapshot} | 0 .../string_test.sh} | 0 tests/unit/{ => benchmark}/benchmark_test.sh | 0 tests/unit/{ => cli}/doc_test.sh | 0 tests/unit/{ => cli}/upgrade_test.sh | 0 tests/unit/{ => cli}/watch_checksum_test.sh | 0 tests/unit/{ => cli}/watch_polling_test.sh | 0 tests/unit/{ => cli}/watch_test.sh | 0 .../env_deprecated_aliases_test.sh | 0 tests/unit/{ => config}/env_test.sh | 0 tests/unit/{ => config}/parallel_test.sh | 0 tests/unit/{ => config}/rerun_test.sh | 0 tests/unit/{ => console}/colors_test.sh | 0 .../header_test.sh} | 0 .../results_diff_test.sh} | 0 .../results_test.sh} | 0 .../branches_test.sh} | 0 .../core_test.sh} | 0 .../engine_test.sh} | 0 .../executable_test.sh} | 0 .../helpers_test.sh} | 0 .../parallel_aggregation_test.sh} | 0 .../percent_test.sh} | 0 .../reporting_test.sh} | 0 .../subshell_test.sh} | 0 tests/unit/{ => doubles}/test_doubles_test.sh | 6 +-- .../helper_test.sh} | 40 +++++++++---------- .../tag_test.sh} | 0 .../tags_map_test.sh} | 4 +- tests/unit/{ => learn}/learn_test.sh | 2 +- tests/unit/{ => main}/completions_test.sh | 0 tests/unit/{ => main}/main_test.sh | 0 .../{ => project}/bash_compatibility_test.sh | 0 tests/unit/{ => project}/bash_version_test.sh | 0 tests/unit/{ => project}/build_test.sh | 2 +- tests/unit/{ => project}/package_json_test.sh | 2 +- .../unit/{ => project}/redirect_error_test.sh | 0 .../{ => project}/release_generation_test.sh | 4 +- .../{ => project}/release_sandbox_test.sh | 2 +- .../unit/{ => project}/release_update_test.sh | 4 +- .../{ => project}/release_utilities_test.sh | 4 +- .../{ => project}/release_validation_test.sh | 2 +- .../report_json_test.sh} | 0 tests/unit/{ => reports}/reports_test.sh | 0 .../context_test.sh} | 0 .../diagnostics_test.sh} | 0 .../discovery_test.sh} | 0 .../exec_test.sh} | 0 .../hooks_test.sh} | 0 .../payload_test.sh} | 0 tests/unit/{ => state}/state_test.sh | 0 tests/unit/{ => system}/check_os_test.sh | 2 +- tests/unit/{ => system}/dependencies_test.sh | 0 tests/unit/{ => system}/io_test.sh | 0 tests/unit/{ => util}/clock_test.sh | 0 tests/unit/{ => util}/math_test.sh | 0 tests/unit/{ => util}/str_test.sh | 0 75 files changed, 39 insertions(+), 39 deletions(-) rename tests/unit/{ => api}/custom_assertions_test.sh (100%) rename tests/unit/{ => api}/globals_test.sh (97%) rename tests/unit/{ => api}/skip_todo_test.sh (100%) rename tests/unit/{ => api}/test_title_test.sh (100%) rename tests/unit/{assert_advanced_test.sh => assert/advanced_test.sh} (100%) rename tests/unit/{assert_assertions_test.sh => assert/assertions_test.sh} (100%) rename tests/unit/{assert_basic_test.sh => assert/basic_test.sh} (100%) rename tests/unit/{assert_dates_test.sh => assert/dates_test.sh} (100%) rename tests/unit/{assert_duration_test.sh => assert/duration_test.sh} (100%) rename tests/unit/{file_test.sh => assert/files_test.sh} (100%) rename tests/unit/{directory_test.sh => assert/folders_test.sh} (100%) rename tests/unit/{assert_json_test.sh => assert/json_test.sh} (100%) rename tests/unit/{assert_numeric_test.sh => assert/numeric_test.sh} (100%) rename tests/unit/{assert_once_test.sh => assert/once_test.sh} (100%) rename tests/unit/{assert_snapshot_test.sh => assert/snapshot_test.sh} (100%) rename tests/unit/{snapshots/assert_snapshot_test_sh.test_successful_assert_match_snapshot.snapshot => assert/snapshots/snapshot_test_sh.test_successful_assert_match_snapshot.snapshot} (100%) rename tests/unit/{snapshots/assert_snapshot_test_sh.test_successful_assert_match_snapshot_ignore_colors.snapshot => assert/snapshots/snapshot_test_sh.test_successful_assert_match_snapshot_ignore_colors.snapshot} (100%) rename tests/unit/{snapshots/assert_snapshot_test_sh.test_unsuccessful_assert_match_snapshot.snapshot => assert/snapshots/snapshot_test_sh.test_unsuccessful_assert_match_snapshot.snapshot} (100%) rename tests/unit/{snapshots/assert_snapshot_test_sh.test_unsuccessful_assert_match_snapshot_ignore_colors.snapshot => assert/snapshots/snapshot_test_sh.test_unsuccessful_assert_match_snapshot_ignore_colors.snapshot} (100%) rename tests/unit/{assert_string_test.sh => assert/string_test.sh} (100%) rename tests/unit/{ => benchmark}/benchmark_test.sh (100%) rename tests/unit/{ => cli}/doc_test.sh (100%) rename tests/unit/{ => cli}/upgrade_test.sh (100%) rename tests/unit/{ => cli}/watch_checksum_test.sh (100%) rename tests/unit/{ => cli}/watch_polling_test.sh (100%) rename tests/unit/{ => cli}/watch_test.sh (100%) rename tests/unit/{ => config}/env_deprecated_aliases_test.sh (100%) rename tests/unit/{ => config}/env_test.sh (100%) rename tests/unit/{ => config}/parallel_test.sh (100%) rename tests/unit/{ => config}/rerun_test.sh (100%) rename tests/unit/{ => console}/colors_test.sh (100%) rename tests/unit/{console_header_test.sh => console/header_test.sh} (100%) rename tests/unit/{console_results_diff_test.sh => console/results_diff_test.sh} (100%) rename tests/unit/{console_results_test.sh => console/results_test.sh} (100%) rename tests/unit/{coverage_branches_test.sh => coverage/branches_test.sh} (100%) rename tests/unit/{coverage_core_test.sh => coverage/core_test.sh} (100%) rename tests/unit/{coverage_engine_test.sh => coverage/engine_test.sh} (100%) rename tests/unit/{coverage_executable_test.sh => coverage/executable_test.sh} (100%) rename tests/unit/{coverage_helpers_test.sh => coverage/helpers_test.sh} (100%) rename tests/unit/{coverage_parallel_aggregation_test.sh => coverage/parallel_aggregation_test.sh} (100%) rename tests/unit/{coverage_percent_test.sh => coverage/percent_test.sh} (100%) rename tests/unit/{coverage_reporting_test.sh => coverage/reporting_test.sh} (100%) rename tests/unit/{coverage_subshell_test.sh => coverage/subshell_test.sh} (100%) rename tests/unit/{ => doubles}/test_doubles_test.sh (97%) rename tests/unit/{helpers_test.sh => helper/helper_test.sh} (93%) rename tests/unit/{helpers_tag_test.sh => helper/tag_test.sh} (100%) rename tests/unit/{helpers_tags_map_test.sh => helper/tags_map_test.sh} (90%) rename tests/unit/{ => learn}/learn_test.sh (98%) rename tests/unit/{ => main}/completions_test.sh (100%) rename tests/unit/{ => main}/main_test.sh (100%) rename tests/unit/{ => project}/bash_compatibility_test.sh (100%) rename tests/unit/{ => project}/bash_version_test.sh (100%) rename tests/unit/{ => project}/build_test.sh (99%) rename tests/unit/{ => project}/package_json_test.sh (97%) rename tests/unit/{ => project}/redirect_error_test.sh (100%) rename tests/unit/{ => project}/release_generation_test.sh (98%) rename tests/unit/{ => project}/release_sandbox_test.sh (99%) rename tests/unit/{ => project}/release_update_test.sh (98%) rename tests/unit/{ => project}/release_utilities_test.sh (99%) rename tests/unit/{ => project}/release_validation_test.sh (99%) rename tests/unit/{reports_json_test.sh => reports/report_json_test.sh} (100%) rename tests/unit/{ => reports}/reports_test.sh (100%) rename tests/unit/{runner_context_test.sh => runner/context_test.sh} (100%) rename tests/unit/{runner_diagnostics_test.sh => runner/diagnostics_test.sh} (100%) rename tests/unit/{runner_discovery_test.sh => runner/discovery_test.sh} (100%) rename tests/unit/{runner_exec_test.sh => runner/exec_test.sh} (100%) rename tests/unit/{setup_teardown_test.sh => runner/hooks_test.sh} (100%) rename tests/unit/{runner_payload_test.sh => runner/payload_test.sh} (100%) rename tests/unit/{ => state}/state_test.sh (100%) rename tests/unit/{ => system}/check_os_test.sh (97%) rename tests/unit/{ => system}/dependencies_test.sh (100%) rename tests/unit/{ => system}/io_test.sh (100%) rename tests/unit/{ => util}/clock_test.sh (100%) rename tests/unit/{ => util}/math_test.sh (100%) rename tests/unit/{ => util}/str_test.sh (100%) diff --git a/tests/unit/custom_assertions_test.sh b/tests/unit/api/custom_assertions_test.sh similarity index 100% rename from tests/unit/custom_assertions_test.sh rename to tests/unit/api/custom_assertions_test.sh diff --git a/tests/unit/globals_test.sh b/tests/unit/api/globals_test.sh similarity index 97% rename from tests/unit/globals_test.sh rename to tests/unit/api/globals_test.sh index fcb39646..4e648226 100644 --- a/tests/unit/globals_test.sh +++ b/tests/unit/api/globals_test.sh @@ -23,7 +23,7 @@ function tear_down() { } function test_globals_current_dir() { - assert_same "tests/unit" "$(bashunit::current_dir)" + assert_same "tests/unit/api" "$(bashunit::current_dir)" } function test_globals_current_filename() { @@ -38,7 +38,7 @@ function globals_test::call_caller_filename() { } function test_globals_caller_filename() { - assert_same "tests/unit" "$(globals_test::call_caller_filename)" + assert_same "tests/unit/api" "$(globals_test::call_caller_filename)" } function test_globals_caller_line() { diff --git a/tests/unit/skip_todo_test.sh b/tests/unit/api/skip_todo_test.sh similarity index 100% rename from tests/unit/skip_todo_test.sh rename to tests/unit/api/skip_todo_test.sh diff --git a/tests/unit/test_title_test.sh b/tests/unit/api/test_title_test.sh similarity index 100% rename from tests/unit/test_title_test.sh rename to tests/unit/api/test_title_test.sh diff --git a/tests/unit/assert_advanced_test.sh b/tests/unit/assert/advanced_test.sh similarity index 100% rename from tests/unit/assert_advanced_test.sh rename to tests/unit/assert/advanced_test.sh diff --git a/tests/unit/assert_assertions_test.sh b/tests/unit/assert/assertions_test.sh similarity index 100% rename from tests/unit/assert_assertions_test.sh rename to tests/unit/assert/assertions_test.sh diff --git a/tests/unit/assert_basic_test.sh b/tests/unit/assert/basic_test.sh similarity index 100% rename from tests/unit/assert_basic_test.sh rename to tests/unit/assert/basic_test.sh diff --git a/tests/unit/assert_dates_test.sh b/tests/unit/assert/dates_test.sh similarity index 100% rename from tests/unit/assert_dates_test.sh rename to tests/unit/assert/dates_test.sh diff --git a/tests/unit/assert_duration_test.sh b/tests/unit/assert/duration_test.sh similarity index 100% rename from tests/unit/assert_duration_test.sh rename to tests/unit/assert/duration_test.sh diff --git a/tests/unit/file_test.sh b/tests/unit/assert/files_test.sh similarity index 100% rename from tests/unit/file_test.sh rename to tests/unit/assert/files_test.sh diff --git a/tests/unit/directory_test.sh b/tests/unit/assert/folders_test.sh similarity index 100% rename from tests/unit/directory_test.sh rename to tests/unit/assert/folders_test.sh diff --git a/tests/unit/assert_json_test.sh b/tests/unit/assert/json_test.sh similarity index 100% rename from tests/unit/assert_json_test.sh rename to tests/unit/assert/json_test.sh diff --git a/tests/unit/assert_numeric_test.sh b/tests/unit/assert/numeric_test.sh similarity index 100% rename from tests/unit/assert_numeric_test.sh rename to tests/unit/assert/numeric_test.sh diff --git a/tests/unit/assert_once_test.sh b/tests/unit/assert/once_test.sh similarity index 100% rename from tests/unit/assert_once_test.sh rename to tests/unit/assert/once_test.sh diff --git a/tests/unit/assert_snapshot_test.sh b/tests/unit/assert/snapshot_test.sh similarity index 100% rename from tests/unit/assert_snapshot_test.sh rename to tests/unit/assert/snapshot_test.sh diff --git a/tests/unit/snapshots/assert_snapshot_test_sh.test_successful_assert_match_snapshot.snapshot b/tests/unit/assert/snapshots/snapshot_test_sh.test_successful_assert_match_snapshot.snapshot similarity index 100% rename from tests/unit/snapshots/assert_snapshot_test_sh.test_successful_assert_match_snapshot.snapshot rename to tests/unit/assert/snapshots/snapshot_test_sh.test_successful_assert_match_snapshot.snapshot diff --git a/tests/unit/snapshots/assert_snapshot_test_sh.test_successful_assert_match_snapshot_ignore_colors.snapshot b/tests/unit/assert/snapshots/snapshot_test_sh.test_successful_assert_match_snapshot_ignore_colors.snapshot similarity index 100% rename from tests/unit/snapshots/assert_snapshot_test_sh.test_successful_assert_match_snapshot_ignore_colors.snapshot rename to tests/unit/assert/snapshots/snapshot_test_sh.test_successful_assert_match_snapshot_ignore_colors.snapshot diff --git a/tests/unit/snapshots/assert_snapshot_test_sh.test_unsuccessful_assert_match_snapshot.snapshot b/tests/unit/assert/snapshots/snapshot_test_sh.test_unsuccessful_assert_match_snapshot.snapshot similarity index 100% rename from tests/unit/snapshots/assert_snapshot_test_sh.test_unsuccessful_assert_match_snapshot.snapshot rename to tests/unit/assert/snapshots/snapshot_test_sh.test_unsuccessful_assert_match_snapshot.snapshot diff --git a/tests/unit/snapshots/assert_snapshot_test_sh.test_unsuccessful_assert_match_snapshot_ignore_colors.snapshot b/tests/unit/assert/snapshots/snapshot_test_sh.test_unsuccessful_assert_match_snapshot_ignore_colors.snapshot similarity index 100% rename from tests/unit/snapshots/assert_snapshot_test_sh.test_unsuccessful_assert_match_snapshot_ignore_colors.snapshot rename to tests/unit/assert/snapshots/snapshot_test_sh.test_unsuccessful_assert_match_snapshot_ignore_colors.snapshot diff --git a/tests/unit/assert_string_test.sh b/tests/unit/assert/string_test.sh similarity index 100% rename from tests/unit/assert_string_test.sh rename to tests/unit/assert/string_test.sh diff --git a/tests/unit/benchmark_test.sh b/tests/unit/benchmark/benchmark_test.sh similarity index 100% rename from tests/unit/benchmark_test.sh rename to tests/unit/benchmark/benchmark_test.sh diff --git a/tests/unit/doc_test.sh b/tests/unit/cli/doc_test.sh similarity index 100% rename from tests/unit/doc_test.sh rename to tests/unit/cli/doc_test.sh diff --git a/tests/unit/upgrade_test.sh b/tests/unit/cli/upgrade_test.sh similarity index 100% rename from tests/unit/upgrade_test.sh rename to tests/unit/cli/upgrade_test.sh diff --git a/tests/unit/watch_checksum_test.sh b/tests/unit/cli/watch_checksum_test.sh similarity index 100% rename from tests/unit/watch_checksum_test.sh rename to tests/unit/cli/watch_checksum_test.sh diff --git a/tests/unit/watch_polling_test.sh b/tests/unit/cli/watch_polling_test.sh similarity index 100% rename from tests/unit/watch_polling_test.sh rename to tests/unit/cli/watch_polling_test.sh diff --git a/tests/unit/watch_test.sh b/tests/unit/cli/watch_test.sh similarity index 100% rename from tests/unit/watch_test.sh rename to tests/unit/cli/watch_test.sh diff --git a/tests/unit/env_deprecated_aliases_test.sh b/tests/unit/config/env_deprecated_aliases_test.sh similarity index 100% rename from tests/unit/env_deprecated_aliases_test.sh rename to tests/unit/config/env_deprecated_aliases_test.sh diff --git a/tests/unit/env_test.sh b/tests/unit/config/env_test.sh similarity index 100% rename from tests/unit/env_test.sh rename to tests/unit/config/env_test.sh diff --git a/tests/unit/parallel_test.sh b/tests/unit/config/parallel_test.sh similarity index 100% rename from tests/unit/parallel_test.sh rename to tests/unit/config/parallel_test.sh diff --git a/tests/unit/rerun_test.sh b/tests/unit/config/rerun_test.sh similarity index 100% rename from tests/unit/rerun_test.sh rename to tests/unit/config/rerun_test.sh diff --git a/tests/unit/colors_test.sh b/tests/unit/console/colors_test.sh similarity index 100% rename from tests/unit/colors_test.sh rename to tests/unit/console/colors_test.sh diff --git a/tests/unit/console_header_test.sh b/tests/unit/console/header_test.sh similarity index 100% rename from tests/unit/console_header_test.sh rename to tests/unit/console/header_test.sh diff --git a/tests/unit/console_results_diff_test.sh b/tests/unit/console/results_diff_test.sh similarity index 100% rename from tests/unit/console_results_diff_test.sh rename to tests/unit/console/results_diff_test.sh diff --git a/tests/unit/console_results_test.sh b/tests/unit/console/results_test.sh similarity index 100% rename from tests/unit/console_results_test.sh rename to tests/unit/console/results_test.sh diff --git a/tests/unit/coverage_branches_test.sh b/tests/unit/coverage/branches_test.sh similarity index 100% rename from tests/unit/coverage_branches_test.sh rename to tests/unit/coverage/branches_test.sh diff --git a/tests/unit/coverage_core_test.sh b/tests/unit/coverage/core_test.sh similarity index 100% rename from tests/unit/coverage_core_test.sh rename to tests/unit/coverage/core_test.sh diff --git a/tests/unit/coverage_engine_test.sh b/tests/unit/coverage/engine_test.sh similarity index 100% rename from tests/unit/coverage_engine_test.sh rename to tests/unit/coverage/engine_test.sh diff --git a/tests/unit/coverage_executable_test.sh b/tests/unit/coverage/executable_test.sh similarity index 100% rename from tests/unit/coverage_executable_test.sh rename to tests/unit/coverage/executable_test.sh diff --git a/tests/unit/coverage_helpers_test.sh b/tests/unit/coverage/helpers_test.sh similarity index 100% rename from tests/unit/coverage_helpers_test.sh rename to tests/unit/coverage/helpers_test.sh diff --git a/tests/unit/coverage_parallel_aggregation_test.sh b/tests/unit/coverage/parallel_aggregation_test.sh similarity index 100% rename from tests/unit/coverage_parallel_aggregation_test.sh rename to tests/unit/coverage/parallel_aggregation_test.sh diff --git a/tests/unit/coverage_percent_test.sh b/tests/unit/coverage/percent_test.sh similarity index 100% rename from tests/unit/coverage_percent_test.sh rename to tests/unit/coverage/percent_test.sh diff --git a/tests/unit/coverage_reporting_test.sh b/tests/unit/coverage/reporting_test.sh similarity index 100% rename from tests/unit/coverage_reporting_test.sh rename to tests/unit/coverage/reporting_test.sh diff --git a/tests/unit/coverage_subshell_test.sh b/tests/unit/coverage/subshell_test.sh similarity index 100% rename from tests/unit/coverage_subshell_test.sh rename to tests/unit/coverage/subshell_test.sh diff --git a/tests/unit/test_doubles_test.sh b/tests/unit/doubles/test_doubles_test.sh similarity index 97% rename from tests/unit/test_doubles_test.sh rename to tests/unit/doubles/test_doubles_test.sh index 3420cc4e..667164c6 100644 --- a/tests/unit/test_doubles_test.sh +++ b/tests/unit/doubles/test_doubles_test.sh @@ -71,7 +71,7 @@ function test_unsuccessful_spy_called_times() { function test_successful_spy_with_source_function() { # shellcheck source=/dev/null - source "$(bashunit::current_dir)/fixtures/fake_function_to_spy.sh" + source "$(bashunit::current_dir)/../fixtures/fake_function_to_spy.sh" bashunit::spy function_to_be_spied_on function_to_be_spied_on @@ -81,7 +81,7 @@ function test_successful_spy_with_source_function() { function test_unsuccessful_spy_with_source_function_have_been_called() { # shellcheck source=/dev/null - source "$(bashunit::current_dir)/fixtures/fake_function_to_spy.sh" + source "$(bashunit::current_dir)/../fixtures/fake_function_to_spy.sh" bashunit::spy function_to_be_spied_on function_to_be_spied_on @@ -99,7 +99,7 @@ function test_unsuccessful_spy_with_source_function_have_been_called() { function test_successful_spy_called_times_with_source() { # shellcheck source=/dev/null - source "$(bashunit::current_dir)/fixtures/fake_function_to_spy.sh" + source "$(bashunit::current_dir)/../fixtures/fake_function_to_spy.sh" bashunit::spy function_to_be_spied_on function_to_be_spied_on diff --git a/tests/unit/helpers_test.sh b/tests/unit/helper/helper_test.sh similarity index 93% rename from tests/unit/helpers_test.sh rename to tests/unit/helper/helper_test.sh index a1ae3f4a..91370a81 100644 --- a/tests/unit/helpers_test.sh +++ b/tests/unit/helper/helper_test.sh @@ -125,28 +125,28 @@ function test_successful_unset_if_exists() { function test_check_duplicate_functions_with_duplicates() { local file - file="$(bashunit::current_dir)/fixtures/duplicate_functions.sh" + file="$(bashunit::current_dir)/../fixtures/duplicate_functions.sh" assert_general_error "$(bashunit::helper::check_duplicate_functions "$file")" } function test_check_duplicate_functions_without_duplicates() { local file - file="$(bashunit::current_dir)/fixtures/no_duplicate_functions.sh" + file="$(bashunit::current_dir)/../fixtures/no_duplicate_functions.sh" assert_successful_code "$(bashunit::helper::check_duplicate_functions "$file")" } function test_check_duplicate_functions_without_function_keyword() { local file - file="$(bashunit::current_dir)/fixtures/no_function_keyword_duplicates.sh" + file="$(bashunit::current_dir)/../fixtures/no_function_keyword_duplicates.sh" assert_general_error "$(bashunit::helper::check_duplicate_functions "$file")" } function test_check_duplicate_functions_reports_each_duplicate_name_sorted() { local file names - file="$(bashunit::current_dir)/fixtures/multiple_duplicate_functions.sh" + file="$(bashunit::current_dir)/../fixtures/multiple_duplicate_functions.sh" # Isolate the state mutation in a subshell; report the stored duplicate names. names=$( @@ -255,7 +255,7 @@ function test_get_provider_data_should_returns_empty_when_not_exists_provider_fu "$(bashunit::helper::get_provider_data "fake_function_get_not_existing_provider_data" "${BASH_SOURCE[0]}")" } -FIXTURE_PROVIDER_MAP="$(dirname "${BASH_SOURCE[0]}")/fixtures/provider_map/sample_providers.sh" +FIXTURE_PROVIDER_MAP="$(dirname "${BASH_SOURCE[0]}")/../fixtures/provider_map/sample_providers.sh" function provider_for() { bashunit::helper::build_provider_map "$1" @@ -324,7 +324,7 @@ function test_build_provider_map_no_parallel_marker_defaults_false() { function test_find_files_recursive_given_file() { local path - path="$(bashunit::current_dir)/fixtures/tests/example1_test.sh" + path="tests/unit/fixtures/tests/example1_test.sh" local result result=$(bashunit::helper::find_files_recursive "$path") @@ -334,7 +334,7 @@ function test_find_files_recursive_given_file() { function test_find_files_recursive_given_dir() { local path - path="$(bashunit::current_dir)/fixtures/tests" + path="tests/unit/fixtures/tests" local result result=$(bashunit::helper::find_files_recursive "$path") @@ -347,7 +347,7 @@ tests/unit/fixtures/tests/example3_test.bash" \ function test_find_files_recursive_given_wildcard() { local path - path="$(bashunit::current_dir)/fixtures/tests/*2_test.sh" + path="tests/unit/fixtures/tests/*2_test.sh" local result result=$(bashunit::helper::find_files_recursive "$path") @@ -357,7 +357,7 @@ function test_find_files_recursive_given_wildcard() { function test_find_files_recursive_given_bash_extension() { local path - path="$(bashunit::current_dir)/fixtures/tests/*3_test.bash" + path="tests/unit/fixtures/tests/*3_test.bash" local result result=$(bashunit::helper::find_files_recursive "$path") @@ -465,21 +465,21 @@ function test_find_total_tests_no_files() { function test_find_total_tests_simple_file() { local file - file="$(bashunit::current_dir)/fixtures/find_total_tests/simple_fixture.sh" + file="$(bashunit::current_dir)/../fixtures/find_total_tests/simple_fixture.sh" assert_same "2" "$(helpers_test::find_total_in_subshell "" "$file")" } function test_find_total_tests_simple_file_bash() { local file - file="$(bashunit::current_dir)/fixtures/find_total_tests/simple_fixture.bash" + file="$(bashunit::current_dir)/../fixtures/find_total_tests/simple_fixture.bash" assert_same "2" "$(helpers_test::find_total_in_subshell "" "$file")" } function test_find_total_tests_with_provider() { local file - file="$(bashunit::current_dir)/fixtures/find_total_tests/provider_fixture.sh" + file="$(bashunit::current_dir)/../fixtures/find_total_tests/provider_fixture.sh" assert_same "3" "$(helpers_test::find_total_in_subshell "" "$file")" } @@ -487,8 +487,8 @@ function test_find_total_tests_with_provider() { function test_find_total_tests_multiple_files() { local file1 local file2 - file1="$(bashunit::current_dir)/fixtures/find_total_tests/simple_fixture.sh" - file2="$(bashunit::current_dir)/fixtures/find_total_tests/provider_fixture.sh" + file1="$(bashunit::current_dir)/../fixtures/find_total_tests/simple_fixture.sh" + file2="$(bashunit::current_dir)/../fixtures/find_total_tests/provider_fixture.sh" assert_same "5" "$(helpers_test::find_total_in_subshell "" "$file1" "$file2")" } @@ -496,8 +496,8 @@ function test_find_total_tests_multiple_files() { function test_find_total_tests_with_filter() { local file1 local file2 - file1="$(bashunit::current_dir)/fixtures/find_total_tests/simple_fixture.sh" - file2="$(bashunit::current_dir)/fixtures/find_total_tests/provider_fixture.sh" + file1="$(bashunit::current_dir)/../fixtures/find_total_tests/simple_fixture.sh" + file2="$(bashunit::current_dir)/../fixtures/find_total_tests/provider_fixture.sh" assert_same "3" "$(helpers_test::find_total_in_subshell "with_provider" "$file1" "$file2")" } @@ -574,28 +574,28 @@ function test_parse_file_path_filter_with_colon_in_path() { function test_find_function_at_line_first_function() { local file - file="$(bashunit::current_dir)/fixtures/find_total_tests/simple_fixture.sh" + file="$(bashunit::current_dir)/../fixtures/find_total_tests/simple_fixture.sh" assert_same "test_first" "$(bashunit::helper::find_function_at_line "$file" 4)" } function test_find_function_at_line_second_function() { local file - file="$(bashunit::current_dir)/fixtures/find_total_tests/simple_fixture.sh" + file="$(bashunit::current_dir)/../fixtures/find_total_tests/simple_fixture.sh" assert_same "test_second" "$(bashunit::helper::find_function_at_line "$file" 8)" } function test_find_function_at_line_exact_function_line() { local file - file="$(bashunit::current_dir)/fixtures/find_total_tests/simple_fixture.sh" + file="$(bashunit::current_dir)/../fixtures/find_total_tests/simple_fixture.sh" assert_same "test_first" "$(bashunit::helper::find_function_at_line "$file" 3)" } function test_find_function_at_line_before_any_function() { local file - file="$(bashunit::current_dir)/fixtures/find_total_tests/simple_fixture.sh" + file="$(bashunit::current_dir)/../fixtures/find_total_tests/simple_fixture.sh" assert_same "" "$(bashunit::helper::find_function_at_line "$file" 1)" } diff --git a/tests/unit/helpers_tag_test.sh b/tests/unit/helper/tag_test.sh similarity index 100% rename from tests/unit/helpers_tag_test.sh rename to tests/unit/helper/tag_test.sh diff --git a/tests/unit/helpers_tags_map_test.sh b/tests/unit/helper/tags_map_test.sh similarity index 90% rename from tests/unit/helpers_tags_map_test.sh rename to tests/unit/helper/tags_map_test.sh index d05a1caa..f6fa1bd6 100644 --- a/tests/unit/helpers_tags_map_test.sh +++ b/tests/unit/helper/tags_map_test.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash # shellcheck disable=SC2317 -FIXTURE_TAGS_MAP="$(dirname "${BASH_SOURCE[0]}")/fixtures/tags_map/sample_tags.sh" -FIXTURE_TAGS_MAP_OTHER="$(dirname "${BASH_SOURCE[0]}")/fixtures/tags_map/sample_tags_other.sh" +FIXTURE_TAGS_MAP="$(dirname "${BASH_SOURCE[0]}")/../fixtures/tags_map/sample_tags.sh" +FIXTURE_TAGS_MAP_OTHER="$(dirname "${BASH_SOURCE[0]}")/../fixtures/tags_map/sample_tags_other.sh" function tags_for() { bashunit::helper::build_tags_map "$1" diff --git a/tests/unit/learn_test.sh b/tests/unit/learn/learn_test.sh similarity index 98% rename from tests/unit/learn_test.sh rename to tests/unit/learn/learn_test.sh index b8f6df25..b7a9e846 100644 --- a/tests/unit/learn_test.sh +++ b/tests/unit/learn/learn_test.sh @@ -13,7 +13,7 @@ function _learn_in_sandbox() { sandbox="$(bashunit::temp_dir)" # Resolve the repo root from this test file, not $BASHUNIT_ROOT_DIR: under # `build.sh --verify` the running binary's root dir has no src/ (#834). - root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" + root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)" # stdin is /dev/null so the `read -p "Press Enter to continue..."` prompts in # the interactive paths hit EOF and return instead of blocking the suite. # BASHUNIT_ROOT_DIR is set INSIDE the child (run_lesson_test shells out to the diff --git a/tests/unit/completions_test.sh b/tests/unit/main/completions_test.sh similarity index 100% rename from tests/unit/completions_test.sh rename to tests/unit/main/completions_test.sh diff --git a/tests/unit/main_test.sh b/tests/unit/main/main_test.sh similarity index 100% rename from tests/unit/main_test.sh rename to tests/unit/main/main_test.sh diff --git a/tests/unit/bash_compatibility_test.sh b/tests/unit/project/bash_compatibility_test.sh similarity index 100% rename from tests/unit/bash_compatibility_test.sh rename to tests/unit/project/bash_compatibility_test.sh diff --git a/tests/unit/bash_version_test.sh b/tests/unit/project/bash_version_test.sh similarity index 100% rename from tests/unit/bash_version_test.sh rename to tests/unit/project/bash_version_test.sh diff --git a/tests/unit/build_test.sh b/tests/unit/project/build_test.sh similarity index 99% rename from tests/unit/build_test.sh rename to tests/unit/project/build_test.sh index d2cb8996..61a3fabb 100644 --- a/tests/unit/build_test.sh +++ b/tests/unit/project/build_test.sh @@ -3,7 +3,7 @@ ROOT_DIR="" function set_up_before_script() { - ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" + ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)" } function src_files_sourced_by_entrypoint() { diff --git a/tests/unit/package_json_test.sh b/tests/unit/project/package_json_test.sh similarity index 97% rename from tests/unit/package_json_test.sh rename to tests/unit/project/package_json_test.sh index 01f88a5b..918ba241 100644 --- a/tests/unit/package_json_test.sh +++ b/tests/unit/project/package_json_test.sh @@ -5,7 +5,7 @@ PKG_FILE="" DOCS_PKG_FILE="" function set_up_before_script() { - ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" + ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)" PKG_FILE="$ROOT_DIR/package.json" DOCS_PKG_FILE="$ROOT_DIR/docs/package.json" } diff --git a/tests/unit/redirect_error_test.sh b/tests/unit/project/redirect_error_test.sh similarity index 100% rename from tests/unit/redirect_error_test.sh rename to tests/unit/project/redirect_error_test.sh diff --git a/tests/unit/release_generation_test.sh b/tests/unit/project/release_generation_test.sh similarity index 98% rename from tests/unit/release_generation_test.sh rename to tests/unit/project/release_generation_test.sh index c5b2f97d..23bd8c94 100644 --- a/tests/unit/release_generation_test.sh +++ b/tests/unit/project/release_generation_test.sh @@ -11,8 +11,8 @@ RELEASE_SCRIPT_DIR="" FIXTURES_DIR="" function set_up_before_script() { - RELEASE_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" - FIXTURES_DIR="$(dirname "${BASH_SOURCE[0]}")/fixtures/release" + RELEASE_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)" + FIXTURES_DIR="$(dirname "${BASH_SOURCE[0]}")/../fixtures/release" # Source release.sh to get access to functions # shellcheck source=/dev/null diff --git a/tests/unit/release_sandbox_test.sh b/tests/unit/project/release_sandbox_test.sh similarity index 99% rename from tests/unit/release_sandbox_test.sh rename to tests/unit/project/release_sandbox_test.sh index 4fde81bd..01b83c7c 100644 --- a/tests/unit/release_sandbox_test.sh +++ b/tests/unit/project/release_sandbox_test.sh @@ -11,7 +11,7 @@ RELEASE_SCRIPT_DIR="" FIXTURE_DIR="" function set_up_before_script() { - RELEASE_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" + RELEASE_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)" # Source release.sh to get access to functions # shellcheck source=/dev/null diff --git a/tests/unit/release_update_test.sh b/tests/unit/project/release_update_test.sh similarity index 98% rename from tests/unit/release_update_test.sh rename to tests/unit/project/release_update_test.sh index 7ffeb5e3..14b30df1 100644 --- a/tests/unit/release_update_test.sh +++ b/tests/unit/project/release_update_test.sh @@ -11,8 +11,8 @@ RELEASE_SCRIPT_DIR="" FIXTURES_DIR="" function set_up_before_script() { - RELEASE_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" - FIXTURES_DIR="$(dirname "${BASH_SOURCE[0]}")/fixtures/release" + RELEASE_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)" + FIXTURES_DIR="$(dirname "${BASH_SOURCE[0]}")/../fixtures/release" # Source release.sh to get access to functions # shellcheck source=/dev/null diff --git a/tests/unit/release_utilities_test.sh b/tests/unit/project/release_utilities_test.sh similarity index 99% rename from tests/unit/release_utilities_test.sh rename to tests/unit/project/release_utilities_test.sh index 2faeab18..a1c942c5 100644 --- a/tests/unit/release_utilities_test.sh +++ b/tests/unit/project/release_utilities_test.sh @@ -11,8 +11,8 @@ RELEASE_SCRIPT_DIR="" FIXTURES_DIR="" function set_up_before_script() { - RELEASE_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" - FIXTURES_DIR="$(dirname "${BASH_SOURCE[0]}")/fixtures/release" + RELEASE_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)" + FIXTURES_DIR="$(dirname "${BASH_SOURCE[0]}")/../fixtures/release" # Source release.sh to get access to functions # shellcheck source=/dev/null diff --git a/tests/unit/release_validation_test.sh b/tests/unit/project/release_validation_test.sh similarity index 99% rename from tests/unit/release_validation_test.sh rename to tests/unit/project/release_validation_test.sh index 4c576416..533ca9d3 100644 --- a/tests/unit/release_validation_test.sh +++ b/tests/unit/project/release_validation_test.sh @@ -10,7 +10,7 @@ fi RELEASE_SCRIPT_DIR="" function set_up_before_script() { - RELEASE_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" + RELEASE_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)" # Source release.sh to get access to functions # shellcheck source=/dev/null diff --git a/tests/unit/reports_json_test.sh b/tests/unit/reports/report_json_test.sh similarity index 100% rename from tests/unit/reports_json_test.sh rename to tests/unit/reports/report_json_test.sh diff --git a/tests/unit/reports_test.sh b/tests/unit/reports/reports_test.sh similarity index 100% rename from tests/unit/reports_test.sh rename to tests/unit/reports/reports_test.sh diff --git a/tests/unit/runner_context_test.sh b/tests/unit/runner/context_test.sh similarity index 100% rename from tests/unit/runner_context_test.sh rename to tests/unit/runner/context_test.sh diff --git a/tests/unit/runner_diagnostics_test.sh b/tests/unit/runner/diagnostics_test.sh similarity index 100% rename from tests/unit/runner_diagnostics_test.sh rename to tests/unit/runner/diagnostics_test.sh diff --git a/tests/unit/runner_discovery_test.sh b/tests/unit/runner/discovery_test.sh similarity index 100% rename from tests/unit/runner_discovery_test.sh rename to tests/unit/runner/discovery_test.sh diff --git a/tests/unit/runner_exec_test.sh b/tests/unit/runner/exec_test.sh similarity index 100% rename from tests/unit/runner_exec_test.sh rename to tests/unit/runner/exec_test.sh diff --git a/tests/unit/setup_teardown_test.sh b/tests/unit/runner/hooks_test.sh similarity index 100% rename from tests/unit/setup_teardown_test.sh rename to tests/unit/runner/hooks_test.sh diff --git a/tests/unit/runner_payload_test.sh b/tests/unit/runner/payload_test.sh similarity index 100% rename from tests/unit/runner_payload_test.sh rename to tests/unit/runner/payload_test.sh diff --git a/tests/unit/state_test.sh b/tests/unit/state/state_test.sh similarity index 100% rename from tests/unit/state_test.sh rename to tests/unit/state/state_test.sh diff --git a/tests/unit/check_os_test.sh b/tests/unit/system/check_os_test.sh similarity index 97% rename from tests/unit/check_os_test.sh rename to tests/unit/system/check_os_test.sh index 84ea08f4..83266a3b 100644 --- a/tests/unit/check_os_test.sh +++ b/tests/unit/system/check_os_test.sh @@ -85,7 +85,7 @@ function test_module_load_detects_os_with_a_single_uname_call() { # under `build.sh --verify` the built bashunit lives in a folder # without src/, and sourcing through $BASHUNIT_ROOT_DIR crashed # the whole verification run (silently, until #834 gated it). - source "$(dirname "${BASH_SOURCE[0]}")/../../src/system/check_os.sh" + source "$(dirname "${BASH_SOURCE[0]}")/../../../src/system/check_os.sh" assert_have_been_called_times 1 uname } diff --git a/tests/unit/dependencies_test.sh b/tests/unit/system/dependencies_test.sh similarity index 100% rename from tests/unit/dependencies_test.sh rename to tests/unit/system/dependencies_test.sh diff --git a/tests/unit/io_test.sh b/tests/unit/system/io_test.sh similarity index 100% rename from tests/unit/io_test.sh rename to tests/unit/system/io_test.sh diff --git a/tests/unit/clock_test.sh b/tests/unit/util/clock_test.sh similarity index 100% rename from tests/unit/clock_test.sh rename to tests/unit/util/clock_test.sh diff --git a/tests/unit/math_test.sh b/tests/unit/util/math_test.sh similarity index 100% rename from tests/unit/math_test.sh rename to tests/unit/util/math_test.sh diff --git a/tests/unit/str_test.sh b/tests/unit/util/str_test.sh similarity index 100% rename from tests/unit/str_test.sh rename to tests/unit/util/str_test.sh