-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: optionally collect parsing errors
- Loading branch information
Showing
8 changed files
with
75 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use core::str; | ||
use std::path::{Path, PathBuf}; | ||
|
||
use assert_cmd::Command; | ||
|
||
fn main() { | ||
parse_errors(); | ||
} | ||
|
||
fn parse_errors() { | ||
let profile = if cfg!(debug_assertions) { | ||
"debug" | ||
} else { | ||
"release" | ||
}; | ||
|
||
let cargo_folder = Path::new(env!("CARGO_MANIFEST_DIR")); | ||
let mut sqruff_path = PathBuf::from(cargo_folder); | ||
sqruff_path.push(format!("../../target/{}/sqruff", profile)); | ||
|
||
// STDIN - do nothing | ||
let mut cmd = Command::new(sqruff_path.clone()); | ||
cmd.env("HOME", PathBuf::from(env!("CARGO_MANIFEST_DIR"))); | ||
cmd.arg("fix") | ||
.arg("-f") | ||
.arg("human") | ||
.arg("--parsing-errors") | ||
.arg("-"); | ||
cmd.current_dir(cargo_folder); | ||
cmd.write_stdin("SelEc"); | ||
|
||
let assert = cmd.assert(); | ||
let output = assert.get_output(); | ||
|
||
let stdout_str = str::from_utf8(&output.stdout).unwrap(); | ||
let stderr_str = str::from_utf8(&output.stderr).unwrap(); | ||
assert_eq!(stdout_str, "SelEc\n\n"); | ||
assert_eq!(stderr_str, "== [<string>] FAIL\nL: 1 | P: 1 | ???? | Unparsable section\nL: 1 | P: 1 | LT12 | Files must end with a single trailing newline.\n | [layout.end_of_file]\n"); | ||
assert_eq!(output.status.code().unwrap(), 1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters