| 1 | //! Running afs-ld with no inputs must produce the exact diagnostic line |
| 2 | //! `afs-ld: error: no input files` on stderr and exit with code 2. |
| 3 | //! |
| 4 | //! The CLI surface grows over the next sprints but this invariant is the |
| 5 | //! baseline every later change must preserve. |
| 6 | |
| 7 | use std::process::Command; |
| 8 | |
| 9 | #[test] |
| 10 | fn empty_invocation_produces_no_input_files_diagnostic() { |
| 11 | let exe = env!("CARGO_BIN_EXE_afs-ld"); |
| 12 | let out = Command::new(exe) |
| 13 | .output() |
| 14 | .expect("afs-ld binary should exist and be executable"); |
| 15 | |
| 16 | assert!(!out.status.success(), "afs-ld should fail on empty input"); |
| 17 | assert_eq!( |
| 18 | out.status.code(), |
| 19 | Some(2), |
| 20 | "empty-input exit code must be 2 (CLI misuse / missing input)" |
| 21 | ); |
| 22 | |
| 23 | let stderr = String::from_utf8_lossy(&out.stderr); |
| 24 | assert!( |
| 25 | stderr.contains("afs-ld: error: no input files"), |
| 26 | "expected the `no input files` diagnostic on stderr; got: {stderr}" |
| 27 | ); |
| 28 | } |
| 29 |