Debug the failing test for $ARGUMENTS.
Steps:
- Find the test file in
megalinter/tests/test_megalinter/linters/ - Check if it's auto-generated (has
@generated by .automation/build.pyheader) — if so, fix the descriptor YAML or fixtures, NOT the test file itself - Read the descriptor YAML in
megalinter/descriptors/to understand expected behavior (cli_lint_mode,supported_cli_lint_modes,config_file_name,cli_lint_errors_regex,file_extensions) - Check test fixtures in
.automation/test/<test_folder>/:- Good files must pass the linter cleanly
- Bad files must trigger errors matching
cli_lint_errors_regex - File extensions must match
file_extensionsorfile_names_regexin the descriptor
- If a custom linter class exists in
megalinter/linters/, review it for issues - Common failure causes:
- Fixture file extensions don't match descriptor's
file_extensions cli_lint_errors_regexdoesn't match actual linter output format- Missing config file referenced in
config_file_name cli_lint_modemismatch (file vs list_of_files vs project)supported_cli_lint_modeslists a mode the tool can't run — the per-mode tests (test_success_<mode>_lint_mode/test_failure_<mode>_lint_mode) run for every declared mode; if a failure is confined to one mode, remove it fromsupported_cli_lint_modes(unsupported modes are auto-skipped)- Version pin broken or tool not installable in Dockerfile
- Linter behavior differs between host OS and Docker container (Linux)
test_success_project_lint_modefails on a file under.wireit/: that is a poison fixture guarding excluded-directories forwarding (see.claude/rules/testing.md). The forwarding is broken, not the fixture — check the command in the log for the forwarded exclusion arguments and the[Excluded directories]trace line, then review the descriptor'scli_lint_mode_project_exclude_*properties or the classmanage_excluded_directories_config()/build_lint_commandoverride (a custombuild_lint_commandthat does not callsuper()bypasses forwarding). Do NOT delete the poison fixture to make the test pass
- Fixture file extensions don't match descriptor's
- Reproduce in Docker (required — linters are not installed locally):
To run only specific test methods, use aLINTER="<descriptor_id_lowercase>_<linter_name>" docker buildx build --platform linux/amd64 --file linters/$LINTER/Dockerfile --tag $LINTER . docker run --rm --env TEST_CASE_RUN=true --env OUTPUT_DETAIL=detailed \ --env TEST_KEYWORDS="${LINTER}_test" --env MEGALINTER_VOLUME_ROOT="." \ --volume "$(pwd):/tmp/lint" $LINTER-k-style substring (matches all modes):# all failure-mode tests (test_failure_file_lint_mode, _list_of_files_, _project_) --env TEST_KEYWORDS="${LINTER}_test and test_failure" # narrow to a single mode --env TEST_KEYWORDS="${LINTER}_test and test_failure_project_lint_mode" - In CI, filter tests via commit message body:
TEST_KEYWORDS=<linter>_test - Update
CHANGELOG.mdonly if the fix changes user-visible linter behavior (wrong error count, missed files, broken output). Add one line under Fixes in the beta section:
Do NOT add an entry for test-infrastructure-only fixes (fixture paths, test class regeneration, etc.). Style:- Fix <linter-name>: <what was wrong and what users now get>.claude/rules/changelog.md(written for end users, no internal details).