Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5aac40da5d | |||
| 5322d0dd5c | |||
| 6a9dfac1ac | |||
| 51bfd34d74 | |||
| 485dc07288 | |||
| 52b0c53846 | |||
| 736ca0c4c2 | |||
| 6366a44bc4 | |||
| d282666d6e | |||
| bd199a7dc1 | |||
| c9b773f79b | |||
| f1bbd46cbd | |||
| bd73930584 | |||
| 0db3a8ac73 | |||
| 6ab40a1e6a | |||
| 04bab67778 |
@@ -377,19 +377,19 @@ compose_rust() {
|
|||||||
[ "$link_protocol" = "$plugin_protocol" ] || fail \
|
[ "$link_protocol" = "$plugin_protocol" ] || fail \
|
||||||
"PROTOCOL MISMATCH — Rust-Link ${link_tag} speaks ${link_protocol}, Rust-Plugins ${plugin_tag} declares ${plugin_protocol}. The game link has no 409: a mismatched plugin would mis-parse. Fix: land the matching half and let its release cut, or bump Rust-Plugins/overlay.toml."
|
"PROTOCOL MISMATCH — Rust-Link ${link_tag} speaks ${link_protocol}, Rust-Plugins ${plugin_tag} declares ${plugin_protocol}. The game link has no 409: a mismatched plugin would mis-parse. Fix: land the matching half and let its release cut, or bump Rust-Plugins/overlay.toml."
|
||||||
|
|
||||||
# RunicNPC (docs/runicnpc/PLAN.md D224): a third file, optional until its stage 9.
|
# RunicNPC (docs/runicnpc/PLAN.md D224): a third file, REQUIRED since its stage 9
|
||||||
# The bridge's manifest says which RunicNPC API its npc.* commands need
|
# (D310) — the bridge refuses every NPC an event places without it, and the
|
||||||
# (`runicnpc_api`, from overlay.toml); the latest RunicNPC release is carried
|
# installer refuses a Rust bundle that does not carry it. The bridge's manifest
|
||||||
# only when it answers at least that. A bridge that needs none carries none: a
|
# says which RunicNPC API it needs (`runicnpc_api`, from overlay.toml); the
|
||||||
# RunicNPC it cannot talk to would be an NPC plugin nobody manages.
|
# latest RunicNPC release is carried only when it answers at least that. With
|
||||||
local npc='null' need npc_tag npc_tarball npc_manifest npc_api npc_carried=''
|
# none that does, the Rust bundle is not composed: the published one stays.
|
||||||
|
local npc need npc_tag npc_tarball npc_manifest npc_api
|
||||||
need="$(jq -r '.runicnpc_api // 0' "$manifest")"
|
need="$(jq -r '.runicnpc_api // 0' "$manifest")"
|
||||||
if [ "$need" -gt 0 ]; then
|
[ "$need" -gt 0 ] || fail \
|
||||||
|
"Rust-Plugins ${plugin_tag} declares no runicnpc_api, and RunicNPC is required (D310) — a bridge older than RunicNPC's stage 4 cannot be bundled any more."
|
||||||
rc=0
|
rc=0
|
||||||
resolve_latest "$RUNICNPC_REPO" runicnpc || rc=$?
|
resolve_latest "$RUNICNPC_REPO" runicnpc || rc=$?
|
||||||
if [ "$rc" -eq 2 ]; then
|
[ "$rc" -ne 2 ] || fail "the bridge needs RunicNPC API ${need}, and RunicNPC has not released — RunicNPC is required (D310)."
|
||||||
note "- **Rust**: the bridge needs RunicNPC API ${need}, and RunicNPC has not released yet — the bundle carries none."
|
|
||||||
else
|
|
||||||
npc_tag="$(release_tag runicnpc)"
|
npc_tag="$(release_tag runicnpc)"
|
||||||
verify_assets runicnpc
|
verify_assets runicnpc
|
||||||
npc_tarball="$(single_tarball runicnpc)"
|
npc_tarball="$(single_tarball runicnpc)"
|
||||||
@@ -398,9 +398,8 @@ compose_rust() {
|
|||||||
|| fail "the RunicNPC tarball has no ${RUNICNPC_PREFIX}/RunicNPC.cs"
|
|| fail "the RunicNPC tarball has no ${RUNICNPC_PREFIX}/RunicNPC.cs"
|
||||||
npc_api="$(jq -r '.api' "$npc_manifest")"
|
npc_api="$(jq -r '.api' "$npc_manifest")"
|
||||||
echo "==> rust: RunicNPC ${npc_tag} api=${npc_api} | the bridge needs ${need}"
|
echo "==> rust: RunicNPC ${npc_tag} api=${npc_api} | the bridge needs ${need}"
|
||||||
if [ "$npc_api" -lt "$need" ]; then
|
[ "$npc_api" -ge "$need" ] || fail \
|
||||||
note "- **Rust**: RunicNPC \`${npc_tag}\` answers API ${npc_api} and the bridge needs ${need} — the bundle carries none until RunicNPC releases one that does."
|
"RunicNPC ${npc_tag} answers API ${npc_api} and Rust-Plugins ${plugin_tag} needs ${need} — RunicNPC is required (D310), so no Rust bundle is composed until it releases one that does."
|
||||||
else
|
|
||||||
npc="$(jq -n --arg repo "$RUNICNPC_REPO" --arg tag "$npc_tag" --slurpfile m "$npc_manifest" \
|
npc="$(jq -n --arg repo "$RUNICNPC_REPO" --arg tag "$npc_tag" --slurpfile m "$npc_manifest" \
|
||||||
--argjson asset "$(asset_json runicnpc "$npc_tarball")" \
|
--argjson asset "$(asset_json runicnpc "$npc_tarball")" \
|
||||||
'{ repo: $repo, tag: $tag, version: ($tag | ltrimstr("v")), commit: $m[0].commit, api: $m[0].api,
|
'{ repo: $repo, tag: $tag, version: ($tag | ltrimstr("v")), commit: $m[0].commit, api: $m[0].api,
|
||||||
@@ -411,10 +410,6 @@ compose_rust() {
|
|||||||
jq -e '([.commit, .compat.frameworks[].min_version] | all(type == "string"))
|
jq -e '([.commit, .compat.frameworks[].min_version] | all(type == "string"))
|
||||||
and (.api | type == "number") and (.compat.requires_plugins | type == "array")' <<<"$npc" >/dev/null \
|
and (.api | type == "number") and (.compat.requires_plugins | type == "array")' <<<"$npc" >/dev/null \
|
||||||
|| fail "the RunicNPC manifest is missing commit, api, a framework floor, or requires_plugins"
|
|| fail "the RunicNPC manifest is missing commit, api, a framework floor, or requires_plugins"
|
||||||
npc_carried="$npc_tag"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
jq -n \
|
jq -n \
|
||||||
--arg link_repo "$RUST_LINK_REPO" --arg link_tag "$link_tag" \
|
--arg link_repo "$RUST_LINK_REPO" --arg link_tag "$link_tag" \
|
||||||
@@ -432,8 +427,8 @@ compose_rust() {
|
|||||||
compat: { frameworks: { oxide: { min_version: $m[0].min_oxide_version },
|
compat: { frameworks: { oxide: { min_version: $m[0].min_oxide_version },
|
||||||
carbon: { min_version: $m[0].min_carbon_version } },
|
carbon: { min_version: $m[0].min_carbon_version } },
|
||||||
requires_plugins: $m[0].requires_plugins },
|
requires_plugins: $m[0].requires_plugins },
|
||||||
asset: $p_asset } }
|
asset: $p_asset },
|
||||||
+ (if $npc == null then {} else { npc: $npc } end)' > "$WORK/rust-s2.json"
|
npc: $npc }' > "$WORK/rust-s2.json"
|
||||||
# A manifest missing a key would compose a `null` the installer then trusts.
|
# A manifest missing a key would compose a `null` the installer then trusts.
|
||||||
jq -e '([.payload.compat.frameworks[].min_version, .payload.commit] | all(type == "string"))
|
jq -e '([.payload.compat.frameworks[].min_version, .payload.commit] | all(type == "string"))
|
||||||
and (.payload.compat.requires_plugins | type == "array")' "$WORK/rust-s2.json" >/dev/null \
|
and (.payload.compat.requires_plugins | type == "array")' "$WORK/rust-s2.json" >/dev/null \
|
||||||
@@ -446,7 +441,7 @@ compose_rust() {
|
|||||||
local tag
|
local tag
|
||||||
tag="$(fresh_tag "$PUBLISHED/v2/rust")"
|
tag="$(fresh_tag "$PUBLISHED/v2/rust")"
|
||||||
publish_doc "$PUBLISHED/v2/rust" "$tag" "$WORK/rust-s2.json"
|
publish_doc "$PUBLISHED/v2/rust" "$tag" "$WORK/rust-s2.json"
|
||||||
note "- **Rust**: published \`${tag}\` — Rust-Link \`${link_tag}\`, Rust-Plugins \`${plugin_tag}\`, protocol ${link_protocol}${npc_carried:+, RunicNPC \`${npc_tag}\`}."
|
note "- **Rust**: published \`${tag}\` — Rust-Link \`${link_tag}\`, Rust-Plugins \`${plugin_tag}\`, protocol ${link_protocol}, RunicNPC \`${npc_tag}\`."
|
||||||
echo "rust ${tag}" >> "$WORK/published-games.txt"
|
echo "rust ${tag}" >> "$WORK/published-games.txt"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
# current.json, bundle-<tag>.json schema 1, ServUO: link + overlay
|
# current.json, bundle-<tag>.json schema 1, ServUO: link + overlay
|
||||||
# v2/servuo/current.json, bundle-<tag>.json schema 2, game "servuo"
|
# v2/servuo/current.json, bundle-<tag>.json schema 2, game "servuo"
|
||||||
# v2/rust/current.json, bundle-<tag>.json schema 2, game "rust": Rust-Link + Rust-Plugins,
|
# v2/rust/current.json, bundle-<tag>.json schema 2, game "rust": Rust-Link + Rust-Plugins,
|
||||||
# and RunicNPC when the bridge needs it (D224)
|
# and RunicNPC, required since its stage 9 (D224, D310)
|
||||||
#
|
#
|
||||||
# Schema 2 (D146) names ONE game, with a `game` discriminant and a `payload`
|
# Schema 2 (D146) names ONE game, with a `game` discriminant and a `payload`
|
||||||
# that is an overlay for ServUO and a plugin for Rust. Schema 1 (D147) is still
|
# that is an overlay for ServUO and a plugin for Rust. Schema 1 (D147) is still
|
||||||
|
|||||||
@@ -89,19 +89,16 @@ jobs:
|
|||||||
rustup component add rustfmt clippy
|
rustup component add rustfmt clippy
|
||||||
cargo --version && cargo fmt --version && cargo clippy --version
|
cargo --version && cargo fmt --version && cargo clippy --version
|
||||||
|
|
||||||
# Keyed on Cargo.lock: dependency builds are reused until a dep actually
|
# Dependency builds are reused until a dep actually changes; a cache miss
|
||||||
# changes. A cache miss only makes the run slower, never wrong.
|
# only makes the run slower, never wrong. rust-cache rather than a plain
|
||||||
- name: Cache cargo registry and build dir
|
# actions/cache of target/: it strips this crate's own artifacts and
|
||||||
|
# anything stale before saving, and saves only on a miss. The plain cache
|
||||||
|
# restored the previous target/ and re-saved all of it under every new
|
||||||
|
# Cargo.lock, so each entry carried every older build and the runner's
|
||||||
|
# cache grew without bound.
|
||||||
|
- name: Cache cargo registry and dependency builds
|
||||||
if: ${{ steps.detect.outputs.crate == 'true' }}
|
if: ${{ steps.detect.outputs.crate == 'true' }}
|
||||||
uses: actions/cache@v4
|
uses: Swatinem/rust-cache@v2
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.cargo/registry
|
|
||||||
~/.cargo/git
|
|
||||||
target
|
|
||||||
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-cargo-
|
|
||||||
|
|
||||||
# Cheapest gate first — parses only, no compile, so a formatting slip
|
# Cheapest gate first — parses only, no compile, so a formatting slip
|
||||||
# fails in seconds instead of after a full build.
|
# fails in seconds instead of after a full build.
|
||||||
|
|||||||
@@ -362,8 +362,9 @@ pub struct RustBundle {
|
|||||||
pub sidecar: RustSidecar,
|
pub sidecar: RustSidecar,
|
||||||
pub payload: PluginPayload,
|
pub payload: PluginPayload,
|
||||||
/// RunicNPC, Runic Gateway's NPC plugin (docs/runicnpc/PLAN.md D224): a third file placed in
|
/// RunicNPC, Runic Gateway's NPC plugin (docs/runicnpc/PLAN.md D224): a third file placed in
|
||||||
/// the plugins directory beside the bridge. Optional until RunicNPC's stage 9 makes it
|
/// the plugins directory beside the bridge. Required since RunicNPC's stage 9 (D310): a bundle
|
||||||
/// required, so a bundle without it — every one before stage 4 — still parses and installs.
|
/// without it — every one before stage 4 — still PARSES, so `doctor` and an old pin can name
|
||||||
|
/// it, but `install` and `update` refuse it.
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
pub npc: Option<NpcComponent>,
|
pub npc: Option<NpcComponent>,
|
||||||
}
|
}
|
||||||
|
|||||||
13
src/cli.rs
13
src/cli.rs
@@ -56,7 +56,7 @@ pub enum PatchChoice {
|
|||||||
No,
|
No,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Which game's shard side this run is about (docs/modules/rust/PLAN.md §34.2.3). ServUO is the
|
/// Which game this run sets up (docs/modules/rust/PLAN.md §34.2.3). ServUO is the
|
||||||
/// default, so every command line written before Rust existed means exactly what it meant.
|
/// default, so every command line written before Rust existed means exactly what it meant.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum Game {
|
pub enum Game {
|
||||||
@@ -94,7 +94,8 @@ pub struct Cli {
|
|||||||
pub patches_unsupported_servuo: bool,
|
pub patches_unsupported_servuo: bool,
|
||||||
/// `--host <name>`: the hostname to print in the website URLs.
|
/// `--host <name>`: the hostname to print in the website URLs.
|
||||||
pub host: Option<String>,
|
pub host: Option<String>,
|
||||||
/// `--site-url <url>`: the site's base URL, for the Admin → Shard (uo-link) link.
|
/// `--site-url <url>`: the site's base URL, printed as a link to the admin page that takes
|
||||||
|
/// the values.
|
||||||
pub site_url: Option<String>,
|
pub site_url: Option<String>,
|
||||||
/// `--yes`: assume the default answer to every prompt.
|
/// `--yes`: assume the default answer to every prompt.
|
||||||
pub assume_yes: bool,
|
pub assume_yes: bool,
|
||||||
@@ -128,7 +129,7 @@ impl Default for Cli {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub const USAGE: &str = "\
|
pub const USAGE: &str = "\
|
||||||
Runic Gateway installer — connects a ServUO shard, or Rust servers, to a Runic
|
Runic Gateway installer — connects a ServUO server, or Rust servers, to a Runic
|
||||||
Gateway website.
|
Gateway website.
|
||||||
|
|
||||||
Usage: runicgateway-installer <COMMAND> [OPTIONS]
|
Usage: runicgateway-installer <COMMAND> [OPTIONS]
|
||||||
@@ -144,7 +145,7 @@ Commands:
|
|||||||
removes only its own plugin file and keeps the plugin config.
|
removes only its own plugin file and keeps the plugin config.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--game <servuo|rust> Which game's shard side. Default servuo.
|
--game <servuo|rust> Which game this run sets up. Default servuo.
|
||||||
--verify install, update. Dry run: report every
|
--verify install, update. Dry run: report every
|
||||||
change that would be made, write nothing.
|
change that would be made, write nothing.
|
||||||
--servuo <PATH> install, doctor, update. The ServUO root,
|
--servuo <PATH> install, doctor, update. The ServUO root,
|
||||||
@@ -161,7 +162,7 @@ Options:
|
|||||||
--host <NAME> install. The hostname to print in the
|
--host <NAME> install. The hostname to print in the
|
||||||
website URLs.
|
website URLs.
|
||||||
--site-url <URL> install. Your site's base URL, for the
|
--site-url <URL> install. Your site's base URL, for the
|
||||||
Admin → Shard (uo-link) link.
|
admin page link it prints at the end.
|
||||||
--yes Assume the default answer to every prompt.
|
--yes Assume the default answer to every prompt.
|
||||||
On uninstall it means yes: that prompt
|
On uninstall it means yes: that prompt
|
||||||
defaults to no, and typing `uninstall
|
defaults to no, and typing `uninstall
|
||||||
@@ -194,7 +195,7 @@ Environment:
|
|||||||
set it.
|
set it.
|
||||||
|
|
||||||
The installer never contacts your website, never deletes anything from your
|
The installer never contacts your website, never deletes anything from your
|
||||||
ServUO tree, and never starts or stops your shard.
|
ServUO tree, and never starts or stops your game server.
|
||||||
";
|
";
|
||||||
|
|
||||||
/// Parses arguments **without** the program name.
|
/// Parses arguments **without** the program name.
|
||||||
|
|||||||
@@ -651,7 +651,12 @@ fn protocol_row(
|
|||||||
/// than a `✗`: reporting a stopped shard as a failure would train operators to ignore this line,
|
/// than a `✗`: reporting a stopped shard as a failure would train operators to ignore this line,
|
||||||
/// which is the one line worth reading.
|
/// which is the one line worth reading.
|
||||||
fn shard_row(root: Result<&ServUoRoot, &anyhow::Error>, health: Option<&Health>) -> Row {
|
fn shard_row(root: Result<&ServUoRoot, &anyhow::Error>, health: Option<&Health>) -> Row {
|
||||||
let running = root.ok().and_then(|r| servuo::find_running(&r.path));
|
// Only a certain match: an unreadable-cwd process may be a different shard, and "running but
|
||||||
|
// has not dialed in" about the wrong shard would send the operator after the wrong problem.
|
||||||
|
let running = root
|
||||||
|
.ok()
|
||||||
|
.and_then(|r| servuo::find_running(&r.path))
|
||||||
|
.filter(|s| s.certain);
|
||||||
|
|
||||||
match (health.and_then(|h| h.plugin_connected), running) {
|
match (health.and_then(|h| h.plugin_connected), running) {
|
||||||
(Some(true), _) => {
|
(Some(true), _) => {
|
||||||
|
|||||||
@@ -178,9 +178,10 @@ fn instance_rows(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── RunicNPC: ours when the bundle carried it (D224) ──────────────────────
|
// ── RunicNPC: ours, and required (D224, D310) ─────────────────────────────
|
||||||
// A warning, like a helper's: until RunicNPC's stage 9 the bridge runs without it, and what is
|
// A failure when it is missing or was never placed: since RunicNPC's stage 9 the bridge
|
||||||
// lost is the site's NPC profiles and placements and events' profile NPCs.
|
// refuses every NPC an event places without it. A file edited by hand still loads, so that
|
||||||
|
// stays a warning, as the bridge's own helpers are.
|
||||||
if let Some(file) = &instance.npc {
|
if let Some(file) = &instance.npc {
|
||||||
let tag = record.npc.as_ref().map(|n| n.tag.as_str()).unwrap_or("?");
|
let tag = record.npc.as_ref().map(|n| n.tag.as_str()).unwrap_or("?");
|
||||||
match std::fs::read(&file.path) {
|
match std::fs::read(&file.path) {
|
||||||
@@ -192,11 +193,17 @@ fn instance_rows(
|
|||||||
.note("edited or replaced by hand; `update --game rust` puts the released one back"),
|
.note("edited or replaced by hand; `update --game rust` puts the released one back"),
|
||||||
),
|
),
|
||||||
Err(_) => rows.push(
|
Err(_) => rows.push(
|
||||||
Row::warn(&label("RunicNPC"), format!("{} is missing", file.path))
|
Row::fail(&label("RunicNPC"), format!("{} is missing", file.path))
|
||||||
.note("without it the site's NPC profiles and placements, and events' profile NPCs, are off")
|
.note("RunicNPC is required: without it every NPC an event places is refused, Rust's own scientists included")
|
||||||
.note("`update --game rust` puts it back"),
|
.note("`update --game rust` puts it back"),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
rows.push(
|
||||||
|
Row::fail(&label("RunicNPC"), "not installed")
|
||||||
|
.note("RunicNPC is required: without it every NPC an event places is refused, Rust's own scientists included")
|
||||||
|
.note("`update --game rust` installs it from the current bundle"),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── The plugin's config: the website's ───────────────────────────────────
|
// ── The plugin's config: the website's ───────────────────────────────────
|
||||||
@@ -340,6 +347,11 @@ fn helper_absence(name: &str) -> String {
|
|||||||
an event zone, because ZoneDomes cannot be called without it"
|
an event zone, because ZoneDomes cannot be called without it"
|
||||||
.to_string()
|
.to_string()
|
||||||
}
|
}
|
||||||
|
"RunicGatewayRaids.cs" => {
|
||||||
|
"the bridge still runs and still reports raid bases, but an event's RaidableBases base \
|
||||||
|
is not the event's: it cannot be placed, set or locked, and despawns on its own timer"
|
||||||
|
.to_string()
|
||||||
|
}
|
||||||
_ => format!("the bridge still runs without {name}; what it helped with falls back"),
|
_ => format!("the bridge still runs without {name}; what it helped with falls back"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ use anyhow::{bail, Context, Result};
|
|||||||
|
|
||||||
use super::npc;
|
use super::npc;
|
||||||
use super::plugin::{self, ConfigView};
|
use super::plugin::{self, ConfigView};
|
||||||
|
use super::popup;
|
||||||
use super::record::{ComponentRecord, DeployedFile, Instance, NpcRecord, RustRecord, SCHEMA};
|
use super::record::{ComponentRecord, DeployedFile, Instance, NpcRecord, RustRecord, SCHEMA};
|
||||||
use super::server::{self, RustServer};
|
use super::server::{self, RustServer};
|
||||||
use super::sidecar;
|
use super::sidecar;
|
||||||
@@ -49,6 +50,8 @@ struct Planned {
|
|||||||
retired_helpers: Vec<String>,
|
retired_helpers: Vec<String>,
|
||||||
/// RunicNPC, when the bundle carries it (D224): absent, identical or replaced.
|
/// RunicNPC, when the bundle carries it (D224): absent, identical or replaced.
|
||||||
npc_action: Option<BinaryAction>,
|
npc_action: Option<BinaryAction>,
|
||||||
|
/// PopupNotifications' config: the banner where it is missing or the plugin's defaults (D327).
|
||||||
|
popup: popup::State,
|
||||||
game_port: u16,
|
game_port: u16,
|
||||||
web_port: u16,
|
web_port: u16,
|
||||||
config_path: PathBuf,
|
config_path: PathBuf,
|
||||||
@@ -183,7 +186,9 @@ pub fn deploy(cli: &Cli, mode: Mode) -> Result<()> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunicNPC (D224), fetched and checked beside the plugin, before anything is planned.
|
// RunicNPC (D224), fetched and checked beside the plugin, before anything is planned. It is
|
||||||
|
// required since RunicNPC's stage 9 (D310): the bridge refuses every NPC an event places
|
||||||
|
// without it, so a bundle that cannot place it is refused before anything is written.
|
||||||
let npc_released = match &bundle.npc {
|
let npc_released = match &bundle.npc {
|
||||||
Some(component) => {
|
Some(component) => {
|
||||||
let path = scratch.path().join(&component.asset.name);
|
let path = scratch.path().join(&component.asset.name);
|
||||||
@@ -191,7 +196,8 @@ pub fn deploy(cli: &Cli, mode: Mode) -> Result<()> {
|
|||||||
let released = npc::read_tarball(&path)?;
|
let released = npc::read_tarball(&path)?;
|
||||||
if released.manifest.api != component.api {
|
if released.manifest.api != component.api {
|
||||||
bail!(
|
bail!(
|
||||||
"RunicNPC in bundle {} answers API {}, but the bundle says {} — refusing a component the bundle does not describe.",
|
"RunicNPC in bundle {} answers API {}, but the bundle says {} — refusing a \
|
||||||
|
component the bundle does not describe.",
|
||||||
bundle.bundle,
|
bundle.bundle,
|
||||||
released.manifest.api,
|
released.manifest.api,
|
||||||
component.api
|
component.api
|
||||||
@@ -205,7 +211,12 @@ pub fn deploy(cli: &Cli, mode: Mode) -> Result<()> {
|
|||||||
}
|
}
|
||||||
Some(released)
|
Some(released)
|
||||||
}
|
}
|
||||||
None => None,
|
None => bail!(
|
||||||
|
"bundle {} carries no RunicNPC, and Runic Gateway's Rust events need it: without it \
|
||||||
|
the bridge refuses every NPC an event places. Install the current bundle (leave \
|
||||||
|
--bundle off), or pin one published with RunicNPC v1.0.0 or later.",
|
||||||
|
bundle.bundle
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
// ── Plan every instance ──────────────────────────────────────────────────
|
// ── Plan every instance ──────────────────────────────────────────────────
|
||||||
@@ -387,6 +398,7 @@ pub fn deploy(cli: &Cli, mode: Mode) -> Result<()> {
|
|||||||
|| p.npc_action.is_some_and(|a| a.writes())
|
|| p.npc_action.is_some_and(|a| a.writes())
|
||||||
|| p.helper_actions.iter().any(|a| a.writes())
|
|| p.helper_actions.iter().any(|a| a.writes())
|
||||||
|| !p.retired_helpers.is_empty()
|
|| !p.retired_helpers.is_empty()
|
||||||
|
|| p.popup.writes()
|
||||||
})
|
})
|
||||||
.count();
|
.count();
|
||||||
if restored == 0 && !binary_action.writes() {
|
if restored == 0 && !binary_action.writes() {
|
||||||
@@ -529,10 +541,12 @@ fn plan_instance(
|
|||||||
Ok(_) => BinaryAction::Replace,
|
Ok(_) => BinaryAction::Replace,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
let popup = popup::inspect(&server.framework.config_dir(&server.path).join(popup::FILE));
|
||||||
let config_path = layout.rust_config(id);
|
let config_path = layout.rust_config(id);
|
||||||
Ok(Planned {
|
Ok(Planned {
|
||||||
id: id.to_string(),
|
id: id.to_string(),
|
||||||
running: server::is_running(&server.path),
|
running: server::is_running(&server.path),
|
||||||
|
popup,
|
||||||
config_exists: config_path.exists(),
|
config_exists: config_path.exists(),
|
||||||
config_path,
|
config_path,
|
||||||
db_path: layout.rust_db(id),
|
db_path: layout.rust_db(id),
|
||||||
@@ -633,6 +647,18 @@ fn print_plan(
|
|||||||
if p.config_exists { "kept" } else { "written" }
|
if p.config_exists { "kept" } else { "written" }
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
ui::row(
|
||||||
|
"popup look",
|
||||||
|
&format!(
|
||||||
|
"{} {}",
|
||||||
|
p.server
|
||||||
|
.framework
|
||||||
|
.config_dir(&p.server.path)
|
||||||
|
.join(popup::FILE)
|
||||||
|
.display(),
|
||||||
|
p.popup.label()
|
||||||
|
),
|
||||||
|
);
|
||||||
ui::row(
|
ui::row(
|
||||||
"ports",
|
"ports",
|
||||||
&format!(
|
&format!(
|
||||||
@@ -695,6 +721,26 @@ fn deploy_instance(
|
|||||||
ui::ok(&format!("wrote {}", plugin_config_path.display()));
|
ui::ok(&format!("wrote {}", plugin_config_path.display()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PopupNotifications' look (D327): the banner, only over nothing or over the plugin's own
|
||||||
|
// defaults. Before the plugins, so a PopupNotifications that loads after them reads it; one
|
||||||
|
// already loaded keeps its old look until it is reloaded.
|
||||||
|
if let Some(banner) = popup::banner_for(plan.popup) {
|
||||||
|
let dir = plan.server.framework.config_dir(&plan.server.path);
|
||||||
|
std::fs::create_dir_all(&dir)
|
||||||
|
.with_context(|| format!("cannot create {}", dir.display()))?;
|
||||||
|
let path = dir.join(popup::FILE);
|
||||||
|
write_atomic(&path, banner.as_bytes())?;
|
||||||
|
ui::ok(&format!(
|
||||||
|
"wrote the PopupNotifications banner {}{}",
|
||||||
|
path.display(),
|
||||||
|
if plan.running {
|
||||||
|
" (takes effect when PopupNotifications next loads)"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
// The sidecar's config, once; the token is the sidecar's to generate.
|
// The sidecar's config, once; the token is the sidecar's to generate.
|
||||||
if !plan.config_exists {
|
if !plan.config_exists {
|
||||||
if let Some(parent) = plan.config_path.parent() {
|
if let Some(parent) = plan.config_path.parent() {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ mod doctor;
|
|||||||
mod install;
|
mod install;
|
||||||
mod npc;
|
mod npc;
|
||||||
mod plugin;
|
mod plugin;
|
||||||
|
mod popup;
|
||||||
mod record;
|
mod record;
|
||||||
mod server;
|
mod server;
|
||||||
mod sidecar;
|
mod sidecar;
|
||||||
|
|||||||
@@ -8,8 +8,9 @@
|
|||||||
//! it. RunicNPC makes that directory itself on first load, because one made from outside the game
|
//! it. RunicNPC makes that directory itself on first load, because one made from outside the game
|
||||||
//! is not writable by it (runicnpc PLAN.md §1.5).
|
//! is not writable by it (runicnpc PLAN.md §1.5).
|
||||||
//!
|
//!
|
||||||
//! It is optional until RunicNPC's stage 9: a bundle without it installs as before, and a host
|
//! It is required since RunicNPC's stage 9 (D310): the bridge refuses every NPC an event places
|
||||||
//! without it runs the bridge with Rust's own scientists only (D243).
|
//! without it, Rust's own scientists included, so `install` and `update` refuse a bundle that does
|
||||||
|
//! not carry it and `doctor` fails a host that lacks it.
|
||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|||||||
312
src/rustgame/popup.rs
Normal file
312
src/rustgame/popup.rs
Normal file
@@ -0,0 +1,312 @@
|
|||||||
|
//! The recommended PopupNotifications look: a banner across the top of the screen (docs/runicnpc/
|
||||||
|
//! PLAN.md stage 9e, D327).
|
||||||
|
//!
|
||||||
|
//! PopupNotifications is optional and the operator's to install (D141); its config is the
|
||||||
|
//! operator's too. The installer writes the banner into it only where it is **missing** or **still
|
||||||
|
//! exactly the plugin's own defaults** — every setting equal to 0.2.1's, the `Version` aside (D328).
|
||||||
|
//! A config with any one setting changed is somebody's choice and is kept whole, never merged into.
|
||||||
|
//! A config that does not parse is kept too: it is not ours to repair.
|
||||||
|
//!
|
||||||
|
//! The file carries a `Version`: PopupNotifications resets a config whose version is missing or
|
||||||
|
//! below 0.2.0 to its defaults on load, which would undo the banner at the first boot.
|
||||||
|
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
use serde_json::Value;
|
||||||
|
|
||||||
|
/// The config's file name, in the framework's config directory beside the bridge's.
|
||||||
|
pub const FILE: &str = "PopupNotifications.json";
|
||||||
|
|
||||||
|
/// What is there now, and so what happens to it.
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
pub enum State {
|
||||||
|
/// No config: the banner is written, and PopupNotifications reads it when it is installed.
|
||||||
|
Missing,
|
||||||
|
/// The plugin's own defaults, untouched: the banner replaces them. Holds the file's version.
|
||||||
|
Defaults(Version),
|
||||||
|
/// Changed by someone, or unreadable: kept.
|
||||||
|
Theirs,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// PopupNotifications' `VersionNumber`, as its config writes it.
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
pub struct Version {
|
||||||
|
pub major: u64,
|
||||||
|
pub minor: u64,
|
||||||
|
pub patch: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The version written into a config made from nothing: the release the defaults are read from.
|
||||||
|
const WRITTEN_VERSION: Version = Version {
|
||||||
|
major: 0,
|
||||||
|
minor: 2,
|
||||||
|
patch: 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
impl State {
|
||||||
|
pub fn writes(self) -> bool {
|
||||||
|
!matches!(self, Self::Theirs)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn label(self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
Self::Missing => "banner written (no config yet)",
|
||||||
|
Self::Defaults(_) => "banner written (was the plugin's defaults)",
|
||||||
|
Self::Theirs => "kept (not the plugin's defaults)",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Reads the config at `path` and says what it is.
|
||||||
|
pub fn inspect(path: &Path) -> State {
|
||||||
|
match std::fs::read(path) {
|
||||||
|
Err(e) if e.kind() == std::io::ErrorKind::NotFound => State::Missing,
|
||||||
|
Err(_) => State::Theirs,
|
||||||
|
Ok(bytes) => classify(&bytes),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn classify(bytes: &[u8]) -> State {
|
||||||
|
let Ok(Value::Object(mut found)) = serde_json::from_slice::<Value>(bytes) else {
|
||||||
|
return State::Theirs;
|
||||||
|
};
|
||||||
|
let version = found.remove("Version");
|
||||||
|
let Ok(Value::Object(mut defaults)) = serde_json::from_str::<Value>(&render(DEFAULTS, None))
|
||||||
|
else {
|
||||||
|
unreachable!("the defaults are valid JSON")
|
||||||
|
};
|
||||||
|
defaults.remove("Version");
|
||||||
|
if !same(&Value::Object(found), &Value::Object(defaults)) {
|
||||||
|
return State::Theirs;
|
||||||
|
}
|
||||||
|
State::Defaults(
|
||||||
|
version
|
||||||
|
.as_ref()
|
||||||
|
.and_then(read_version)
|
||||||
|
.unwrap_or(WRITTEN_VERSION),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_version(v: &Value) -> Option<Version> {
|
||||||
|
Some(Version {
|
||||||
|
major: v.get("Major")?.as_u64()?,
|
||||||
|
minor: v.get("Minor")?.as_u64()?,
|
||||||
|
patch: v.get("Patch")?.as_u64()?,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// JSON equality with numbers compared as numbers: the plugin writes its floats through
|
||||||
|
/// Newtonsoft, and a value written `1.0` by one framework and `1` by another is the same setting.
|
||||||
|
fn same(a: &Value, b: &Value) -> bool {
|
||||||
|
match (a, b) {
|
||||||
|
(Value::Number(x), Value::Number(y)) => match (x.as_f64(), y.as_f64()) {
|
||||||
|
(Some(x), Some(y)) => (x - y).abs() < 1e-6,
|
||||||
|
_ => false,
|
||||||
|
},
|
||||||
|
(Value::Object(x), Value::Object(y)) => {
|
||||||
|
x.len() == y.len() && x.iter().all(|(k, v)| y.get(k).is_some_and(|w| same(v, w)))
|
||||||
|
}
|
||||||
|
(Value::Array(x), Value::Array(y)) => {
|
||||||
|
x.len() == y.len() && x.iter().zip(y).all(|(v, w)| same(v, w))
|
||||||
|
}
|
||||||
|
_ => a == b,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The banner, as the file to write for `state`. `None` for a config that is kept.
|
||||||
|
pub fn banner_for(state: State) -> Option<String> {
|
||||||
|
match state {
|
||||||
|
State::Missing => Some(render(BANNER, Some(WRITTEN_VERSION))),
|
||||||
|
State::Defaults(version) => Some(render(BANNER, Some(version))),
|
||||||
|
State::Theirs => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// One look: the eleven settings PopupNotifications has.
|
||||||
|
struct Look {
|
||||||
|
left: &'static str,
|
||||||
|
bottom: &'static str,
|
||||||
|
width: &'static str,
|
||||||
|
height: &'static str,
|
||||||
|
spacing: &'static str,
|
||||||
|
close: bool,
|
||||||
|
alpha: &'static str,
|
||||||
|
font: &'static str,
|
||||||
|
font_size: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// PopupNotifications 0.2.1's `GetBaseConfig()`: a small grey box at the right of the screen.
|
||||||
|
const DEFAULTS: Look = Look {
|
||||||
|
left: "0.8",
|
||||||
|
bottom: "0.78",
|
||||||
|
width: "0.19",
|
||||||
|
height: "0.1",
|
||||||
|
spacing: "0.01",
|
||||||
|
close: true,
|
||||||
|
alpha: "0.5",
|
||||||
|
font: "droidsansmono.ttf",
|
||||||
|
font_size: 12,
|
||||||
|
};
|
||||||
|
|
||||||
|
/// The recommended look (9d player session, 2026-10-09): a banner across the top of the screen.
|
||||||
|
const BANNER: Look = Look {
|
||||||
|
left: "0.15",
|
||||||
|
bottom: "0.87",
|
||||||
|
width: "0.7",
|
||||||
|
height: "0.07",
|
||||||
|
spacing: "0.005",
|
||||||
|
close: false,
|
||||||
|
alpha: "0.8",
|
||||||
|
font: "robotocondensed-bold.ttf",
|
||||||
|
font_size: 18,
|
||||||
|
};
|
||||||
|
|
||||||
|
/// The config file, laid out as the plugin writes it. Duration, the most shown, both colours and
|
||||||
|
/// the close button's transparency are the plugin's own in both looks.
|
||||||
|
fn render(look: Look, version: Option<Version>) -> String {
|
||||||
|
let version = version.unwrap_or(WRITTEN_VERSION);
|
||||||
|
format!(
|
||||||
|
r##"{{
|
||||||
|
"Notification duration (in seconds)": 8,
|
||||||
|
"Maximum notifications shown at any time": 6,
|
||||||
|
"UI Positioning": {{
|
||||||
|
"Position of the left side of notification (0.0 - 1.0)": {left},
|
||||||
|
"Position of the bottom of noticiation (0.0 - 1.0)": {bottom},
|
||||||
|
"Width (0.0 - 1.0)": {width},
|
||||||
|
"Height (0.0 - 1.0)": {height},
|
||||||
|
"Space between notification (0.0 - 1.0)": {spacing}
|
||||||
|
}},
|
||||||
|
"UI Options": {{
|
||||||
|
"Show close button": {close},
|
||||||
|
"Panel color (hex)": "#2b2b2b",
|
||||||
|
"Panel transparency (0.0 - 1.0)": {alpha},
|
||||||
|
"Close button color (hex)": "#d85540",
|
||||||
|
"Close button transparency (0.0 - 1.0)": 0.5,
|
||||||
|
"Font": "{font}",
|
||||||
|
"Font size": {font_size}
|
||||||
|
}},
|
||||||
|
"Version": {{
|
||||||
|
"Major": {major},
|
||||||
|
"Minor": {minor},
|
||||||
|
"Patch": {patch}
|
||||||
|
}}
|
||||||
|
}}"##,
|
||||||
|
left = look.left,
|
||||||
|
bottom = look.bottom,
|
||||||
|
width = look.width,
|
||||||
|
height = look.height,
|
||||||
|
spacing = look.spacing,
|
||||||
|
close = look.close,
|
||||||
|
alpha = look.alpha,
|
||||||
|
font = look.font,
|
||||||
|
font_size = look.font_size,
|
||||||
|
major = version.major,
|
||||||
|
minor = version.minor,
|
||||||
|
patch = version.patch,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use crate::util::TempDir;
|
||||||
|
|
||||||
|
/// The file PopupNotifications 0.2.1 wrote on both rigs at its first load (2026-10-09).
|
||||||
|
const RIG_DEFAULTS: &str = r##"{
|
||||||
|
"Notification duration (in seconds)": 8,
|
||||||
|
"Maximum notifications shown at any time": 6,
|
||||||
|
"UI Positioning": {
|
||||||
|
"Position of the left side of notification (0.0 - 1.0)": 0.8,
|
||||||
|
"Position of the bottom of noticiation (0.0 - 1.0)": 0.78,
|
||||||
|
"Width (0.0 - 1.0)": 0.19,
|
||||||
|
"Height (0.0 - 1.0)": 0.1,
|
||||||
|
"Space between notification (0.0 - 1.0)": 0.01
|
||||||
|
},
|
||||||
|
"UI Options": {
|
||||||
|
"Show close button": true,
|
||||||
|
"Panel color (hex)": "#2b2b2b",
|
||||||
|
"Panel transparency (0.0 - 1.0)": 0.5,
|
||||||
|
"Close button color (hex)": "#d85540",
|
||||||
|
"Close button transparency (0.0 - 1.0)": 0.5,
|
||||||
|
"Font": "droidsansmono.ttf",
|
||||||
|
"Font size": 12
|
||||||
|
},
|
||||||
|
"Version": {
|
||||||
|
"Major": 0,
|
||||||
|
"Minor": 2,
|
||||||
|
"Patch": 1
|
||||||
|
}
|
||||||
|
}"##;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_missing_config_gets_the_banner_with_a_version() {
|
||||||
|
let dir = TempDir::new("rg-popup-missing").unwrap();
|
||||||
|
let state = inspect(&dir.path().join(FILE));
|
||||||
|
assert_eq!(state, State::Missing);
|
||||||
|
let written: Value = serde_json::from_str(&banner_for(state).unwrap()).unwrap();
|
||||||
|
assert_eq!(written["UI Positioning"]["Width (0.0 - 1.0)"], 0.7);
|
||||||
|
assert_eq!(written["UI Options"]["Show close button"], false);
|
||||||
|
assert_eq!(written["UI Options"]["Font"], "robotocondensed-bold.ttf");
|
||||||
|
assert_eq!(written["UI Options"]["Font size"], 18);
|
||||||
|
// Without a version the plugin resets the file to its defaults at load.
|
||||||
|
assert_eq!(written["Version"]["Minor"], 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_plugins_own_defaults_are_replaced_and_their_version_kept() {
|
||||||
|
assert_eq!(
|
||||||
|
classify(RIG_DEFAULTS.as_bytes()),
|
||||||
|
State::Defaults(WRITTEN_VERSION)
|
||||||
|
);
|
||||||
|
let later = RIG_DEFAULTS.replace("\"Patch\": 1", "\"Patch\": 4");
|
||||||
|
let state = classify(later.as_bytes());
|
||||||
|
assert_eq!(
|
||||||
|
state,
|
||||||
|
State::Defaults(Version {
|
||||||
|
major: 0,
|
||||||
|
minor: 2,
|
||||||
|
patch: 4
|
||||||
|
})
|
||||||
|
);
|
||||||
|
assert!(banner_for(state).unwrap().contains("\"Patch\": 4"));
|
||||||
|
// A whole number written as a float is still the default.
|
||||||
|
let floats = RIG_DEFAULTS.replace("\"Font size\": 12", "\"Font size\": 12.0");
|
||||||
|
assert!(matches!(classify(floats.as_bytes()), State::Defaults(_)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_rendered_defaults_are_the_file_the_plugin_writes() {
|
||||||
|
let ours: Value = serde_json::from_str(&render(DEFAULTS, None)).unwrap();
|
||||||
|
let rig: Value = serde_json::from_str(RIG_DEFAULTS).unwrap();
|
||||||
|
assert_eq!(ours, rig);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn any_change_keeps_the_whole_config() {
|
||||||
|
for changed in [
|
||||||
|
RIG_DEFAULTS.replace("\"Font size\": 12", "\"Font size\": 14"),
|
||||||
|
RIG_DEFAULTS.replace(
|
||||||
|
"\"Notification duration (in seconds)\": 8",
|
||||||
|
"\"Notification duration (in seconds)\": 9",
|
||||||
|
),
|
||||||
|
RIG_DEFAULTS.replace("#2b2b2b", "#000000"),
|
||||||
|
render(BANNER, None),
|
||||||
|
"{ not json".to_string(),
|
||||||
|
"[]".to_string(),
|
||||||
|
] {
|
||||||
|
let state = classify(changed.as_bytes());
|
||||||
|
assert_eq!(state, State::Theirs, "{changed}");
|
||||||
|
assert_eq!(banner_for(state), None);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_config_with_a_setting_added_or_missing_is_theirs() {
|
||||||
|
let mut v: Value = serde_json::from_str(RIG_DEFAULTS).unwrap();
|
||||||
|
v["Extra"] = Value::Bool(true);
|
||||||
|
assert_eq!(classify(v.to_string().as_bytes()), State::Theirs);
|
||||||
|
let mut v: Value = serde_json::from_str(RIG_DEFAULTS).unwrap();
|
||||||
|
v.as_object_mut().unwrap().remove("UI Options");
|
||||||
|
assert_eq!(classify(v.to_string().as_bytes()), State::Theirs);
|
||||||
|
}
|
||||||
|
}
|
||||||
289
src/servuo.rs
289
src/servuo.rs
@@ -180,6 +180,21 @@ pub(crate) fn strip_extended_prefix(path: PathBuf) -> PathBuf {
|
|||||||
pub struct RunningShard {
|
pub struct RunningShard {
|
||||||
pub pid: u32,
|
pub pid: u32,
|
||||||
pub detail: String,
|
pub detail: String,
|
||||||
|
/// `false` when the process names a *relative* `ServUO.exe` and its working directory could not
|
||||||
|
/// be read (another user's process, installer not run as root), so it may be a different
|
||||||
|
/// shard. Install/update still refuse — failing closed is the point — but say why.
|
||||||
|
pub certain: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// How one process relates to the tree being deployed into. See [`classify`].
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
enum Verdict {
|
||||||
|
/// Not a ServUO process, or one running out of a different tree.
|
||||||
|
No,
|
||||||
|
/// A ServUO process running out of this tree.
|
||||||
|
Shard,
|
||||||
|
/// A ServUO process launched with a relative path whose working directory could not be read.
|
||||||
|
Unknown,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Refuses to proceed if a shard is running out of `root`.
|
/// Refuses to proceed if a shard is running out of `root`.
|
||||||
@@ -190,20 +205,31 @@ pub struct RunningShard {
|
|||||||
/// running" for a shard that is very much running — the one wrong answer that corrupts a live
|
/// running" for a shard that is very much running — the one wrong answer that corrupts a live
|
||||||
/// `Scripts.dll`. Scoping to processes under *this* root also means a second shard on the same host
|
/// `Scripts.dll`. Scoping to processes under *this* root also means a second shard on the same host
|
||||||
/// does not block a deploy into the first.
|
/// does not block a deploy into the first.
|
||||||
|
///
|
||||||
|
/// Every launch shape is covered (installer#47): `ServUO.exe` run directly (Windows),
|
||||||
|
/// `mono /abs/path/ServUO.exe`, and — the common one under systemd or tmux — `mono ServUO.exe`
|
||||||
|
/// started from inside the root, where the root appears only in the process's working directory.
|
||||||
|
/// The decision itself is [`classify`]; this function only gathers what it needs.
|
||||||
pub fn find_running(root: &Path) -> Option<RunningShard> {
|
pub fn find_running(root: &Path) -> Option<RunningShard> {
|
||||||
use sysinfo::{ProcessRefreshKind, RefreshKind, System};
|
use sysinfo::{ProcessRefreshKind, RefreshKind, System};
|
||||||
|
|
||||||
let system = System::new_with_specifics(
|
let system = System::new_with_specifics(
|
||||||
RefreshKind::nothing().with_processes(ProcessRefreshKind::everything()),
|
RefreshKind::nothing().with_processes(ProcessRefreshKind::everything()),
|
||||||
);
|
);
|
||||||
let root_str = normalize_for_match(&root.to_string_lossy());
|
|
||||||
|
|
||||||
|
let mut unknown = None;
|
||||||
for (pid, process) in system.processes() {
|
for (pid, process) in system.processes() {
|
||||||
// Own process first: the installer may well have been copied into the server root, and
|
// Own process first: the installer may well have been copied into the server root, and
|
||||||
// matching itself would make every run refuse to start.
|
// matching itself would make every run refuse to start.
|
||||||
if pid.as_u32() == std::process::id() {
|
if pid.as_u32() == std::process::id() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// On Linux the scan lists every thread (TID) beside its process (TGID). They share the
|
||||||
|
// process's exe/cmd/cwd, so a thread can match first and the refusal names a pid that
|
||||||
|
// `kill` cannot use (installer#45 item 5). Threads are skipped; the process itself matches.
|
||||||
|
if process.thread_kind().is_some() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
let exe = process
|
let exe = process
|
||||||
.exe()
|
.exe()
|
||||||
@@ -215,19 +241,101 @@ pub fn find_running(root: &Path) -> Option<RunningShard> {
|
|||||||
.map(|a| a.to_string_lossy().to_string())
|
.map(|a| a.to_string_lossy().to_string())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let hay = normalize_for_match(&format!("{exe} {}", args.join(" ")));
|
let found = |certain| {
|
||||||
// Two conditions, both required: something in this process names the tree, AND it names
|
let detail = if exe.is_empty() {
|
||||||
// the ServUO assembly. Either alone over-matches — an editor with the path open, or a
|
args.join(" ")
|
||||||
// different shard's ServUO.exe.
|
} else {
|
||||||
if hay.contains(&root_str) && hay.contains("servuo.exe") {
|
exe.clone()
|
||||||
let detail = if exe.is_empty() { args.join(" ") } else { exe };
|
};
|
||||||
return Some(RunningShard {
|
RunningShard {
|
||||||
pid: pid.as_u32(),
|
pid: pid.as_u32(),
|
||||||
detail,
|
detail,
|
||||||
});
|
certain,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
match classify(root, &exe, &args, process.cwd()) {
|
||||||
|
Verdict::Shard => return Some(found(true)),
|
||||||
|
// Kept looking: a certain match elsewhere is the better report.
|
||||||
|
Verdict::Unknown if unknown.is_none() => unknown = Some(found(false)),
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None
|
unknown
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Decides whether one process is a ServUO running out of `root`. Pure, so every launch shape is
|
||||||
|
/// unit-tested without spawning anything.
|
||||||
|
///
|
||||||
|
/// Something in the process must name the ServUO assembly — otherwise an editor or a shell sitting
|
||||||
|
/// in the root would match — and that assembly must resolve into this tree, otherwise a second
|
||||||
|
/// shard on the host would block this one.
|
||||||
|
fn classify(root: &Path, exe: &str, args: &[String], cwd: Option<&Path>) -> Verdict {
|
||||||
|
let root_str = normalize_for_match(&root.to_string_lossy());
|
||||||
|
let names_assembly = |s: &str| normalize_for_match(s).ends_with("servuo.exe");
|
||||||
|
|
||||||
|
// ServUO.exe is itself the executable (Windows): its path settles it, whatever argv says.
|
||||||
|
if names_assembly(exe) {
|
||||||
|
return if in_tree(Path::new(exe), &root_str) {
|
||||||
|
Verdict::Shard
|
||||||
|
} else {
|
||||||
|
Verdict::No
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// The original substring rule, kept so nothing it caught is lost: the tree and the assembly
|
||||||
|
// both named somewhere in the command line (`mono /opt/ServUO/ServUO.exe`, or an option of
|
||||||
|
// the form `--assembly=/opt/ServUO/ServUO.exe`).
|
||||||
|
let hay = normalize_for_match(&format!("{exe} {}", args.join(" ")));
|
||||||
|
if !hay.contains("servuo.exe") {
|
||||||
|
return Verdict::No;
|
||||||
|
}
|
||||||
|
if hay.contains(&root_str) {
|
||||||
|
return Verdict::Shard;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hosted (`mono` / `dotnet`) with the assembly named relatively: resolve it against the
|
||||||
|
// process's working directory. `mono ServUO.exe` from the root and `mono ServUO/ServUO.exe`
|
||||||
|
// from its parent both land here.
|
||||||
|
let mut verdict = Verdict::No;
|
||||||
|
for arg in args.iter().filter(|a| names_assembly(a)) {
|
||||||
|
let path = Path::new(arg);
|
||||||
|
let resolved = if path.has_root() {
|
||||||
|
path.to_path_buf()
|
||||||
|
} else if let Some(cwd) = cwd {
|
||||||
|
cwd.join(path)
|
||||||
|
} else {
|
||||||
|
// Unreadable cwd: cannot rule this tree out. Fail closed (decided 2026-11-27).
|
||||||
|
verdict = Verdict::Unknown;
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
if in_tree(&resolved, &root_str) {
|
||||||
|
return Verdict::Shard;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
verdict
|
||||||
|
}
|
||||||
|
|
||||||
|
/// True when `path` (lexically normalized: `.` dropped, `..` applied) lies inside the tree whose
|
||||||
|
/// normalized path is `root_str`. A component-wise prefix, so `/opt/ServUO2` is not inside
|
||||||
|
/// `/opt/ServUO`.
|
||||||
|
fn in_tree(path: &Path, root_str: &str) -> bool {
|
||||||
|
use std::path::Component;
|
||||||
|
|
||||||
|
let mut clean = PathBuf::new();
|
||||||
|
for component in path.components() {
|
||||||
|
match component {
|
||||||
|
Component::CurDir => {}
|
||||||
|
Component::ParentDir => {
|
||||||
|
clean.pop();
|
||||||
|
}
|
||||||
|
other => clean.push(other.as_os_str()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let path_str = normalize_for_match(&clean.to_string_lossy());
|
||||||
|
let root_str = root_str.trim_end_matches('/');
|
||||||
|
path_str
|
||||||
|
.strip_prefix(root_str)
|
||||||
|
.is_some_and(|rest| rest.starts_with('/'))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Lower-cases and unifies separators so a Windows path compares equal however it was spelled.
|
/// Lower-cases and unifies separators so a Windows path compares equal however it was spelled.
|
||||||
@@ -238,6 +346,18 @@ fn normalize_for_match(s: &str) -> String {
|
|||||||
/// Builds the refusal message. Separate from [`find_running`] so the wording is testable and so
|
/// Builds the refusal message. Separate from [`find_running`] so the wording is testable and so
|
||||||
/// callers cannot accidentally soften it.
|
/// callers cannot accidentally soften it.
|
||||||
pub fn running_error(root: &Path, shard: &RunningShard) -> anyhow::Error {
|
pub fn running_error(root: &Path, shard: &RunningShard) -> anyhow::Error {
|
||||||
|
if !shard.certain {
|
||||||
|
return anyhow::anyhow!(
|
||||||
|
"A ServUO process is running (pid {} — {}) and its working directory cannot be read, \
|
||||||
|
so the installer cannot rule out that it is running from {}.\n\
|
||||||
|
Stop it, or re-run the installer as root (sudo) so it can check. ServUO.exe holds \
|
||||||
|
Scripts.dll open and rewrites Saves/ on exit, so deploying underneath a live shard \
|
||||||
|
corrupts one or both. This is not overridable.",
|
||||||
|
shard.pid,
|
||||||
|
shard.detail,
|
||||||
|
root.display()
|
||||||
|
);
|
||||||
|
}
|
||||||
anyhow::anyhow!(
|
anyhow::anyhow!(
|
||||||
"ServUO is running from {} (pid {} — {}).\n\
|
"ServUO is running from {} (pid {} — {}).\n\
|
||||||
Stop the shard before installing. ServUO.exe holds Scripts.dll open and rewrites Saves/ \
|
Stop the shard before installing. ServUO.exe holds Scripts.dll open and rewrites Saves/ \
|
||||||
@@ -263,6 +383,16 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::util::TempDir;
|
use crate::util::TempDir;
|
||||||
|
|
||||||
|
/// Held by every test that scans the real process table. The live-launch test's child names
|
||||||
|
/// `ServUO.exe`; caught mid-exit by a parallel scan (cmdline read, cwd already gone) it is an
|
||||||
|
/// `Unknown` match, and the empty-tree test would report it as a shard.
|
||||||
|
static PROCESS_TABLE: std::sync::Mutex<()> = std::sync::Mutex::new(());
|
||||||
|
|
||||||
|
fn process_table() -> std::sync::MutexGuard<'static, ()> {
|
||||||
|
// A failed test poisons the lock; the next one still needs it.
|
||||||
|
PROCESS_TABLE.lock().unwrap_or_else(|e| e.into_inner())
|
||||||
|
}
|
||||||
|
|
||||||
fn fake_root(dir: &Path) {
|
fn fake_root(dir: &Path) {
|
||||||
fs::create_dir_all(dir.join("Scripts")).unwrap();
|
fs::create_dir_all(dir.join("Scripts")).unwrap();
|
||||||
fs::create_dir_all(dir.join("Config")).unwrap();
|
fs::create_dir_all(dir.join("Config")).unwrap();
|
||||||
@@ -383,6 +513,7 @@ mod tests {
|
|||||||
let shard = RunningShard {
|
let shard = RunningShard {
|
||||||
pid: 4242,
|
pid: 4242,
|
||||||
detail: "/opt/ServUO/ServUO.exe".into(),
|
detail: "/opt/ServUO/ServUO.exe".into(),
|
||||||
|
certain: true,
|
||||||
};
|
};
|
||||||
let msg = running_error(Path::new("/opt/ServUO"), &shard).to_string();
|
let msg = running_error(Path::new("/opt/ServUO"), &shard).to_string();
|
||||||
assert!(msg.contains("4242"), "{msg}");
|
assert!(msg.contains("4242"), "{msg}");
|
||||||
@@ -390,6 +521,143 @@ mod tests {
|
|||||||
assert!(msg.contains("not overridable"), "{msg}");
|
assert!(msg.contains("not overridable"), "{msg}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn an_uncertain_refusal_says_it_could_not_check_and_still_offers_no_override() {
|
||||||
|
let shard = RunningShard {
|
||||||
|
pid: 4242,
|
||||||
|
detail: "mono ServUO.exe".into(),
|
||||||
|
certain: false,
|
||||||
|
};
|
||||||
|
let msg = running_error(Path::new("/opt/ServUO"), &shard).to_string();
|
||||||
|
assert!(msg.contains("4242"), "{msg}");
|
||||||
|
assert!(msg.contains("cannot be read"), "{msg}");
|
||||||
|
assert!(msg.contains("sudo"), "{msg}");
|
||||||
|
assert!(msg.contains("not overridable"), "{msg}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// installer#47 — every launch shape. Paths are written Unix-style; `Path` parses them on
|
||||||
|
// Windows too (root dir, no prefix), so these run on both CI legs.
|
||||||
|
const ROOT: &str = "/opt/ServUO";
|
||||||
|
const MONO: &str = "/usr/bin/mono-sgen";
|
||||||
|
|
||||||
|
fn verdict(exe: &str, args: &[&str], cwd: Option<&str>) -> Verdict {
|
||||||
|
let args: Vec<String> = args.iter().map(|a| a.to_string()).collect();
|
||||||
|
classify(Path::new(ROOT), exe, &args, cwd.map(Path::new))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_relative_launch_from_the_root_is_the_shard() {
|
||||||
|
// `cd /opt/ServUO && mono ServUO.exe` — systemd WorkingDirectory=, or tmux.
|
||||||
|
let v = verdict(MONO, &["mono", "ServUO.exe"], Some("/opt/ServUO"));
|
||||||
|
assert_eq!(v, Verdict::Shard);
|
||||||
|
let v = verdict(
|
||||||
|
MONO,
|
||||||
|
&["mono", "--debug", "./ServUO.exe"],
|
||||||
|
Some("/opt/ServUO"),
|
||||||
|
);
|
||||||
|
assert_eq!(v, Verdict::Shard);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_relative_launch_from_elsewhere_resolves_against_its_cwd() {
|
||||||
|
let v = verdict(MONO, &["mono", "ServUO/ServUO.exe"], Some("/opt"));
|
||||||
|
assert_eq!(v, Verdict::Shard);
|
||||||
|
let v = verdict(MONO, &["mono", "../ServUO/ServUO.exe"], Some("/opt/other"));
|
||||||
|
assert_eq!(v, Verdict::Shard);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn an_absolute_launch_is_the_shard_whatever_the_cwd() {
|
||||||
|
let v = verdict(MONO, &["mono", "/opt/ServUO/ServUO.exe"], Some("/root"));
|
||||||
|
assert_eq!(v, Verdict::Shard);
|
||||||
|
// exe unreadable (another user's process), cwd unreadable: argv alone still settles it.
|
||||||
|
let v = verdict("", &["mono", "/opt/ServUO/ServUO.exe"], None);
|
||||||
|
assert_eq!(v, Verdict::Shard);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn servuo_as_the_executable_is_decided_by_its_path() {
|
||||||
|
// Windows: ServUO.exe runs natively; argv may be relative.
|
||||||
|
let v = verdict("/opt/ServUO/ServUO.exe", &["ServUO.exe"], None);
|
||||||
|
assert_eq!(v, Verdict::Shard);
|
||||||
|
let v = verdict("/srv/Other/ServUO.exe", &["ServUO.exe"], None);
|
||||||
|
assert_eq!(v, Verdict::No);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_second_shard_on_the_host_does_not_match() {
|
||||||
|
let v = verdict(MONO, &["mono", "ServUO.exe"], Some("/srv/Other"));
|
||||||
|
assert_eq!(v, Verdict::No);
|
||||||
|
let v = verdict(
|
||||||
|
MONO,
|
||||||
|
&["mono", "/srv/Other/ServUO.exe"],
|
||||||
|
Some("/opt/ServUO"),
|
||||||
|
);
|
||||||
|
assert_eq!(v, Verdict::No);
|
||||||
|
// A sibling whose name merely starts with the root's.
|
||||||
|
let v = verdict(MONO, &["mono", "ServUO.exe"], Some("/opt/ServUO2"));
|
||||||
|
assert_eq!(v, Verdict::No);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_process_that_does_not_name_the_assembly_never_matches() {
|
||||||
|
// The tmux shell sitting in the root, or an editor with a file open.
|
||||||
|
assert_eq!(
|
||||||
|
verdict("/bin/bash", &["-bash"], Some("/opt/ServUO")),
|
||||||
|
Verdict::No
|
||||||
|
);
|
||||||
|
let v = verdict(
|
||||||
|
"/usr/bin/vim",
|
||||||
|
&["vim", "Config/Server.cfg"],
|
||||||
|
Some("/opt/ServUO"),
|
||||||
|
);
|
||||||
|
assert_eq!(v, Verdict::No);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// installer#47 end to end on a real `/proc`: a process started *inside* the root naming a
|
||||||
|
/// relative `ServUO.exe` — the shape of `cd root && mono ServUO.exe` — is found, under its own
|
||||||
|
/// pid (a thread id would not equal `child.id()`, installer#45 item 5). `sh -c '…' ServUO.exe`
|
||||||
|
/// puts `ServUO.exe` in argv as `$0`. The shell waits in the `read` builtin on a stdin pipe the
|
||||||
|
/// test holds open, so it never forks: a forked child is a copy of `sh` — same argv, same cwd —
|
||||||
|
/// until it execs, a genuine second match the scan could report first (release run 3309).
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
#[test]
|
||||||
|
fn a_live_relative_launch_from_the_root_is_found_by_its_pid() {
|
||||||
|
let tmp = TempDir::new("rg-test-live-shard").unwrap();
|
||||||
|
let root = tmp.path().join("srv");
|
||||||
|
fake_root(&root);
|
||||||
|
let root = fs::canonicalize(&root).unwrap();
|
||||||
|
|
||||||
|
let _table = process_table();
|
||||||
|
let mut child = std::process::Command::new("sh")
|
||||||
|
.args(["-c", "read x", "ServUO.exe"])
|
||||||
|
.current_dir(&root)
|
||||||
|
.stdin(std::process::Stdio::piped())
|
||||||
|
.spawn()
|
||||||
|
.unwrap();
|
||||||
|
// The process is listed as soon as it exists, but give /proc a moment to fill cmdline.
|
||||||
|
let mut found = None;
|
||||||
|
for _ in 0..20 {
|
||||||
|
found = find_running(&root);
|
||||||
|
if found.is_some() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
std::thread::sleep(std::time::Duration::from_millis(50));
|
||||||
|
}
|
||||||
|
let _ = child.kill();
|
||||||
|
let _ = child.wait();
|
||||||
|
|
||||||
|
let shard = found.expect("a relative launch from the root must be detected");
|
||||||
|
assert_eq!(shard.pid, child.id());
|
||||||
|
assert!(shard.certain);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_relative_launch_with_an_unreadable_cwd_fails_closed() {
|
||||||
|
let v = verdict("", &["mono", "ServUO.exe"], None);
|
||||||
|
assert_eq!(v, Verdict::Unknown);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn nothing_is_running_out_of_an_empty_tree() {
|
fn nothing_is_running_out_of_an_empty_tree() {
|
||||||
// Also proves the scan does not match the test binary itself, which is the failure mode
|
// Also proves the scan does not match the test binary itself, which is the failure mode
|
||||||
@@ -397,6 +665,7 @@ mod tests {
|
|||||||
let tmp = TempDir::new("rg-test-running").unwrap();
|
let tmp = TempDir::new("rg-test-running").unwrap();
|
||||||
let root = tmp.path().join("srv");
|
let root = tmp.path().join("srv");
|
||||||
fake_root(&root);
|
fake_root(&root);
|
||||||
|
let _table = process_table();
|
||||||
assert!(find_running(&root).is_none());
|
assert!(find_running(&root).is_none());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
29
src/util.rs
29
src/util.rs
@@ -119,13 +119,22 @@ pub struct TempDir {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TempDir {
|
impl TempDir {
|
||||||
|
/// The name is pid + a per-process counter + the clock. The counter is what makes it unique:
|
||||||
|
/// two threads can read the same nanosecond (parallel tests did, and deleted each other's
|
||||||
|
/// files). `create_dir`, not `create_dir_all`, so a name that somehow exists is an error rather
|
||||||
|
/// than a directory silently shared with its owner.
|
||||||
pub fn new(prefix: &str) -> Result<Self> {
|
pub fn new(prefix: &str) -> Result<Self> {
|
||||||
|
use std::sync::atomic::{AtomicU64, Ordering};
|
||||||
|
static NEXT: AtomicU64 = AtomicU64::new(0);
|
||||||
|
|
||||||
|
let n = NEXT.fetch_add(1, Ordering::Relaxed);
|
||||||
let nanos = SystemTime::now()
|
let nanos = SystemTime::now()
|
||||||
.duration_since(UNIX_EPOCH)
|
.duration_since(UNIX_EPOCH)
|
||||||
.map(|d| d.as_nanos())
|
.map(|d| d.as_nanos())
|
||||||
.unwrap_or(0);
|
.unwrap_or(0);
|
||||||
let path = std::env::temp_dir().join(format!("{prefix}-{}-{nanos}", std::process::id()));
|
let path =
|
||||||
fs::create_dir_all(&path)
|
std::env::temp_dir().join(format!("{prefix}-{}-{n}-{nanos}", std::process::id()));
|
||||||
|
fs::create_dir(&path)
|
||||||
.with_context(|| format!("cannot create scratch directory {}", path.display()))?;
|
.with_context(|| format!("cannot create scratch directory {}", path.display()))?;
|
||||||
Ok(Self { path })
|
Ok(Self { path })
|
||||||
}
|
}
|
||||||
@@ -307,6 +316,22 @@ mod tests {
|
|||||||
assert!(!path.exists());
|
assert!(!path.exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn temp_dirs_made_at_once_on_many_threads_never_share_a_path() {
|
||||||
|
// Parallel tests with one prefix used to land in one directory when they read the same
|
||||||
|
// nanosecond, and the first to finish deleted the other's files.
|
||||||
|
let dirs: Vec<TempDir> = std::thread::scope(|s| {
|
||||||
|
let handles: Vec<_> = (0..16)
|
||||||
|
.map(|_| s.spawn(|| TempDir::new("rg-test-unique").unwrap()))
|
||||||
|
.collect();
|
||||||
|
handles.into_iter().map(|h| h.join().unwrap()).collect()
|
||||||
|
});
|
||||||
|
let mut paths: Vec<_> = dirs.iter().map(|d| d.path().to_path_buf()).collect();
|
||||||
|
paths.sort();
|
||||||
|
paths.dedup();
|
||||||
|
assert_eq!(paths.len(), dirs.len());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn a_failed_command_is_reported_with_what_it_printed() {
|
fn a_failed_command_is_reported_with_what_it_printed() {
|
||||||
// Both halves matter: the command to retype, and the reason it failed. stderr wins over
|
// Both halves matter: the command to retype, and the reason it failed. stderr wins over
|
||||||
|
|||||||
Reference in New Issue
Block a user