test: a warning on any compile path must not fail the build
The fixture puts a #warning in each kind of source the build compiles — module interface, module implementation, C, consumer — plus an unknown -z value so ld.lld warns on the link step too, and asserts the build succeeds cold (every unit compiling, every warning emitted), succeeds with nothing to do, and succeeds again after each source is touched back into staleness. The staged copy lives outside the repo because the whole test depends on units compiling for the first time. The last pass breaks a source on purpose: "never fails" would satisfy everything above just as well, so the error path is asserted too — both that it fails and that it still reports the compiler's diagnostic.
This commit is contained in:
parent
8e2d21a2bc
commit
67d31689bc
6 changed files with 211 additions and 0 deletions
9
tests/CompilerWarning/fixture/lib/Widget.cpp
Normal file
9
tests/CompilerWarning/fixture/lib/Widget.cpp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
||||
|
||||
module;
|
||||
#warning "implementation unit is noisy"
|
||||
module Widget;
|
||||
import std;
|
||||
|
||||
std::int32_t WidgetValue() { return 42; }
|
||||
13
tests/CompilerWarning/fixture/lib/Widget.cppm
Normal file
13
tests/CompilerWarning/fixture/lib/Widget.cppm
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
||||
|
||||
module;
|
||||
// Every source in this fixture carries a #warning: -W#warnings is on by
|
||||
// default, so each unit produces diagnostics on stderr and still exits 0.
|
||||
// That is the whole point — the build has to read the exit status, not the
|
||||
// chatter.
|
||||
#warning "interface unit is noisy"
|
||||
export module Widget;
|
||||
import std;
|
||||
|
||||
export std::int32_t WidgetValue();
|
||||
8
tests/CompilerWarning/fixture/lib/counter.c
Normal file
8
tests/CompilerWarning/fixture/lib/counter.c
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
/* SPDX-License-Identifier: LGPL-3.0-only
|
||||
SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts® */
|
||||
|
||||
#warning "C source is noisy"
|
||||
|
||||
long CounterValue(void) {
|
||||
return 7;
|
||||
}
|
||||
17
tests/CompilerWarning/fixture/main.cpp
Normal file
17
tests/CompilerWarning/fixture/main.cpp
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
||||
|
||||
#warning "consumer is noisy"
|
||||
|
||||
import std;
|
||||
import Widget;
|
||||
|
||||
extern "C" long CounterValue();
|
||||
|
||||
// Prints "<module value> <C value>". The test asserts on it so that "the build
|
||||
// succeeded" also means the objects behind those two numbers were really
|
||||
// produced, not merely left over from an earlier pass.
|
||||
int main() {
|
||||
std::print("{} {}", WidgetValue(), CounterValue());
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in a new issue