From c12218cb1dc21eb906944a7d344d91829cfd1375 Mon Sep 17 00:00:00 2001 From: Bertrand Martin Date: Thu, 23 Apr 2026 21:03:04 +0200 Subject: [PATCH] Group compatibility suites by upstream package --- .../io/jawk/CompatibilityTestResources.java | 23 ++++++++++++++++--- .../io/jawk/{ => gawk}/AbstractGawkSuite.java | 8 ++++--- .../io/jawk/{ => gawk}/GawkExtensionIT.java | 7 ++++-- src/it/java/io/jawk/{ => gawk}/GawkIT.java | 7 ++++-- .../java/io/jawk/{ => gawk}/GawkLocaleIT.java | 7 ++++-- .../{ => gawk}/GawkOptionalFeatureIT.java | 7 ++++-- .../io/jawk/{ => onetrueawk}/BwkMiscIT.java | 13 +++++++---- .../java/io/jawk/{ => onetrueawk}/BwkPIT.java | 12 ++++++---- .../java/io/jawk/{ => onetrueawk}/BwkTIT.java | 12 ++++++---- .../java/io/jawk/posix/PosixIT.java} | 16 +++++++++---- src/site/markdown/compatibility.md | 12 ++++++++-- 11 files changed, 89 insertions(+), 35 deletions(-) rename src/it/java/io/jawk/{ => gawk}/AbstractGawkSuite.java (93%) rename src/it/java/io/jawk/{ => gawk}/GawkExtensionIT.java (99%) rename src/it/java/io/jawk/{ => gawk}/GawkIT.java (99%) rename src/it/java/io/jawk/{ => gawk}/GawkLocaleIT.java (97%) rename src/it/java/io/jawk/{ => gawk}/GawkOptionalFeatureIT.java (98%) rename src/it/java/io/jawk/{ => onetrueawk}/BwkMiscIT.java (89%) rename src/it/java/io/jawk/{ => onetrueawk}/BwkPIT.java (89%) rename src/it/java/io/jawk/{ => onetrueawk}/BwkTIT.java (91%) rename src/{test/java/io/jawk/AwkMan7Test.java => it/java/io/jawk/posix/PosixIT.java} (98%) diff --git a/src/it/java/io/jawk/CompatibilityTestResources.java b/src/it/java/io/jawk/CompatibilityTestResources.java index 7ad3d4cd..66ed165b 100644 --- a/src/it/java/io/jawk/CompatibilityTestResources.java +++ b/src/it/java/io/jawk/CompatibilityTestResources.java @@ -30,11 +30,18 @@ * Resolves vendored integration-test resources directly from the repository * checkout instead of relying on the Maven test classpath layout. */ -final class CompatibilityTestResources { +public final class CompatibilityTestResources { private CompatibilityTestResources() {} - static Path projectDirectory(Class anchor) { + /** + * Resolves the Maven project directory from the compiled location of an + * integration-test class. + * + * @param anchor a class loaded from the current test output + * @return the project base directory + */ + public static Path projectDirectory(Class anchor) { try { Path testClassesDirectory = Paths .get(anchor.getProtectionDomain().getCodeSource().getLocation().toURI()) @@ -54,7 +61,17 @@ static Path projectDirectory(Class anchor) { } } - static Path resourceDirectory(Class anchor, String firstSegment, String... additionalSegments) { + /** + * Resolves a vendored integration-test resource directory relative to + * {@code src/it/resources}. + * + * @param anchor a class loaded from the current test output + * @param firstSegment the first resource path segment under + * {@code src/it/resources} + * @param additionalSegments any remaining resource path segments + * @return the resolved resource directory path + */ + public static Path resourceDirectory(Class anchor, String firstSegment, String... additionalSegments) { Path resourceDirectory = projectDirectory(anchor).resolve(Paths.get("src", "it", "resources", firstSegment)); for (String segment : additionalSegments) { resourceDirectory = resourceDirectory.resolve(segment); diff --git a/src/it/java/io/jawk/AbstractGawkSuite.java b/src/it/java/io/jawk/gawk/AbstractGawkSuite.java similarity index 93% rename from src/it/java/io/jawk/AbstractGawkSuite.java rename to src/it/java/io/jawk/gawk/AbstractGawkSuite.java index 634c3910..a6a1e961 100644 --- a/src/it/java/io/jawk/AbstractGawkSuite.java +++ b/src/it/java/io/jawk/gawk/AbstractGawkSuite.java @@ -1,10 +1,10 @@ -package io.jawk; +package io.jawk.gawk; /*- * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲ * Jawk * ჻჻჻჻჻჻ - * Copyright 2006 - 2026 MetricsHub + * Copyright (C) 2006 - 2026 MetricsHub * ჻჻჻჻჻჻ * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -28,9 +28,11 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; +import io.jawk.CompatibilityTestResources; /** - * Shared helpers for the explicit gawk compatibility integration suites. + * Shared helpers for the explicit gawk compatibility integration suites + * transcribed from the vendored GNU Awk test suite. */ abstract class AbstractGawkSuite { diff --git a/src/it/java/io/jawk/GawkExtensionIT.java b/src/it/java/io/jawk/gawk/GawkExtensionIT.java similarity index 99% rename from src/it/java/io/jawk/GawkExtensionIT.java rename to src/it/java/io/jawk/gawk/GawkExtensionIT.java index cf0436b4..d851b2bb 100644 --- a/src/it/java/io/jawk/GawkExtensionIT.java +++ b/src/it/java/io/jawk/gawk/GawkExtensionIT.java @@ -1,4 +1,4 @@ -package io.jawk; +package io.jawk.gawk; /*- * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲ @@ -22,10 +22,13 @@ * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱ */ +import io.jawk.AwkTestSupport; import org.junit.Test; /** - * Extension-oriented gawk compatibility cases mirrored from the vendored extension-style gawk groups. + * Extension-oriented gawk compatibility cases mirrored from the vendored + * extension-style GNU Awk test groups. + * Upstream source: {@code git://git.savannah.gnu.org/gawk.git} */ public class GawkExtensionIT extends AbstractGawkSuite { diff --git a/src/it/java/io/jawk/GawkIT.java b/src/it/java/io/jawk/gawk/GawkIT.java similarity index 99% rename from src/it/java/io/jawk/GawkIT.java rename to src/it/java/io/jawk/gawk/GawkIT.java index f398da58..a395a7ff 100644 --- a/src/it/java/io/jawk/GawkIT.java +++ b/src/it/java/io/jawk/gawk/GawkIT.java @@ -1,4 +1,4 @@ -package io.jawk; +package io.jawk.gawk; /*- * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲ @@ -22,10 +22,13 @@ * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱ */ +import io.jawk.AwkTestSupport; import org.junit.Test; /** - * Core gawk compatibility cases mirrored from the basic and Unix test groups in the vendored gawk suite. + * Core gawk compatibility cases mirrored from the basic and Unix test groups + * in the vendored GNU Awk test suite. + * Upstream source: {@code git://git.savannah.gnu.org/gawk.git} */ public class GawkIT extends AbstractGawkSuite { diff --git a/src/it/java/io/jawk/GawkLocaleIT.java b/src/it/java/io/jawk/gawk/GawkLocaleIT.java similarity index 97% rename from src/it/java/io/jawk/GawkLocaleIT.java rename to src/it/java/io/jawk/gawk/GawkLocaleIT.java index cad7d78c..6250678d 100644 --- a/src/it/java/io/jawk/GawkLocaleIT.java +++ b/src/it/java/io/jawk/gawk/GawkLocaleIT.java @@ -1,4 +1,4 @@ -package io.jawk; +package io.jawk.gawk; /*- * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲ @@ -22,10 +22,13 @@ * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱ */ +import io.jawk.AwkTestSupport; import org.junit.Test; /** - * Locale- and charset-sensitive gawk compatibility cases mirrored from the vendored locale test groups. + * Locale- and charset-sensitive gawk compatibility cases mirrored from the + * vendored GNU Awk locale test groups. + * Upstream source: {@code git://git.savannah.gnu.org/gawk.git} */ public class GawkLocaleIT extends AbstractGawkSuite { diff --git a/src/it/java/io/jawk/GawkOptionalFeatureIT.java b/src/it/java/io/jawk/gawk/GawkOptionalFeatureIT.java similarity index 98% rename from src/it/java/io/jawk/GawkOptionalFeatureIT.java rename to src/it/java/io/jawk/gawk/GawkOptionalFeatureIT.java index 318e6514..8a001e4a 100644 --- a/src/it/java/io/jawk/GawkOptionalFeatureIT.java +++ b/src/it/java/io/jawk/gawk/GawkOptionalFeatureIT.java @@ -1,4 +1,4 @@ -package io.jawk; +package io.jawk.gawk; /*- * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲ @@ -22,10 +22,13 @@ * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱ */ +import io.jawk.AwkTestSupport; import org.junit.Test; /** - * Optional-feature and environment-specific gawk compatibility cases mirrored from the vendored optional gawk groups. + * Optional-feature and environment-specific gawk compatibility cases mirrored + * from the vendored GNU Awk optional test groups. + * Upstream source: {@code git://git.savannah.gnu.org/gawk.git} */ public class GawkOptionalFeatureIT extends AbstractGawkSuite { diff --git a/src/it/java/io/jawk/BwkMiscIT.java b/src/it/java/io/jawk/onetrueawk/BwkMiscIT.java similarity index 89% rename from src/it/java/io/jawk/BwkMiscIT.java rename to src/it/java/io/jawk/onetrueawk/BwkMiscIT.java index 96bdca8a..7fac9099 100644 --- a/src/it/java/io/jawk/BwkMiscIT.java +++ b/src/it/java/io/jawk/onetrueawk/BwkMiscIT.java @@ -1,4 +1,4 @@ -package io.jawk; +package io.jawk.onetrueawk; /*- * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲ @@ -27,6 +27,8 @@ import java.nio.file.Path; import java.util.Arrays; import java.util.stream.Collectors; +import io.jawk.AwkTestSupport; +import io.jawk.CompatibilityTestResources; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -36,11 +38,12 @@ import org.junit.runners.Parameterized.Parameters; /** - * Integration suite based on BWK miscellaneous compatibility tests. Each AWK - * script in the BWK compatibility resources executes against its corresponding - * input file and its output is compared with the recorded result. + * Integration suite based on the BWK miscellaneous compatibility tests vendored + * from the One True Awk upstream repository. Each AWK script executes against + * its corresponding input file and its output is compared with the recorded + * result. * - * @see One True Awk + * @see BWK / One True Awk upstream repository */ @RunWith(Parameterized.class) public class BwkMiscIT { diff --git a/src/it/java/io/jawk/BwkPIT.java b/src/it/java/io/jawk/onetrueawk/BwkPIT.java similarity index 89% rename from src/it/java/io/jawk/BwkPIT.java rename to src/it/java/io/jawk/onetrueawk/BwkPIT.java index 543308ed..1914c99f 100644 --- a/src/it/java/io/jawk/BwkPIT.java +++ b/src/it/java/io/jawk/onetrueawk/BwkPIT.java @@ -1,4 +1,4 @@ -package io.jawk; +package io.jawk.onetrueawk; /*- * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲ @@ -27,6 +27,8 @@ import java.nio.file.Path; import java.util.Arrays; import java.util.stream.Collectors; +import io.jawk.AwkTestSupport; +import io.jawk.CompatibilityTestResources; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -36,11 +38,11 @@ import org.junit.runners.Parameterized.Parameters; /** - * Integration suite based on BWK pattern tests. Each AWK script in the BWK - * compatibility resources executes against the shared BWK input file and its - * output is compared with the recorded result. + * Integration suite based on the BWK pattern tests vendored from the One True + * Awk upstream repository. Each AWK script executes against the shared BWK + * input file and its output is compared with the recorded result. * - * @see One True Awk + * @see BWK / One True Awk upstream repository */ @RunWith(Parameterized.class) public class BwkPIT { diff --git a/src/it/java/io/jawk/BwkTIT.java b/src/it/java/io/jawk/onetrueawk/BwkTIT.java similarity index 91% rename from src/it/java/io/jawk/BwkTIT.java rename to src/it/java/io/jawk/onetrueawk/BwkTIT.java index 04510b4d..51da2868 100644 --- a/src/it/java/io/jawk/BwkTIT.java +++ b/src/it/java/io/jawk/onetrueawk/BwkTIT.java @@ -1,4 +1,4 @@ -package io.jawk; +package io.jawk.onetrueawk; /*- * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲ @@ -29,6 +29,8 @@ import java.nio.file.Path; import java.util.Arrays; import java.util.stream.Collectors; +import io.jawk.AwkTestSupport; +import io.jawk.CompatibilityTestResources; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -38,11 +40,11 @@ import org.junit.runners.Parameterized.Parameters; /** - * Integration suite based on BWK text-processing tests. Each AWK script in the - * BWK compatibility resources executes against the shared BWK input file and - * its output is compared with the recorded result. + * Integration suite based on the BWK text-processing tests vendored from the + * One True Awk upstream repository. Each AWK script executes against the shared + * BWK input file and its output is compared with the recorded result. * - * @see One True Awk + * @see BWK / One True Awk upstream repository */ @RunWith(Parameterized.class) public class BwkTIT { diff --git a/src/test/java/io/jawk/AwkMan7Test.java b/src/it/java/io/jawk/posix/PosixIT.java similarity index 98% rename from src/test/java/io/jawk/AwkMan7Test.java rename to src/it/java/io/jawk/posix/PosixIT.java index f7c63e65..29675f15 100644 --- a/src/test/java/io/jawk/AwkMan7Test.java +++ b/src/it/java/io/jawk/posix/PosixIT.java @@ -1,4 +1,4 @@ -package io.jawk; +package io.jawk.posix; /*- * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲ @@ -22,12 +22,20 @@ * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱ */ +import io.jawk.AwkTestSupport; import java.util.Locale; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -public class AwkMan7Test { +/** + * Integration suite for POSIX AWK behavior, expressed as explicit Jawk tests + * derived from the POSIX awk utility specification. + * + * @see POSIX awk utility + * specification + */ +public class PosixIT { private static Locale defaultLocale; @@ -952,8 +960,8 @@ public void spec91RangeResetsPerFile() throws Exception { public void spec92EnvironExposesEnvironmentVariable() throws Exception { AwkTestSupport .awkTest("92. ENVIRON exposes environment variable") - .script("BEGIN{print ENVIRON[\"AWK_TEST\"]}") - .expectLines(System.getenv().getOrDefault("AWK_TEST", "")) + .script("BEGIN{print ENVIRON[\"PATH\"]}") + .expectLines(System.getenv().getOrDefault("PATH", "")) .runAndAssert(); } diff --git a/src/site/markdown/compatibility.md b/src/site/markdown/compatibility.md index 191621a0..e75d478c 100644 --- a/src/site/markdown/compatibility.md +++ b/src/site/markdown/compatibility.md @@ -32,7 +32,7 @@ This maintained fork diverges from the original project in several practical way - Jawk supports long integers - Jawk supports octal and hexadecimal notation in strings - the Maven coordinates are `io.jawk:jawk` and the package root is `io.jawk` -- gawk and bwk compatibility test suites have been added +- BWK, POSIX, and gawk compatibility test suites have been added - the Maven artifact is published under the LGPL - operator precedence is fixed and follows POSIX specifications @@ -74,10 +74,17 @@ Jawk tuples are reusable, but they should be treated as internal artifacts tied ## Compatibility Test Suites -Jawk maintains compatibility tests derived from the BWK (One True AWK) and gawk test suites. These run automatically as integration tests during `mvn verify`. +Jawk maintains compatibility tests derived from: + +- BWK / One True Awk: +- POSIX awk utility specification: +- GNU Awk: `git://git.savannah.gnu.org/gawk.git` + +These run automatically as integration tests during `mvn verify`. Compatibility suites now live under `src/it/java`, with their vendored inputs under `src/it/resources`. The compatibility suites read those vendored files directly from the repository checkout instead of relying on the Maven test classpath layout. +They are also grouped by upstream family in separate Java packages so the Failsafe reports aggregate BWK, POSIX, and gawk results independently. The gawk coverage is split into a small set of explicit Java integration suites built on `AwkTestSupport`, following the broad test families declared in gawk's vendored `Makefile.am`. The vendored gawk files remain in the repository to make future refreshes and diffs straightforward, but the runtime source of truth is the Java test code. | Suite | Coverage | @@ -85,6 +92,7 @@ The gawk coverage is split into a small set of explicit Java integration suites | **BwkPIT** | Pattern matching and basic AWK operations from the BWK test collection | | **BwkTIT** | Text processing, field splitting, built-in functions, and output formatting | | **BwkMiscIT** | Miscellaneous BWK compatibility edge cases | +| **PosixIT** | Explicit POSIX AWK specification behaviors transcribed into integration tests | | **GawkIT** | Core gawk compatibility mirrored from the vendored basic and Unix test groups | | **GawkExtensionIT** | gawk extension-oriented compatibility mirrored from the vendored extension-style test groups | | **GawkLocaleIT** | Locale- and charset-sensitive gawk compatibility mirrored from the vendored locale test groups |