Skip to content

[bazel] Make //codepropertygraph:tests run the actual tests - #1870

Merged
max-leuthaeuser merged 1 commit into
masterfrom
max/bazel-test-fix
Oct 19, 2026
Merged

max-leuthaeuser merged 1 commit into
masterfrom
max/bazel-test-fix

Conversation

@max-leuthaeuser

@max-leuthaeuser max-leuthaeuser commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

//codepropertygraph:tests globbed src/main/scala instead of src/test/scala and therefore ran 0 tests while reporting PASSED.

  • Use src/test/scala and ship src/test/resources as data.
  • Add better-files (+ repin) which the tests use, and link the domain classes (//schema:domainClassesLinked) at runtime because the compile time target is neverlink.
  • Resolve test resources the same way as in the rest of our codebases (e.g. joern's JoernRunfilesLocator): Bazel runfiles lookup first, fallback to ProjectRoot.relativise which is only used by sbt/IDE. New test-only CpgRunfilesLocator with a Bazel implementation (src/test/javaBazel, rules_java//java/runfiles) and an sbt stub returning empty (src/test/java). Bazel tests do not rely on ProjectRoot (no FILE_IN_PROJECT_ROOT).

Testing

  • bazel test //codepropertygraph:tests: now runs 27 tests, all pass.
  • sbt test: 27 tests pass. sbt scalafmtCheck Test/scalafmtCheck, bazel build //..., bazel run formatCheck: clean.

Comment thread codepropertygraph/BUILD Outdated
The target globbed src/main/scala and therefore ran 0 tests.

- use src/test/scala and ship src/test/resources as data
- add better-files (repin) and link the domain classes at runtime
- resolve test resources via the Bazel runfiles lookup (CpgRunfilesLocator,
  same mechanism as in joern); ProjectRoot.relativise remains the fallback
  for sbt/IDE only
Comment thread codepropertygraph/BUILD
":tests_java",
"//schema:domainClassesNeverLinked",
"//schema:java_proto",
"@maven//:com_github_pathikrit_better_files_3",

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.

Can you please make a followup PR that removes better_files? This seems to be one of the last cases where it is still in our codebase.

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.

Sure.

@max-leuthaeuser
max-leuthaeuser merged commit 2c53c7b into master Oct 19, 2026
1 check passed
@max-leuthaeuser
max-leuthaeuser deleted the max/bazel-test-fix branch October 19, 2026 11:59
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