Skip to content

Commit bb07436

Browse files
committed
possible zunit recursion fix, appit fix
1 parent 47e6d30 commit bb07436

5 files changed

Lines changed: 36 additions & 2 deletions

File tree

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ Built with pure Java 25, zb compiles and packages your project with zero externa
1616
- 📦 **Executable JAR generation** out of the box
1717
- 🎯 **One command, zero config** — sensible defaults, optional `.zb` file when you want control
1818

19+
## Speed
20+
21+
zb compiles, packages, and tests in seconds — no dependency resolution, no daemon, no warm-up:
22+
23+
| Project | Build + test | Tests |
24+
|---------|--------------|-------|
25+
| [zb](https://github.com/AdamBien/zb) (builds itself) | **1.8s** | 6 unit tests |
26+
| [zsmith](https://github.com/AdamBien/zsmith) | **2.8s** | 19 unit tests |
27+
28+
These are full builds — compile, package the executable JAR, **and** run the test suite — from a cold start.
29+
1930
## Prerequisites
2031

2132
- Java 25 or later

src/main/java/airhacks/App.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ public interface App {
2424

2525
String VERSION = "zb v" + readVersion();
2626

27-
private static String readVersion() {
27+
static String readVersion() {
2828
try (var in = App.class.getResourceAsStream("/version.txt")) {
29+
if (in == null) {
30+
return "unknown";
31+
}
2932
return new String(in.readAllBytes()).trim();
3033
} catch (IOException e) {
3134
return "unknown";

src/main/java/airhacks/zb/hook/control/PostBuildHook.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ public interface PostBuildHook {
1313

1414
String NONE = "<none>";
1515

16+
/// Suppresses the hook to break recursion. A hook like `zunit` runs the test
17+
/// suite, whose integration tests call `App.build`, which would fire the hook
18+
/// again — unbounded recursion. Set as an env var on every hook-spawned child
19+
/// (inherited by all descendants), or as a system property by in-process
20+
/// callers (tests) that must build without re-triggering the hook.
21+
String SKIP_MARKER = "ZB_IN_POST_BUILD_HOOK";
22+
23+
static boolean hookSuppressed() {
24+
return Boolean.parseBoolean(System.getenv(SKIP_MARKER)) || Boolean.getBoolean(SKIP_MARKER);
25+
}
26+
1627
static Optional<String> configuredHook() {
1728
var hook = Configuration.POST_BUILD_HOOK.get(NONE);
1829
if (NONE.equals(hook) || hook.isBlank()) {
@@ -39,6 +50,7 @@ static void execute(String command, Path sourceDir, Path jarDir, String jarFileN
3950
.inheritIO()
4051
.directory(Path.of(".").toFile());
4152
var env = processBuilder.environment();
53+
env.put(SKIP_MARKER, "true");
4254
env.put("ZB_JAR_PATH", jarDir.resolve(jarFileName).toString());
4355
env.put("ZB_SOURCE_DIR", sourceDir.toString());
4456
env.put("ZB_JAR_DIR", jarDir.toString());
@@ -59,6 +71,9 @@ static void execute(String command, Path sourceDir, Path jarDir, String jarFileN
5971
}
6072

6173
static void runIfConfigured(Path sourceDir, Path jarDir, String jarFileName) {
74+
if (hookSuppressed()) {
75+
return;
76+
}
6277
configuredHook().ifPresent(hook -> execute(hook, sourceDir, jarDir, jarFileName));
6378
}
6479
}

src/main/resources/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2026.06.26.01
1+
2026.06.26.02

src/test/java/airhacks/AppIT.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@
1010
import java.util.jar.JarFile;
1111
import java.util.jar.Manifest;
1212

13+
import airhacks.zb.hook.control.PostBuildHook;
14+
1315
public class AppIT {
1416

1517
public static void main(String... args) throws IOException {
18+
// AppIT exercises the build itself; the post-build hook (e.g. zunit) would
19+
// recursively re-run this suite and clobber the JAR under assertion.
20+
System.setProperty(PostBuildHook.SKIP_MARKER, "true");
1621
createZBJar();
1722
servicesConfigurationFileIsIncluded();
1823
temporaryClassesDirectoryIsDeleted();

0 commit comments

Comments
 (0)