-
Notifications
You must be signed in to change notification settings - Fork 228
test(docs): add tests for examples in website hero and repo README #2710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Wow, it seems the new test to have suddenly discovered an error in the README example! $ cargo run -p prqlc compile
Compiling prql-compiler v0.8.1 (/workspaces/prql/prql-compiler)
Compiling prqlc v0.8.1 (/workspaces/prql/prql-compiler/prqlc)
Finished dev [unoptimized + debuginfo] target(s) in 41.87s
Running `target/debug/prqlc compile`
Enter PRQL, then press ctrl-d to compile:
from employees
filter country == "USA" # Each line transforms the previous result
aggregate { # `aggregate` reduces each column to a value
max salary,
min salary,
count, # Trailing commas are allowed
}
Error:
╭─[Root.prql:6:3]
│
6 │ count, # Trailing commas are allowed
│ ──┬──
│ ╰──── function std.aggregate, param `columns` expected type `scalar`, but found type `array -> int`
│
│ Help: Have you forgotten an argument to function std.count?
│
│ Note: Type `scalar` expands to `int || float || bool || text || date || time || timestamp || null`
───╯ @aljazerzen Any thoughts? |
Yeah, I changed |
It seems that the default argument used to be set to
|
I needed it like that because I was changing how types work, and when a function is deemed a window function. It's an implementation thing. |
let re = Regex::new(r"(?s)```(elm|prql)\n(?P<prql>.+?)\n```").unwrap(); | ||
assert_ne!(re.find_iter(&contents).count(), 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clever regex-ing!
In a way this is similar to
prql/web/book/tests/snapshot.rs
Line 152 in 65706a1
fn collect_book_examples() -> Result<Vec<Example>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a comment with a ref
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was initially thinking of code block analysis using pulldown-cmark
, but changed because it seemed like overkill. (And extracting code blocks with pulldown-cmark
was too difficult for me!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I def think writing another parser wouldn't be great!
This code is a very good balance IMO
@@ -0,0 +1,75 @@ | |||
use prql_compiler::Options; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW Rust unfortunately has poor performance with making lots of test binaries. So it would be faster if we could have this as a file within this test https://github.com/PRQL/prql/blob/65706a115a84997c608eaeda38b1aef1240fcec3/web/book/tests/snapshot.rs (which would change to a module, like this file is)
See the link at
prql/prql-compiler/tests/integration/README.md
Lines 54 to 55 in f4eb8c7
We follow the advice in | |
<https://matklad.github.io/2021/02/27/delete-cargo-integration-tests.html>. |
(but we can merge this and make the change / I'll make the change, I don't want to slow you down!)
Co-authored-by: Maximilian Roos <[email protected]>
This PR renames the website tests to docs tests and adds more tests for examples in docs.