Repository navigation
Description
Summary
tests/cli_exit_status.rs on master uses env!("CARGO_BIN_EXE_jcode"), but
the root package's binary target is named kcode (Cargo.toml:
[lib]
name = "jcode"
path = "src/lib.rs"
[[bin]]
name = "kcode"
path = "src/main.rs"
cargo sets CARGO_BIN_EXE_<NAME> per BIN TARGET NAME. Because the
library target is jcode and the binary target is kcode, the variable
CARGO_BIN_EXE_jcode is not defined at compile time. The "Quality
Guardrails" CI job ("Check all targets and all features") currently fails
with:
error: environment variable CARGO_BIN_EXE_jcode not defined at compile time
at tests/cli_exit_status.rs:6:31
Root cause
The fork renamed the jcode binary to kcode, but this test was missed
during the decollision. All other integration tests in the repo already
use the correct spelling (tests/e2e/binary_integration.rs,
tests/api_stdio_cli.rs, tests/e2e/windows_lifecycle.rs, etc.) — they
reference env!("CARGO_BIN_EXE_kcode"). Only this one test still references
the old name.
The same file also carries fork-residue for JCODE_HOME (the fork uses
KCODE_HOME; see crates/jcode-storage/src/lib.rs::jcode_dir) and for the
CLI banner (src/cli/args.rs:30 declares #[command(name = "kcode")], so
the version banner starts with "kcode ").
Why the previous attempt (PR #129) was wrong
PR #129 changed env!("CARGO_BIN_EXE_jcode") to
std::env::var("CARGO_BIN_EXE_jcode").expect("CARGO_BIN_EXE_jcode"). That
will fail at runtime with "environment variable not found", because
CARGO_BIN_EXE_* is a compile-time variable cargo provides to integration
test targets, not a runtime environment variable.
The correct fix is to use the correct variable name and keep it as a
compile-time env!():
let output = Command::new(env!("CARGO_BIN_EXE_kcode"))Fix branch / PR
- Branch:
fix/cli-exit-status-kcode-bin(based onorigin/master) - Repo: KooshaPari/KCode
- A PR superseding PR fix(ci): clear repo-wide rustfmt drift + env! macro in cli_exit_status #129 for this file is opened alongside this issue.
Out-of-scope observation (separate issue, do NOT bundle)
While validating on macOS, I observed src/main.rs::run_main invokes
self_heal_macos_code_signature() unconditionally at startup; that function
shells out to /usr/bin/xattr and codesign, whose stderr propagates into
the spawned process's captured stderr and breaks the
output.stderr.is_empty() assertion in two of the four tests in this file
(help_exits_successfully_on_stdout and version_exits_successfully_on_stdout).
This is a separate fork-introduced macOS stderr leak unrelated to the
bin-target rename and is intentionally left out of scope for the PR that
fixes this issue.
Activity