From 2b0d8a4c105ce1c3eac31d574f8fd999027cde44 Mon Sep 17 00:00:00 2001 From: Hamza Date: Thu, 29 Oct 2026 13:53:11 +0500 Subject: [PATCH] test(cli): don't assert the operating system's wording for a missing file Review caught a test that cannot pass on Windows: it asserted the error for `validate-pdf --nope` contains "No such file", which is the unix phrasing. Windows says "The system cannot find the file specified", so the assertion failed there even when the command refused the path correctly -- the same mistake as the `\\?\C:\` one on #1909, and in a test whose point is to run everywhere. It asserts the error names the path; `failed()` already checks the exit code and the stream. The companion check that a ` --help` run did not open a file now looks for either operating system's wording, so it catches that on Windows too rather than only on unix. --- apps/designcraft-cli/tests/it/args.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/designcraft-cli/tests/it/args.rs b/apps/designcraft-cli/tests/it/args.rs index bbbde4867..7c27a8e8e 100644 --- a/apps/designcraft-cli/tests/it/args.rs +++ b/apps/designcraft-cli/tests/it/args.rs @@ -153,7 +153,9 @@ fn every_subcommand_answers_help_without_running_anything() { // None of the work the rest of the line asks for was done. assert!(!png.exists(), "{what} exported a file"); assert!(!out.contains("cannot connect") && !out.contains("render threads"), "{what}: {out:?}"); - assert!(!out.contains("No such file"), "{what}: {out:?}"); + // Either operating system's wording, so this catches a file the help path opened on + // Windows as well as on unix. + assert!(!out.contains("No such file") && !out.contains("cannot find the file"), "{what}: {out:?}"); } } // `script`'s own help is longer than one usage line: it documents the script syntax, which is @@ -193,7 +195,11 @@ fn the_subcommands_that_take_a_word_read_an_unknown_option_as_that_word() { assert!(err.contains("no command `--nope`"), "{err:?}"); // A path nobody has. let err = run(&["validate-pdf", "--nope"]).failed("validate-pdf --nope"); - assert!(err.contains("--nope") && err.contains("No such file"), "{err:?}"); + // The error names the path. Not the operating system's wording for a missing file: Windows + // says "The system cannot find the file specified", so asserting the Unix phrasing failed + // there even when the command refused correctly (noted in review). `failed` already checks + // the exit code and the stream. + assert!(err.contains("--nope"), "{err:?}"); // A method name for the running app, so the error is about reaching the app. let dead = closed_port(); let err = run(&["app", "--port", &dead, "--nope"]).failed("app --nope");