Skip to content

Add compiler warnings override test. - #126

Merged
nradakovic merged 1 commit into
mainfrom
nira_add_warnings_override_test
Aug 24, 2026
Merged

Add compiler warnings override test.#126
nradakovic merged 1 commit into
mainfrom
nira_add_warnings_override_test

Conversation

@nradakovic

Copy link
Copy Markdown
Member

Add compiler warnings override tests to verify feature warnings order.

@nradakovic nradakovic self-assigned this Aug 24, 2026
Copilot AI lite review requested due to automatic review settings August 24, 2026 09:05
@nradakovic nradakovic added documentation Improvements or additions to documentation unit test Add or update unit tests p3 Medium/Low - handle it within normal process labels Aug 24, 2026

Copilot AI 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.

Pull request overview

Adds a new feature-verification regression test intended to ensure user-provided compiler flags (coptsuser_compile_flags) take precedence over warning-related toolchain features by virtue of their ordering.

Changes:

  • Added a new cc_test target (warning_override_test) and included it in the root feature_verification_tests suite.
  • Added documentation describing the new test and updated expected test counts / listings.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
tests/feature_verification/warning_override_test.cpp New test source meant to validate warning-override flag ordering.
tests/feature_verification/BUILD Adds the new cc_test target with copts + enabled warning feature(s).
tests/BUILD Adds the new test to feature_verification_tests.
docs/test_suite.md Documents the new test and updates expected counts/listing.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +14 to +25
// Test for: warning feature override via user flags (copts)
//
// This test verifies that the ordering between warning features and user flags
// is correct. Specifically, it tests that:
//
// 1. A warning feature (e.g., strict_warnings) is enabled and emits -Wshadow
// 2. User provides -Wno-shadow via copts (which becomes user_compile_flags)
// 3. The compilation SUCCEEDS because user_compile_flags comes AFTER warning
// features in the features list, making user flags take precedence
//
// If the flag ordering regresses (e.g., warning features come after user flags),
// this test will fail to compile, catching the regression immediately.
Comment on lines +29 to +50
// This function intentionally has variable shadowing, which triggers -Wshadow
// when strict_warnings or all_wall_warnings are enabled. The test provides
// -Wno-shadow via copts, so this should compile successfully if flag ordering
// is correct.
int shadow_function(int value) {
int result = value * 2;
{
// Intentional shadowing to trigger -Wshadow
int result = value * 3;
return result;
}
}

int main() {
std::cout << "Warning override test: shadow_function(5) = "
<< shadow_function(5) << std::endl;

std::cout << "Test passed! User -Wno-shadow flag successfully overrode "
<< "the strict_warnings feature." << std::endl;

return 0;
}
Comment thread docs/test_suite.md Outdated
Comment on lines +50 to +54
4. **`warning_override_test`** - Warning feature override via user flags
- Regression test verifying user flags (copts) can override enabled warning features
- Enables `strict_warnings` feature and provides conflicting `-Wno-shadow` via copts
- Validates that the flag ordering is correct: user_compile_flags comes after warning features,
ensuring user flags take precedence
Comment on lines +146 to +161
# Test for: warning feature override via user_compile_flags
# Verifies that user-provided flags (via copts) can override enabled warning
# features. This regression test ensures that the flag ordering between warning
# features and user_compile_flags is correct: user_compile_flags must come
# after warning features so that user flags take precedence.
#
# The test enables strict_warnings (which emits -Wshadow) and provides
# -Wno-shadow via copts. If the flag ordering is correct, the test compiles
# successfully. If ordering regresses, compilation will fail with shadowing
# warnings, immediately catching the regression.
cc_test(
name = "warning_override_test",
srcs = ["warning_override_test.cpp"],
copts = ["-Wno-shadow"],
features = ["strict_warnings"],
)
Comment thread docs/test_suite.md
Comment on lines 68 to 69
- Tests thread creation, synchronization, and joining
- Validates multiple threads can safely access shared state
@nradakovic
nradakovic force-pushed the nira_add_warnings_override_test branch from 1848abb to 44fb302 Compare August 24, 2026 09:12
Add compiler warnings override tests to verify feature warnings
order.
@nradakovic
nradakovic force-pushed the nira_add_warnings_override_test branch from 44fb302 to 23f8c45 Compare August 24, 2026 09:16
@nradakovic
nradakovic requested a lite review from Copilot August 24, 2026 09:16

Copilot AI 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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Suppressed comments (4)

tests/feature_verification/warning_override_test.cpp:23

  • This test assumes strict_warnings enables -Wshadow (and that -Wno-shadow can override it), but the toolchain templates don’t add -Wshadow as part of minimal_warnings/strict_warnings (e.g. templates/linux/cc_toolchain_flags.bzl.template:100-151). As written, the test is likely to compile regardless of flag ordering, so it won’t catch regressions.
// 1. strict_warnings (implies minimal_warnings which enables -Wall) and 
//    warnings_as_errors are both enabled, making -Wshadow an error
// 2. Code with variable shadowing would trigger an error
// 3. User provides -Wno-shadow via copts (which becomes user_compile_flags)
// 4. The compilation SUCCEEDS because user_compile_flags comes AFTER warning

tests/feature_verification/BUILD:156

  • This test’s copts/commentary are based on -Wshadow, but the toolchain warning features don’t currently enable -Wshadow, so the test may never exercise the intended failure mode. Consider switching to a warning that is actually enabled by strict_warnings/-Wall (e.g. unused parameter) and overriding that instead.
# The test enables both strict_warnings and warnings_as_errors (making warnings
# into errors), then provides -Wno-shadow via copts. If the flag ordering is
# correct, the test compiles successfully because user's -Wno-shadow overrides
# the -Wshadow error. If ordering regresses, compilation will fail with a
# -Wshadow error, immediately catching the regression.

docs/test_suite.md:55

  • The documentation describes this test as overriding -Wshadow via -Wno-shadow, but the toolchain warning features don’t currently enable -Wshadow, so that scenario is unlikely to be exercised. If the test is updated to override an actually-enabled warning (e.g. -Wunused-parameter via -Wno-unused-parameter), the docs should be updated to match.
   - Regression test verifying user flags (copts) can override enabled warning features
   - Enables both `strict_warnings` and `warnings_as_errors` features (making warnings into errors)
   - Provides conflicting `-Wno-shadow` via copts to override the warning
   - Validates that the flag ordering is correct: user_compile_flags comes after warning features,
     ensuring user flags take precedence. If ordering regresses, compilation will fail with an error.

tests/feature_verification/warning_override_test.cpp:35

  • The code currently triggers shadowing, but -Wshadow is not enabled by the toolchain’s warning features, so this is unlikely to produce a warning/error even with warnings_as_errors. Using a warning that is actually enabled by -Wall/-Wextra (e.g. -Wunused-parameter) will make this a reliable ordering regression test across toolchains.

// This function intentionally has variable shadowing, which triggers -Wshadow
// when strict_warnings or all_wall_warnings are enabled. The test provides
// -Wno-shadow via copts, so this should compile successfully if flag ordering
// is correct.

@nradakovic
nradakovic merged commit 0f5cb41 into main Aug 24, 2026
17 checks passed
@nradakovic
nradakovic deleted the nira_add_warnings_override_test branch August 24, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation p3 Medium/Low - handle it within normal process unit test Add or update unit tests

Projects

Development

Successfully merging this pull request may close these issues.

3 participants