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.
This commit is contained in:
parent
2f4bcc57bc
commit
07634d9390
@ -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]
|
#[test]
|
||||||
fn complex_dependencies() {
|
fn complex_dependencies() {
|
||||||
integration_test(
|
integration_test(
|
||||||
|
@ -394,6 +394,11 @@ impl<'a> Recipe<'a> {
|
|||||||
if quiet_command {
|
if quiet_command {
|
||||||
command = &command[1..];
|
command = &command[1..];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if command == "" {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if options.dry_run
|
if options.dry_run
|
||||||
|| options.verbose
|
|| options.verbose
|
||||||
|| !((quiet_command ^ self.quiet) || options.quiet) {
|
|| !((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)?;
|
write!(f, "Recipe `{}` failed with exit code {}", recipe, code)?;
|
||||||
},
|
},
|
||||||
Signal{recipe, signal} => {
|
Signal{recipe, signal} => {
|
||||||
write!(f, "Recipe `{}` wast terminated by signal {}", recipe, signal)?;
|
write!(f, "Recipe `{}` was terminated by signal {}", recipe, signal)?;
|
||||||
}
|
}
|
||||||
UnknownFailure{recipe} => {
|
UnknownFailure{recipe} => {
|
||||||
write!(f, "Recipe `{}` failed for an unknown reason", recipe)?;
|
write!(f, "Recipe `{}` failed for an unknown reason", recipe)?;
|
||||||
@ -1886,6 +1891,7 @@ impl<'a> Parser<'a> {
|
|||||||
if self.accepted(Indent) {
|
if self.accepted(Indent) {
|
||||||
while !self.accepted(Dedent) {
|
while !self.accepted(Dedent) {
|
||||||
if self.accepted(Eol) {
|
if self.accepted(Eol) {
|
||||||
|
lines.push(vec![]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if let Some(token) = self.expect(Line) {
|
if let Some(token) = self.expect(Line) {
|
||||||
|
Loading…
Reference in New Issue
Block a user