Skip to content

Check and fix mock names in pre-commit hook - #464

Merged
MaciejKaszynski merged 9 commits into
eclipse-score:mainfrom
etas-contrib:check-mock-naming
Aug 17, 2026
Merged

MaciejKaszynski merged 9 commits into
eclipse-score:mainfrom
etas-contrib:check-mock-naming

Conversation

@cameron-craig-etas

@cameron-craig-etas cameron-craig-etas commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

#422

This PR adds a Python script to validate test doubles (mocks, stubs, fakes etc.), to ensure they use the test double name as a prefix (e.g mock_component.cpp). We recently updated all our mocks to use a consistent format (/pull/457). This pre-commit will keep things nice and tidy 🧹

As far as testing goes I have ran through these scenarios manually:

  • Attempting to commit a mock with a backwards name:
    Check and fix test double file names.....................................Failed
    - hook id: test-doubles-naming-fix
    - exit code: 1
    - files were modified by this hook
    
    WARNING: Non-conformant files have been found, fixing now.
    WARNING: Renaming: score/launch_manager/src/daemon/src/process_group_manager/details/component_mock.hpp -> score/launch_manager/src/daemon/src/process_group_manager/details/mock_component.hpp.
    
  • Attempting to commit a stub with a backwards name:
    Check and fix test double file names.....................................Failed
    - hook id: test-doubles-naming-fix
    - exit code: 1
    - files were modified by this hook
    
    WARNING: Non-conformant files have been found, fixing now.
    WARNING: Renaming: bad_stub.hpp -> stub_bad.hpp.
    
  • Attempting to commit a mock stub mutant hybrid:
    Check and fix test double file names.....................................Failed
    - hook id: test-doubles-naming-fix
    - exit code: 1
    
    Traceback (most recent call last):
      File "/home/crc1yok/git/lifecycle/./scripts/fix_test_doubles_naming_precommit.py", line 236, in <module>
        raise SystemExit(main())
                       ^^^^^^
      File "/home/crc1yok/git/lifecycle/./scripts/fix_test_doubles_naming_precommit.py", line 201, in main
        operations = define_operations(args.filenames)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/crc1yok/git/lifecycle/./scripts/fix_test_doubles_naming_precommit.py", line 136, in define_operations
        raise ValueError(
    ValueError: Invalid file name mock_fake.hpp contains multiple double names.
    
  • Adding a mock with multiple file extensions:
    Check and fix test double file names.....................................Failed
    - hook id: test-doubles-naming-fix
    - exit code: 1
    
    Traceback (most recent call last):
      File "/home/crc1yok/git/lifecycle/./scripts/fix_test_doubles_naming_precommit.py", line 239, in <module>
        raise SystemExit(main())
                         ^^^^^^
      File "/home/crc1yok/git/lifecycle/./scripts/fix_test_doubles_naming_precommit.py", line 204, in main
        operations = define_operations(args.filenames)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/crc1yok/git/lifecycle/./scripts/fix_test_doubles_naming_precommit.py", line 141, in define_operations
        raise ValueError(
    ValueError: More than one file extension found for test double test_mock.old.cpp. Fix this!
    
  • A valid commit with no changes to test doubles
    Check and fix copyright headers with cr_checker..........................Passed
    

@cameron-craig-etas cameron-craig-etas changed the title Check mock names in pre-commit hook Check an fix mock names in pre-commit hook Aug 13, 2026
@github-actions

github-actions Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run --lockfile_mode=error //:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Extracting Bazel installation...
Starting local Bazel server (8.6.0) and connecting to it...
INFO: Invocation ID: 7961d054-ab70-4495-be85-f057ad22413a
Computing main repo mapping: 
Computing main repo mapping: 
Loading: 
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
    currently loading: 
Loading: 0 packages loaded
    currently loading: 
Loading: 0 packages loaded
    currently loading: 
Loading: 0 packages loaded
    currently loading: 
Loading: 0 packages loaded
    currently loading: 
Loading: 0 packages loaded
    currently loading: 
Loading: 0 packages loaded
    currently loading: 
Analyzing: target //:license-check (1 packages loaded, 0 targets configured)
Analyzing: target //:license-check (1 packages loaded, 0 targets configured)

Analyzing: target //:license-check (27 packages loaded, 10 targets configured)

Analyzing: target //:license-check (85 packages loaded, 10 targets configured)

Analyzing: target //:license-check (90 packages loaded, 10 targets configured)

Analyzing: target //:license-check (152 packages loaded, 3161 targets configured)

Analyzing: target //:license-check (161 packages loaded, 5780 targets configured)

Analyzing: target //:license-check (167 packages loaded, 9402 targets configured)

Analyzing: target //:license-check (172 packages loaded, 9451 targets configured)

Analyzing: target //:license-check (173 packages loaded, 9575 targets configured)

INFO: Analyzed target //:license-check (177 packages loaded, 11589 targets configured).
[6 / 15] [Prepa] Creating source manifest for //:license.check.license_check
INFO: Found 1 target...
Target //:license.check.license_check up-to-date:
  bazel-bin/license.check.license_check
  bazel-bin/license.check.license_check.jar
INFO: Elapsed time: 24.806s, Critical Path: 0.25s
INFO: 16 processes: 4 disk cache hit, 12 internal.
INFO: Build completed successfully, 16 total actions
INFO: Running command line: bazel-bin/license.check.license_check ./formatted.txt <args omitted>
usage: org.eclipse.dash.licenses.cli.Main [-batch <int>] [-cd <url>]
       [-confidence <int>] [-ef <url>] [-excludeSources <sources>] [-help] [-lic
       <url>] [-project <shortname>] [-repo <url>] [-review] [-summary <file>]
       [-timeout <seconds>] [-token <token>]

@github-actions

Copy link
Copy Markdown
Contributor

The created documentation from the pull request is available at: docu-html

@cameron-craig-etas cameron-craig-etas changed the title Check an fix mock names in pre-commit hook Check and fix mock names in pre-commit hook Aug 14, 2026
@cameron-craig-etas
cameron-craig-etas marked this pull request as ready for review August 14, 2026 07:05

@MaciejKaszynski MaciejKaszynski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly nit picks

Comment thread README.md Outdated
Comment thread .pre-commit-config.yaml Outdated
Comment thread scripts/fix_test_doubles_naming_precommit.py Outdated
Comment thread scripts/fix_test_doubles_naming_precommit.py Outdated
Comment thread scripts/fix_test_doubles_naming_precommit.py Outdated
@MaciejKaszynski
MaciejKaszynski merged commit c1b015f into eclipse-score:main Aug 17, 2026
22 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in LCM - Lifecycle & Health FT Aug 17, 2026

This branch was successfully deployed

1 active deployment
workflow-approval — c057fbf5 Deployed Aug 17, 2026 by cameron-craig-etas via Build and test unit-tests-arm64-qnx / approval #94
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants