From 07634d9390f2c416171030de6ba2bb30075972c5 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Wed, 16 Nov 2016 21:37:43 -0800 Subject: [PATCH] Fix line numbers (#124) Blank lines were being ignored by the parser, so lines would be reported incorrectly in error messages from shebang recipes. Blank lines are now included by the parser, so shebang recipes expand to have the non-blank lines in the expected place in the file. --- src/integration.rs | 35 +++++++++++++++++++++++++++++++++++ src/lib.rs | 8 +++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/integration.rs b/src/integration.rs index 47cf78a..5810571 100644 --- a/src/integration.rs +++ b/src/integration.rs @@ -1274,6 +1274,41 @@ fn quiet_shebang_recipe() { ); } +#[test] +fn shebang_line_numbers() { + integration_test( + &[], + r#" +quiet: + #!/usr/bin/env cat + + a + + b + + + c + + +"#, + 0, + "#!/usr/bin/env cat + + + +a + +b + + +c + + +", + "", + ); +} + #[test] fn complex_dependencies() { integration_test( diff --git a/src/lib.rs b/src/lib.rs index 0f61973..8283ef9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -394,6 +394,11 @@ impl<'a> Recipe<'a> { if quiet_command { command = &command[1..]; } + + if command == "" { + continue; + } + if options.dry_run || options.verbose || !((quiet_command ^ self.quiet) || options.quiet) { @@ -1318,7 +1323,7 @@ impl<'a> Display for RunError<'a> { write!(f, "Recipe `{}` failed with exit code {}", recipe, code)?; }, Signal{recipe, signal} => { - write!(f, "Recipe `{}` wast terminated by signal {}", recipe, signal)?; + write!(f, "Recipe `{}` was terminated by signal {}", recipe, signal)?; } UnknownFailure{recipe} => { write!(f, "Recipe `{}` failed for an unknown reason", recipe)?; @@ -1886,6 +1891,7 @@ impl<'a> Parser<'a> { if self.accepted(Indent) { while !self.accepted(Dedent) { if self.accepted(Eol) { + lines.push(vec![]); continue; } if let Some(token) = self.expect(Line) {