Skip to content

Commit

Permalink
fix: Improve error message when no .prql files exist (#4424)
Browse files Browse the repository at this point in the history
  • Loading branch information
max-sixty authored Apr 28, 2024
1 parent 3bf2a42 commit c64a53e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions prqlc/prqlc/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ fn linearize_tree(tree: &SourceTree) -> Result<Vec<SourceFile>> {
} else if let Some(root) = tree.sources.keys().find(path_starts_with_uppercase) {
root_path = root;
} else {
if tree.sources.is_empty() {
// TODO: should we allow non `.prql` files? We could require `.prql`
// for modules but then allow any file if a single file is passed
// (python allows this, for example)
return Err(Error::new_simple(
"No `.prql` files found in the source tree",
));
}

let file_names = tree
.sources
.keys()
Expand Down
13 changes: 13 additions & 0 deletions prqlc/prqlc/tests/integration/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,3 +458,16 @@ fn normalize_prqlc(cmd: &mut Command) -> &mut Command {
.env_remove("RUST_BACKTRACE")
.env_remove("RUST_LOG")
}

#[test]
fn compile_no_prql_files() {
assert_cmd_snapshot!(prqlc_command().args(["compile", "README.md"]), @r###"
success: false
exit_code: 1
----- stdout -----
----- stderr -----
Error: No `.prql` files found in the source tree
"###);
}

0 comments on commit c64a53e

Please sign in to comment.