Skip to content

[tests] Add edge case coverage for CopyIncludePaths in Paths.cpp#862

Open
voyager-jhk wants to merge 14 commits intocompiler-research:mainfrom
voyager-jhk:add-paths-coverage
Open

[tests] Add edge case coverage for CopyIncludePaths in Paths.cpp#862
voyager-jhk wants to merge 14 commits intocompiler-research:mainfrom
voyager-jhk:add-paths-coverage

Conversation

@voyager-jhk
Copy link

Description

This PR improves the test coverage for the internal utility function CopyIncludePaths located in lib/CppInterOp/Paths.cpp.

Previously, several edge-case flag branches (such as -fmodule-cache-path, -nostdinc, -stdlib=libc++, and -v) lacked test coverage.

I have:

  1. Created a dedicated PathsTest.cpp test suite.
  2. Added PathsTest.CopyIncludePathsEdgeCases to specifically target and validate these uncovered branches.
  3. Updated the unittests/CppInterOp/CMakeLists.txt to properly link the new test file.

Contributes to #541

Type of change

Please tick all options which are relevant.

  • Bug fix
  • New feature
  • Requires documentation updates
  • Test coverage improvement

Testing

Please describe the test(s) that you added and ran to verify your changes.

  • Built the CppInterOpTests target locally using CMake.
  • Successfully ran the new test suite via Google Test filter: ./unittests/CppInterOp/bin/Release/CppInterOpTests --gtest_filter="PathsTest.*"
  • Verified that all edge-case branches are correctly hit and pass without assertions or memory errors.

Checklist

  • I have read the contribution guide recently

@codecov
Copy link

codecov bot commented Mar 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.90%. Comparing base (22812bc) to head (673ed62).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #862      +/-   ##
==========================================
+ Coverage   79.75%   79.90%   +0.14%     
==========================================
  Files          11       11              
  Lines        4031     4031              
==========================================
+ Hits         3215     3221       +6     
+ Misses        816      810       -6     

see 1 file with indirect coverage changes
see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@voyager-jhk
Copy link
Author

@mcbarton @aaronj0 Looks like the linker errors only happen on cling native builds and Emscripten (WASM DCE). All clang-repl native builds are green.

Since CopyIncludePaths seems unavailable in those environments, should I just guard this test in CMake/macros, or rewrite it to hit those branches indirectly via the public Interpreter API?

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

@mcbarton
Copy link
Collaborator

@voyager-jhk to fix the Emscripten linker errors like the one in the ci, you need to work out what make use of the cppinterop_api annotation. It should be obvious how to use it looking at the source code.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

/// "-nostdinc".
///
void CopyIncludePaths(const clang::HeaderSearchOptions& Opts,
CPPINTEROP_API void CopyIncludePaths(const clang::HeaderSearchOptions& Opts,
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: unknown type name 'CPPINTEROP_API' [clang-diagnostic-error]

CPPINTEROP_API void CopyIncludePaths(const clang::HeaderSearchOptions& Opts,
^

@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants