Skip to content

Commit 7cfcfe9

Browse files
dfa1claude
andauthored
test: fail loud when the golden corpus is missing (#19)
* test: fail loud when the golden corpus is missing locateCorpus returned null when third_party/zstd/tests was absent, and filesIn turned that into an empty stream — so a missing submodule silently skipped every golden test and still went green. Throw instead: the corpus is the vendored zstd submodule, so its absence is a setup error worth surfacing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * build: enforce the golden corpus exists, with a friendly message Add maven-enforcer requireFilesExist on third_party/zstd/tests in the integration-tests module, bound to validate. A missing submodule now fails the build up front with a message telling the user to run 'git submodule update --init --recursive', instead of failing later. The runtime IllegalStateException stays as a backstop for direct/IDE runs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 7429d52 commit 7cfcfe9

2 files changed

Lines changed: 44 additions & 6 deletions

File tree

integration-tests/pom.xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,44 @@
4949
</dependency>
5050
</dependencies>
5151

52+
<build>
53+
<plugins>
54+
<!-- Fail early, with a clear message, if the vendored zstd submodule
55+
(the golden corpus these tests read) has not been checked out —
56+
before compiling or running anything. -->
57+
<plugin>
58+
<groupId>org.apache.maven.plugins</groupId>
59+
<artifactId>maven-enforcer-plugin</artifactId>
60+
<version>3.5.0</version>
61+
<executions>
62+
<execution>
63+
<id>require-golden-corpus</id>
64+
<phase>validate</phase>
65+
<goals>
66+
<goal>enforce</goal>
67+
</goals>
68+
<configuration>
69+
<rules>
70+
<requireFilesExist>
71+
<files>
72+
<file>${maven.multiModuleProjectDirectory}/third_party/zstd/tests</file>
73+
</files>
74+
<message>
75+
The golden corpus is missing: third_party/zstd/tests was not found.
76+
These integration tests read the vendored zstd submodule. Check it out with:
77+
78+
git submodule update --init --recursive
79+
80+
then re-run the build.</message>
81+
</requireFilesExist>
82+
</rules>
83+
</configuration>
84+
</execution>
85+
</executions>
86+
</plugin>
87+
</plugins>
88+
</build>
89+
5290
<!-- The matching native library for the host platform (test scope only). -->
5391
<profiles>
5492
<!-- Activated by ./mvnw verify -P coverage alongside the parent profile.

integration-tests/src/test/java/io/github/dfa1/zstd/it/GoldenCorpusTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ class GoldenCorpusTest {
3838

3939
private static final Path TESTS = locateCorpus();
4040

41-
/// Walks up from the working directory to find `third_party/zstd/tests`,
42-
/// or returns `null` if the submodule is absent.
41+
/// Walks up from the working directory to find `third_party/zstd/tests`.
42+
/// The corpus is the vendored zstd submodule, so its absence is a setup
43+
/// error — fail loudly rather than silently skipping every golden test.
4344
private static Path locateCorpus() {
4445
Path dir = Path.of("").toAbsolutePath();
4546
for (; dir != null; dir = dir.getParent()) {
@@ -48,13 +49,12 @@ private static Path locateCorpus() {
4849
return candidate;
4950
}
5051
}
51-
return null;
52+
throw new IllegalStateException(
53+
"golden corpus not found: third_party/zstd/tests is missing — "
54+
+ "initialise the zstd submodule (git submodule update --init --recursive)");
5255
}
5356

5457
private static Stream<Arguments> filesIn(String subdir, String suffix) {
55-
if (TESTS == null) {
56-
return Stream.empty();
57-
}
5858
Path dir = TESTS.resolve(subdir);
5959
if (!Files.isDirectory(dir)) {
6060
return Stream.empty();

0 commit comments

Comments
 (0)