Skip to content

Add skylib tests for compile_commands.bzl - #284

Open
furtib wants to merge 7 commits into
Ericsson:mainfrom
furtib:test-bazel-mock-002
Open

Add skylib tests for compile_commands.bzl#284
furtib wants to merge 7 commits into
Ericsson:mainfrom
furtib:test-bazel-mock-002

Conversation

@furtib

@furtib furtib commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Why:
We want to properly test compile_commands generation.

What:

  • Added skylib tests to check whether compile flags have been correctly obtained.
  • Have 4 bug, tests:
    • implementation_deps does not collect defines
    • implementation_deps does not collect local_defines
    • implementaion_deps does not collect qoute_includes
    • Compile flags are duplicated

Addresses:
none

@Szelethus Szelethus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thats quite a PR! I reviewed it to the best of my ability. I'd like for you to create an issue for each of the observed bugs (or locate them). Plus points if you also mention the issue number in the TODO comments.

Comment thread test/unit/compile_commands/compile_commands_analysis_test.bzl Outdated
Comment thread test/unit/compile_commands/compile_commands_analysis_test.bzl Outdated
asserts.true(
env,
"IMPL_DEP_LOCAL_DEF" in foo_commands[0],
"Should contain local_define IMPL_DEP_LOCAL_DEF from implementation_dep, got: %s" % foo_commands[0],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is >80 columns.

Comment thread test/unit/compile_commands/compile_commands_analysis_test.bzl Outdated
furtib added 3 commits August 24, 2026 15:05
Add qoute include test

Remove most tests

Undo refactors for compile_commands.bzl
@furtib
furtib force-pushed the test-bazel-mock-002 branch from 70913e9 to 0c149bd Compare August 24, 2026 13:06
@furtib
furtib requested a review from Szelethus August 25, 2026 11:44

@Szelethus Szelethus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

Comment thread test/unit/compile_commands/compile_commands_analysis_test.bzl Outdated
Comment thread test/unit/compile_commands/compile_commands_analysis_test.bzl Outdated
Comment thread test/unit/compile_commands/compile_commands_analysis_test.bzl Outdated
Comment thread test/unit/compile_commands/compile_commands_analysis_test.bzl Outdated
Co-authored-by: Kristóf Umann <dkszelethus@gmail.com>
@@ -0,0 +1,423 @@
# Copyright 2026 Ericsson AB

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggestion: name file like test/unit/compile_commands/analysis_test.bzl instead of test/unit/compile_commands/compile_commands_analysis_test.bzl
No need to duplicate "compile_commands".

Comment on lines +383 to +407
get_compile_flags_defines_test(
name = name + "_defines_test",
target_under_test = ":" + name + "_with_defines",
)
get_compile_flags_local_defines_test(
name = name + "_local_defines_test",
target_under_test = ":" + name + "_with_local_defines",
)
get_compile_flags_includes_test(
name = name + "_includes_test",
target_under_test = ":" + name + "_with_includes",
)
get_compile_flags_copts_test(
name = name + "_copts_test",
target_under_test = ":" + name + "_with_copts",
)
get_compile_flags_dep_includes_test(
name = name + "_dep_includes_test",
target_under_test = ":" + name + "_with_dep_includes",
)
get_compile_flags_system_includes_test(
name = name + "_system_includes_test",
target_under_test = ":" + name + "_with_system_includes",
)
get_compile_flags_quote_includes_test(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These test names are just insane!
It is very hard to find which one to debug :)

Comment on lines +348 to +357
# Split command into flags and check for duplicates
flags = foo_commands[0].split(" ")
seen = []
duplicates = []
for f in flags:
if f == "":
continue
if f in seen and f not in duplicates:
duplicates.append(f)
seen.append(f)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This will produce wrong list: splitting by space will give many "-I" and "-iquote" with their values separately - not that kind of duplication :)

@nettle nettle left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice! :)
But naming "get_compile_flags_..." is terrible :)
BTW, I ran it with #303 and it works, just need to apply some fixes

@nettle

nettle commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Thats quite a PR! I reviewed it to the best of my ability. I'd like for you to create an issue for each of the observed bugs (or locate them). Plus points if you also mention the issue number in the TODO comments.

Well, I guess the way how issues were created it kind of destroyed the idea of reporting these as bugs :)
Sorry, issues do not look like bugs to fix, so have absolute no sense.
I would suggest better describe test-cases... instead of terrible test names ;)

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

Labels

test ☑️ Adding or refactoring tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants