Skip to content

[test] Unify path defines and add CPPINTEROP_BIN_DIR env override#1037

Open
conrade-ctc wants to merge 1 commit into
compiler-research:mainfrom
conrade-ctc:unify_path_defines_and_env
Open

[test] Unify path defines and add CPPINTEROP_BIN_DIR env override#1037
conrade-ctc wants to merge 1 commit into
compiler-research:mainfrom
conrade-ctc:unify_path_defines_and_env

Conversation

@conrade-ctc

@conrade-ctc conrade-ctc commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Collapse the test suite's two artifacts-prefix concepts (CPPINTEROP_LIB_PATH for the dispatch tests, CPPINTEROP_BINARY_DIR for TracingTests) into a single CPPINTEROP_BIN_DIR, overridable at runtime by an environment variable of the same name so relocated test binaries can locate libclangCppInterOp.
  • Add unittests/CppInterOp/TestPaths.h (dependency-free) with GetCppInterOpDirPath() / GetCppInterOpLibPath(): env var wins, else the compile-time default, else empty — no hard dependency on the macro being defined.
  • Drop CPPINTEROP_LIB_PATH; the dispatch tests now derive the library path from the prefix and fail with a clear message instead of std::abort() when the location is unknown.
  • Rename the TracingTests source-tree macro to CPPINTEROP_SRC_DIR (it reads .cpp/.h sources, which never live in an artifacts prefix) and route its artifacts lookups through the shared helper.

(this is related to compiler-research/cppyy-backend#211 as well)

Test plan

  • check-cppinterop: 7/7 passing, including DispatchTests and the DispatchTests-isolation ldd contract.
  • Verified all three resolution paths: env override → installed lib, env unset → baked default, bogus env → clean failure (exit 1, no abort).

🤖 Done with the help of Claude Code (Claude Opus 4.8)

@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.56%. Comparing base (84e1ff5) to head (0b148c7).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1037   +/-   ##
=======================================
  Coverage   86.56%   86.56%           
=======================================
  Files          23       23           
  Lines        5621     5621           
=======================================
  Hits         4866     4866           
  Misses        755      755           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions Bot 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.

clang-tidy made some suggestions

DispatchInitializer() {
if (!Cpp::LoadDispatchAPI(CPPINTEROP_LIB_PATH)) {
std::abort();
std::string libPath = TestUtils::GetCppInterOpLibPath();

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.

warning: no header providing "std::string" is directly included [misc-include-cleaner]

unittests/CppInterOp/DispatchInit.cpp:9:

+ #include <string>

@@ -0,0 +1,40 @@
#ifndef CPPINTEROP_UNITTESTS_LIBCPPINTEROP_TESTPATHS_H
#define CPPINTEROP_UNITTESTS_LIBCPPINTEROP_TESTPATHS_H

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.

warning: header guard does not follow preferred style [llvm-header-guard]

Suggested change
#define CPPINTEROP_UNITTESTS_LIBCPPINTEROP_TESTPATHS_H
#ifndef GITHUB_WORKSPACE_UNITTESTS_CPPINTEROP_TESTPATHS_H
#define GITHUB_WORKSPACE_UNITTESTS_CPPINTEROP_TESTPATHS_H

unittests/CppInterOp/TestPaths.h:39:

- #endif // CPPINTEROP_UNITTESTS_LIBCPPINTEROP_TESTPATHS_H
+ #endif // GITHUB_WORKSPACE_UNITTESTS_CPPINTEROP_TESTPATHS_H

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think these need to be ignored, right? Maybe there is a clang-tidy config update so this doesn't get flagged @vgvassilev?

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.

Yes!

@conrade-ctc

Copy link
Copy Markdown
Contributor Author

I had a more localized change originally, but there were some inconsistencies across the repos that I thought might be nice to tackle now since we're migrating to a consolidated repo setup, and consistency across that set seemed like a good idea. Let me know if you think that's not the right approach. @vgvassilev @Vipul-Cariappa @aaronj0

"CPPINTEROP_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/../../\""
"CPPINTEROP_BINARY_DIR=\"${CMAKE_CURRENT_BINARY_DIR}/../../\""
"CPPINTEROP_SRC_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/../../\""
"CPPINTEROP_BIN_DIR=\"${CMAKE_BINARY_DIR}\""

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.

I believe that change breaks ROOT. @aaronj0, can you review?

@vgvassilev vgvassilev requested a review from aaronj0 June 11, 2026 17:10
Dispatch tests baked the library location into a CPPINTEROP_LIB_PATH
macro and TracingTests carried both CPPINTEROP_DIR (source tree) and
CPPINTEROP_BINARY_DIR (artifacts) defines. Collapse the two
artifacts-prefix concepts into a single CPPINTEROP_BIN_DIR that a
matching environment variable overrides at runtime, so relocated test
binaries can find libclangCppInterOp:

- Add TestPaths.h with GetCppInterOpDirPath()/GetCppInterOpLibPath():
  env CPPINTEROP_BIN_DIR wins, else the compile-time default, else empty
  (no hard dependency on the macro being defined).
- Drop CPPINTEROP_LIB_PATH; the dispatch tests derive the library path
  from the prefix and fail with a clear message instead of aborting when
  it is unknown.
- Rename the TracingTests source-tree macro to CPPINTEROP_SRC_DIR and
  route its artifacts lookups through the shared helper.

Co-developed-with-the-help-of: Claude Code (Claude Opus 4.8)
@conrade-ctc conrade-ctc force-pushed the unify_path_defines_and_env branch from 8348d51 to 0b148c7 Compare June 29, 2026 15:47
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