Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions src/it/java/io/jawk/CompatibilityTestResources.java
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.jawk;
package io.jawk.gawk;

/*-
* ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
Expand All @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.jawk;
package io.jawk.gawk;

/*-
* ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
Expand All @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.jawk;
package io.jawk.gawk;

/*-
* ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
Expand All @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.jawk;
package io.jawk.gawk;

/*-
* ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
Expand All @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.jawk;
package io.jawk.onetrueawk;

/*-
* ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
Expand Down Expand Up @@ -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;
Expand All @@ -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 <a href="https://github.com/onetrueawk/awk">One True Awk</a>
* @see <a href="https://github.com/onetrueawk/awk">BWK / One True Awk upstream repository</a>
*/
@RunWith(Parameterized.class)
public class BwkMiscIT {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.jawk;
package io.jawk.onetrueawk;

/*-
* ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
Expand Down Expand Up @@ -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;
Expand All @@ -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 <a href="https://github.com/onetrueawk/awk">One True Awk</a>
* @see <a href="https://github.com/onetrueawk/awk">BWK / One True Awk upstream repository</a>
*/
@RunWith(Parameterized.class)
public class BwkPIT {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.jawk;
package io.jawk.onetrueawk;

/*-
* ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
Expand Down Expand Up @@ -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;
Expand All @@ -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 <a href="https://github.com/onetrueawk/awk">One True Awk</a>
* @see <a href="https://github.com/onetrueawk/awk">BWK / One True Awk upstream repository</a>
*/
@RunWith(Parameterized.class)
public class BwkTIT {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.jawk;
package io.jawk.posix;

/*-
* ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
Expand All @@ -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 <a href="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html">POSIX awk utility
* specification</a>
*/
public class PosixIT {

private static Locale defaultLocale;

Expand Down Expand Up @@ -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();
}

Expand Down
12 changes: 10 additions & 2 deletions src/site/markdown/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -74,17 +74,25 @@ 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: <https://github.com/onetrueawk/awk>
- POSIX awk utility specification: <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html>
- 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 |
| --- | --- |
| **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 |
Expand Down
Loading