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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ run/
.idea/
*.iml
.DS_Store
test/live/node_modules/
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ You don't need Preflight installed on the server to use it. Some details:

[docs/upgrade.md](docs/upgrade.md) has every command and option.

## Testing

Unit tests run with `./gradlew build`. The live scenarios in `test/live/run.mjs` boot throwaway Paper servers on 127.0.0.1 with two test-only plugins and a bot that only logs in: a clean run, logins held during the tests, a lockdown and `/preflight unlock`, `DISABLE_PLUGIN`, and `SHUTDOWN`. Instructions are at the top of that file.

## Limitations

- **No simulated players.** The Bukkit API can't create one, so join, chat, and player-action flows aren't covered.
Expand Down
12 changes: 12 additions & 0 deletions docs/test-audit.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

Kept by this repo's owning session (Minecraft: Plugins Lead), per `~/Code/CLAUDE.md`, "Test self-audits". Newest first.

## 2026-11-10: the live scenarios, in the repo

The first audit's main gap is closed. `test/live/run.mjs` runs the five scenarios on throwaway Paper servers, one at a time, with two test-only plugins (`test/live/fixture`, old-style `plugin.yml` with `softdepend`; `test/live/dependent`, `paper-plugin.yml` requiring the first) and a mineflayer bot for logins. 17/17 on Paper 26.1.2:

- **Clean run:** the server stops itself, the report has no failures and replaces a stale one, the example plugin's tests ran, the test world is deleted.
- **Logins held:** while a slow test runs, the old report is already gone and a login is refused with the reason; once the tests pass, the same login works.
- **Lockdown:** a plugin that throws in `onEnable` locks the server; logins are refused with the reason; the report names the plugin; `/preflight unlock` lets logins in.
- **Disable plugin:** the plugin that needs the failing one, declared in `paper-plugin.yml`, is disabled first and really stops; with no server-level failure, logins are open. This closes the other gap.
- **Shutdown:** a critical failure stops the server, and the report records it.

Not run on 26.2 or 26.3 this time; the harness takes `PF_TEST_PAPER` and adds ViaVersion and ViaBackwards for them.

## 2026-11-10: first full audit (at 0.3.0)

What Preflight promises (README, `docs/upgrade.md`, `docs/decisions.md`), and what proves it. Unit tests are in `preflight-plugin/src/test` and `preflight-upgrade/src/test`. The live scenarios are in `docs/26x-audit.md`: five, run by hand on throwaway Paper 26.1.2, 26.2 and 26.3 servers.
Expand Down
5 changes: 5 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
rootProject.name = "Preflight"

include("preflight-api", "preflight-plugin", "preflight-example", "preflight-upgrade")

// Test-only plugins for the live scenarios in test/live. Never released.
include("livetest-fixture", "livetest-dependent")
project(":livetest-fixture").projectDir = file("test/live/fixture")
project(":livetest-dependent").projectDir = file("test/live/dependent")
1 change: 1 addition & 0 deletions test/live/dependent/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tasks.named<Jar>("jar") { archiveBaseName.set("PfDependent") }
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.extantape.preflight.livetest;

import org.bukkit.plugin.java.JavaPlugin;

/** Test-only: needs PfFixture, declared in paper-plugin.yml, so DISABLE_PLUGIN must switch it off first. */
public final class DependentPlugin extends JavaPlugin {
@Override public void onEnable() { getLogger().info("PfDependent enabled"); }
@Override public void onDisable() { getLogger().info("PfDependent disabled"); }
}
10 changes: 10 additions & 0 deletions test/live/dependent/src/main/resources/paper-plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: PfDependent
version: '${version}'
main: com.extantape.preflight.livetest.DependentPlugin
api-version: '26.1'
description: Test-only fixture for Preflight's live scenarios. Never install it on a real server.
dependencies:
server:
PfFixture:
load: BEFORE
required: true
2 changes: 2 additions & 0 deletions test/live/fixture/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies { "compileOnly"(project(":preflight-api")) }
tasks.named<Jar>("jar") { archiveBaseName.set("PfFixture") }
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.extantape.preflight.livetest;

import com.extantape.preflight.api.Check;
import com.extantape.preflight.api.PreflightRegistry;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

import java.nio.file.Files;
import java.nio.file.Path;

/**
* Test-only plugin for Preflight's live scenarios. Never install it on a real server. What it does comes from
* plugins/PfFixture/mode.txt: "pass" (a test that passes), "fail" (a critical test that fails), "slow" (a test that
* passes after 10 seconds, to hold logins) or "throw" (onEnable throws, so the plugin never enables).
* It uses an old-style plugin.yml with softdepend, the way older plugins add tests.
*/
public final class FixturePlugin extends JavaPlugin {
@Override
public void onEnable() {
String mode = "pass";
try {
Path f = getDataFolder().toPath().resolve("mode.txt");
if (Files.exists(f)) mode = Files.readString(f).trim();
} catch (Exception e) {
getLogger().warning("Couldn't read mode.txt: " + e);
}
getLogger().info("PfFixture mode " + mode);
if (mode.equals("throw")) throw new IllegalStateException("PfFixture was told to fail on enable");
if (Bukkit.getPluginManager().getPlugin("Preflight") == null) return;
Tests.register(this, mode);
}

/** Every reference to Preflight's API stays in here, so the plugin loads without it. */
static final class Tests {
static void register(JavaPlugin plugin, String mode) {
PreflightRegistry registry = Bukkit.getServicesManager().load(PreflightRegistry.class);
switch (mode) {
case "fail" -> registry.register(plugin, "always-fails", context -> Check.that(false, "PfFixture fails on purpose"));
case "slow" -> registry.register(plugin, "slow", com.extantape.preflight.api.Severity.CRITICAL, 400,
context -> context.later(200, () -> {}));
default -> registry.register(plugin, "passes", context -> Check.that(true, "never shown"));
}
}
}
}
6 changes: 6 additions & 0 deletions test/live/fixture/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: PfFixture
version: '0.0.0-test'
main: com.extantape.preflight.livetest.FixturePlugin
api-version: '26.1'
softdepend: [Preflight]
description: Test-only fixture for Preflight's live scenarios. Never install it on a real server.
Loading
Loading