On stage #PN5, if a program is implemented so that it says exit: command not found
when an exit command is issued, the tester logs say this:
[tester::#PN5] Running tests for Stage #PN5 (The exit builtin)
[tester::#PN5] Running ./your_program.sh
[your-program] $ invalid_orange_command
[your-program] invalid_orange_command: command not found
[tester::#PN5] ✓ Received command not found message
[your-program] $ exit 0
[tester::#PN5] Error reading output: condition not met
[tester::#PN5] Test failed (try setting 'debug: true' in your codecrafters.yml to see more details)
Screenshot w/ colored logs:
Here’s what I get when running my program locally and executing the same command:
Here’s a snippet of my code:
use std::io::{self, Write};
fn main() {
loop {
print!("$ ");
io::stdout().flush().unwrap();
let mut input = String::new();
io::stdin().read_line(&mut input).unwrap();
input = input.trim().to_string();
let command_with_args = input.split_whitespace().collect::<Vec<&str>>();
let command = command_with_args[0];
let args = command_with_args[1..].to_vec();
if input == "exit" {
break;
}
println!("{}: command not found", command);
}
}
The fix is simple (change input == "exit"
to command == "exit"
), but the tester message is pretty confusing. Instead of “condition not met”, I’d expect:
- (a) a message indicating that the program was expected to exit but it didn’t.
- (b) the rest of my program’s output, i.e. the second prompt to be printed so that I know what it did wrong