Skip to content
Open
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
55 changes: 54 additions & 1 deletion src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,50 @@ fn suggestion(cache: &Cache, args: &[std::ffi::OsString], interactive: bool) ->
.latest
.as_ref()
.filter(|latest| newer(latest))
.map(|latest| format!("proofline {latest} is available; run 'proofline update'"))
.map(|latest| notice(latest, cfg!(target_os = "windows")))
Comment on lines 143 to +146

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning · Detached discovery test fails on Windows

The test still requires Unix-only wording after this change gives Windows a different update notice.

On Windows, the test panics after the refreshed cache yields the expected update notice.

Check for the platform-independent version announcement both before and after the cache refresh.

View finding in Proofline

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 92a28dd. Correct: the assertion at src/update/tests.rs:358 still wanted the Unix text. On this machine the C-1 pipe timeout (fixed in prooflinedev#79) currently hides it. Both checks now use the platform's text (notice("9.0.0", cfg!(target_os = "windows")) after the refresh, and the platform-independent proofline 9.0.0 is available; before it). Verified by merging prooflinedev#79's branch into a throwaway branch: update::tests 9/9 pass on Windows.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marked fixed.

Comment on lines 143 to +146

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning · Windows update link can serve an older release than the notice

The Windows notice advertises the discovery version, but proofline update links to GitHub’s independently promoted latest release. The workflow advances discovery before promoting the GitHub release.

Users can verify and reinstall an older binary without getting the advertised update.

Link to version-pinned downloads for the advertised release, or tell users to confirm the release version before replacing their binary.

View finding in Proofline

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 92a28dd. Confirmed in release.yml: publish-r2.sh uploads latest (what the notice reads) before gh release edit --latest, so releases/latest can still show the old version for a while. install() on Windows now reads the local update cache, the same value the notice showed. When that is a newer version, the steps link to that version's pinned files, https://proofline.sh/cli/download/<version>/... (the files the Unix updater verifies). These exist before GitHub promotes the release. The value has already passed version() via newer(), so it is only digits and dots. Without a cached newer version, the GitHub page stays as the fallback. Still no network call, so the tests stay offline. The integration test now covers both cases.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marked fixed.

Comment on lines 143 to +146

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning · Notice tests miss Windows falling back to Unix wording

The new tests call notice directly, while the cached-discovery fixture expects Unix wording even on Windows.

The tests would pass if suggestion always selected Unix wording.

Assert platform-specific wording from the cached invocation and run that test on Windows.

View finding in Proofline

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 92a28dd. windows_notices_point_to_the_manual_steps now also asserts suggestion(&cache, ["status"], true) == notice("9.0.0", cfg!(target_os = "windows")). Mutation check on Windows: hard-coding notice(latest, false) in suggestion makes the test fail at src/update/tests.rs:218. The cached-discovery test checks the platform text as well (see the other thread).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marked fixed.

}

fn notice(latest: &str, windows: bool) -> String {
Comment on lines +146 to +149

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning · CI misses regressions to Unix-only update notices on Windows

The routing assertions use the test runner’s platform. Only Ubuntu runs them in CI; the Windows smoke job never checks a cached update notice.

CI stays green if suggestion() always selects Unix wording.

Run windows_notices_point_to_the_manual_steps in the Windows CI job.

A person accepted this risk earlier. It is posted again because it cites new evidence: src/update/tests.rs lines 213–221 (not cited before).

View finding in Proofline

Also at:

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accept risk

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepted as a risk.

if windows {
format!("proofline {latest} is available; 'proofline update' shows how to install it")
} else {
format!("proofline {latest} is available; run 'proofline update'")
}
}

/// The README's verified manual update: self-update cannot replace a Windows
/// binary, and Windows has no Unix installer directory to check.
/// `latest` is the cached version the notice announced; its pinned downloads
/// exist before GitHub marks that release as the latest one.
fn windows_steps(executable: Option<&Path>, latest: Option<&str>) -> String {
const ARCHIVE: &str = "proofline-x86_64-pc-windows-msvc.tar.gz";
let download = latest.map_or_else(
|| {
Comment on lines +161 to +164

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning · Windows update recommends an unusable executable on 32-bit Windows

On 32-bit Windows, proofline update tells users to replace a working source build with the x86-64 release without checking OS compatibility.

Users who follow the guide can no longer run proofline until they restore a compatible build.

Recommend the archive only when Windows can run it; otherwise direct users to rebuild from source.

View finding in Proofline

// No newer version is known, so this may already be the newest one.
format!(
"{ARCHIVE} and SHA256SUMS from https://github.com/prooflinedev/cli/releases/latest \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning · Windows update steps can reinstall an older release

If a browser renames duplicate downloads, the Windows guide still hashes and extracts the unsuffixed archive and checks the unsuffixed SHA256SUMS.

An older matching pair can pass verification and install the older executable even with an empty extraction folder.

Download both files into a fresh directory and use those exact paths for verification and extraction.

View finding in Proofline

(stop if that release is not newer than this proofline {})",
env!("CARGO_PKG_VERSION")
)
},
|version| {
let release = format!("{RELEASES}/download/{version}");
format!("{release}/{ARCHIVE} and {release}/SHA256SUMS")
},
);
let executable = executable.map_or_else(
|| "the proofline.exe you ran (find it with '(Get-Command proofline).Source')".to_owned(),
|path| path.display().to_string(),
);
format!(
"'proofline update' cannot replace proofline.exe on Windows; update it by hand:\n \
1. Close every running Proofline process.\n \
2. Download {download}\n \
3. Run 'Get-FileHash -Algorithm SHA256 {ARCHIVE}' and check that the hash matches the archive's line in SHA256SUMS.\n \
4. Create an empty folder with 'mkdir proofline-new' (choose another name if it already exists).\n \
5. Extract into it with 'tar -xzf {ARCHIVE} -C proofline-new'.\n \
Comment on lines +186 to +187

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning · Windows update tests miss regressions that reuse a staging folder

The unit test checks mkdir and tar independently, and the CLI test checks only the extraction destination.

Both tests still pass if the collision warning disappears or directory creation and extraction become one unconditional command.

Assert that the guidance requires an empty folder, tells users to choose another name on collision, and puts extraction in a separate subsequent step.

View finding in Proofline

6. Only if that succeeded, replace {executable} with proofline-new\\proofline.exe."
Comment on lines +186 to +188

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Serious · Windows update can overwrite files in the existing staging folder

Step 4 tells users to choose another folder if proofline-new exists, but steps 5 and 6 still use proofline-new.

Copying the printed tar command can overwrite files in the existing folder and leave the new folder unused.

Store the chosen folder in a PowerShell variable and use it for both extraction and the replacement source.

View finding in Proofline

)
}

fn prepare_check(
Expand Down Expand Up @@ -422,6 +465,16 @@ fn replace(archive: &[u8], destination: &Path) -> anyhow::Result<()> {

/// Updates an official installer location after verifying the pinned archive.
pub(crate) async fn install() -> anyhow::Result<()> {
if cfg!(target_os = "windows") {
let latest = cache_path()
.and_then(|path| read_cache(&path).ok())
.and_then(|cache| cache.latest)
.filter(|latest| newer(latest));
bail!(windows_steps(
std::env::current_exe().ok().as_deref(),
latest.as_deref()
));
}
let (destination, target) =
tokio::task::spawn_blocking(|| Ok::<_, anyhow::Error>((destination()?, target()?)))
.await??;
Expand Down
56 changes: 54 additions & 2 deletions src/update/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,58 @@ fn notices_are_suppressed_for_machine_and_hook_commands() {
assert!(suggestion(&cache, &["status".into()], true).is_some());
}

#[test]
fn windows_notices_point_to_the_manual_steps() {
assert_eq!(
notice("9.0.0", false),
"proofline 9.0.0 is available; run 'proofline update'"
);
let windows = notice("9.0.0", true);
assert!(
windows.starts_with("proofline 9.0.0 is available;"),
"{windows}"
);
assert!(
windows.contains("'proofline update' shows how"),
"{windows}"
);
// `suggestion` itself must pick the wording of the platform it runs on.
let cache = Cache {
checked: now(),
latest: Some("9.0.0".to_owned()),
};
assert_eq!(
suggestion(&cache, &["status".into()], true).unwrap(),
notice("9.0.0", cfg!(target_os = "windows"))
);
let steps = windows_steps(Some(Path::new(r"C:\tools\proofline.exe")), Some("9.0.0"));
for expected in [
"Close every running Proofline process",
"https://proofline.sh/cli/download/9.0.0/proofline-x86_64-pc-windows-msvc.tar.gz",
"https://proofline.sh/cli/download/9.0.0/SHA256SUMS",
"Get-FileHash -Algorithm SHA256 proofline-x86_64-pc-windows-msvc.tar.gz",
"mkdir proofline-new",
"tar -xzf proofline-x86_64-pc-windows-msvc.tar.gz -C proofline-new",
r"replace C:\tools\proofline.exe with proofline-new\proofline.exe",
] {
assert!(
steps.contains(expected),
"{expected:?} missing from {steps}"
);
}
let unknown = windows_steps(None, None);
for expected in [
"from https://github.com/prooflinedev/cli/releases/latest",
"(Get-Command proofline).Source",
concat!("not newer than this proofline ", env!("CARGO_PKG_VERSION")),
] {
assert!(
unknown.contains(expected),
"{expected:?} missing from {unknown}"
);
}
}

// This same test executable supplies a real child fixture. All endpoint and
// fixture-mode injection lives in cfg(test), never in the customer binary.
#[tokio::test]
Expand Down Expand Up @@ -294,7 +346,7 @@ async fn detached_discovery_is_serialized_and_notices_arrive_on_the_next_invocat
assert!(
!String::from_utf8(output.stdout)
.unwrap()
.contains("run 'proofline update'")
.contains(" is available;")
);
}
tokio::time::timeout(Duration::from_secs(5), async {
Expand Down Expand Up @@ -322,7 +374,7 @@ async fn detached_discovery_is_serialized_and_notices_arrive_on_the_next_invocat
assert!(
String::from_utf8(output.stdout)
.unwrap()
.contains("run 'proofline update'")
.contains(&notice("9.0.0", cfg!(target_os = "windows")))
Comment on lines 374 to +377

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning · Tests miss a Windows notice that promises automatic updates

The discovery test uses notice() to generate its expected text, and the wording test checks only fragments that stop short of the installation guidance.

Both tests can pass if the Windows notice incorrectly promises automatic installation.

Assert the full Windows notice against a fixed expected string, independent of notice().

View finding in Proofline

);
assert_eq!(received.load(Ordering::SeqCst), 1);
server.abort();
Expand Down
81 changes: 81 additions & 0 deletions tests/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,84 @@ fn cached_update_preserves_schema_help_and_source_installation() {
b"keep this installed CLI"
);
}

// Windows binaries are installed by hand (README "Windows installation"), so
// `update` must explain those steps instead of failing on Unix installer paths.
#[cfg(windows)]
#[test]
fn windows_update_explains_the_manual_steps() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning · PR checks skip the Windows update integration test

The Ubuntu test job excludes windows_update_explains_the_manual_steps, and the Windows job runs neither the test nor proofline update.

Removing the Windows early return can leave PR checks green while Windows users get installer errors instead of manual update instructions.

Run cargo test --locked --test update windows_update_explains_the_manual_steps in the Windows job.

Details

The helper test checks the instruction text directly, so it still passes if install stops calling windows_steps.

View finding in Proofline

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partly agree, no change in this PR. It's true that CI never runs cargo test on Windows, and the test is #[cfg(windows)], so Ubuntu never compiles it. But the README asks outside contributors to open an issue for workflow changes, not a PR. I'll raise it in a separate CI issue, together with the other Windows-only failures (C-1, the mcp SYSTEMROOT tests). On your detail: the integration test runs the real binary, so on Windows it does fail if install stops calling windows_steps. I ran it locally (RED on main, GREEN here). It just isn't run by CI yet.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proofline recorded no decision on this finding. To record one, reply with only fixed, dismiss, accept risk or confirm.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accept risk

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepted as a risk.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning · PR checks skip the Windows update regression test

Ubuntu excludes the Windows-only integration test, and Windows CI only builds and smoke-tests unrelated commands.

Removing the Windows early return from install() would leave PR checks green for both cached and uncached updates.

Run cargo test --locked --target x86_64-pc-windows-msvc --test update windows_update_explains_the_manual_steps in the Windows job.

View finding in Proofline

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accept risk

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepted as a risk.

let directory = tempfile::tempdir().unwrap();
let installed = directory.path().join("bin").join("proofline.exe");
std::fs::create_dir_all(installed.parent().unwrap()).unwrap();
std::fs::copy(env!("CARGO_BIN_EXE_proofline"), &installed).unwrap();
let before = std::fs::read(&installed).unwrap();
let cache = directory.path().join("proofline").join("update.json");
std::fs::create_dir_all(cache.parent().unwrap()).unwrap();
let checked = SystemTime::now()
.duration_since(UNIX_EPOCH)
Comment on lines +65 to +68

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning · Windows update tests miss stale cached versions

The CLI fixture tests only a missing cache or a newer version, and the helper test bypasses install(). Both would pass without the newer filter.

Windows update could recommend an older or equal release without the version warning, and these tests would still pass.

Add a CLI case caching the running version and assert that stderr gives the fallback URL and version warning, not a pinned download.

View finding in Proofline

.unwrap()
.as_secs();
// Without a cached newer version the steps name the GitHub page; with
// one they pin the downloads to the version the notice announced.
for (home, cached, download) in [
(
None,
false,
Comment on lines +73 to +76

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning · Windows update test misses downgrade guidance from an older cache

The Windows CLI test covers an empty cache and a newer cached release, so removing the newer() filter leaves both outcomes unchanged.

The test would still pass if proofline update offered pinned download links for an older cached release.

Seed an older cached version and assert that stderr shows the guarded fallback and no pinned links for that version.

View finding in Proofline

"https://github.com/prooflinedev/cli/releases/latest",
),
(
Some(directory.path()),
false,
"https://github.com/prooflinedev/cli/releases/latest",
),
(
None,
true,
"https://proofline.sh/cli/download/9.0.0/proofline-x86_64-pc-windows-msvc.tar.gz",
),
] {
if cached {
std::fs::write(
&cache,
format!("{{\"checked\":{checked},\"latest\":\"9.0.0\"}}"),
)
.unwrap();
}
let mut command = Command::new(&installed);
command
.arg("update")
.env("PROOFLINE_NO_UPDATE_CHECK", "1")
.env("LOCALAPPDATA", directory.path())
.env_remove("PROOFLINE_INSTALL_DIR")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning · Windows update test fails when the temporary path contains HOME

The test requires stderr to include the executable path but rejects any occurrence of HOME, including within that path.

Correct manual update instructions fail the test under a temporary directory containing HOME.

Check for the specific installer diagnostic set HOME or PROOFLINE_INSTALL_DIR instead.

View finding in Proofline

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 92a28dd. The check is now !stderr.contains("set HOME or PROOFLINE_INSTALL_DIR"), the exact old error, so a temporary path containing HOME can't make it fail.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marked fixed.

.env_remove("HOME");
if let Some(home) = home {
command.env("HOME", home);
}
let update = command.output().unwrap();
assert!(!update.status.success());
assert!(update.stdout.is_empty());
let stderr = String::from_utf8(update.stderr).unwrap();
for expected in [
download,
"proofline-x86_64-pc-windows-msvc.tar.gz",
"SHA256SUMS",
"Get-FileHash -Algorithm SHA256",
"-C proofline-new",
&installed.display().to_string(),
] {
assert!(
stderr.contains(expected),
"{expected:?} missing from {stderr}"
);
}
assert!(
!stderr.contains("set HOME or PROOFLINE_INSTALL_DIR"),
"{stderr}"
);
assert!(
!stderr.contains("outside the installer directory"),
"{stderr}"
);
}
assert_eq!(std::fs::read(&installed).unwrap(), before);
}