Skip to content

Commit 4a9862f

Browse files
committed
test: Integration test failures easier to understand
Shows the input in the case of a failure (e.g. PRQL#2601)
1 parent 6465777 commit 4a9862f

26 files changed

+36
-40
lines changed

bacon.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ need_stdout = false
4040
# If the doc compiles, then it opens in your browser and bacon switches
4141
# to the previous job
4242
[jobs.doc-open]
43-
command = ["cargo", "doc", "--color", "always", "--no-deps", "--open"]
44-
need_stdout = false
43+
command = ["cargo", "doc", "--color", "always", "--no-deps", "--open"]
44+
need_stdout = false
4545
on_success = "back" # so that we don't open the browser at each change
4646

4747
# You may define here keybindings that would be specific to
@@ -53,7 +53,7 @@ a = "job:check-all"
5353
c = "job:clippy"
5454
d = "job:doc-open"
5555
f = "job:test-fast"
56-
# `g` for standard carGo tests
56+
# `g` for standard cargo tests
5757
g = "job:test-cargo"
5858
r = "job:run"
5959
t = "job:test"

prql-compiler/tests/integration/main.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ fn compile(prql: &str) -> Result<String, prql_compiler::ErrorMessages> {
3636
fn test_sql_examples() {
3737
glob!("queries/**/*.prql", |path| {
3838
let sql = fs::read_to_string(path).unwrap();
39-
assert_snapshot!(
40-
path.file_name().unwrap().to_string_lossy().to_string(),
41-
compile(&sql).unwrap(),
42-
&sql
43-
)
39+
assert_snapshot!("sql", compile(&sql).unwrap(), &sql)
4440
});
4541
}
4642

@@ -56,7 +52,7 @@ fn test_rdbms() {
5652
// for each of the queries
5753
glob!("queries/**/*.prql", |path| {
5854
let test_name = path
59-
.file_name()
55+
.file_stem()
6056
.and_then(|s| s.to_str())
6157
.unwrap_or_default();
6258

@@ -98,7 +94,7 @@ fn test_rdbms() {
9894
for row in first_result.1 {
9995
writeln!(&mut result_string, "{}", row.join(",")).unwrap_or_default();
10096
}
101-
assert_snapshot!(result_string);
97+
assert_snapshot!("results", result_string, &prql);
10298
});
10399
}
104100

prql-compiler/tests/integration/snapshots/[email protected]

Lines changed: 0 additions & 12 deletions
This file was deleted.

prql-compiler/tests/integration/snapshots/integration__rdbms@set_ops_remove.prql.snap

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: prql-compiler/tests/integration/main.rs
3-
expression: result_string
3+
expression: "from tracks\nsort [-bytes]\nselect [\n name,\n bin = ((album_id | as REAL) * 99)\n]\ntake 20\n"
44
input_file: prql-compiler/tests/integration/queries/cast.prql
55
---
66
Through a Looking Glass,22671
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: prql-compiler/tests/integration/main.rs
3-
expression: result_string
3+
expression: "from tracks\nselect [album_id, genre_id]\ngroup tracks.* (take 1)\nsort tracks.*\n"
44
input_file: prql-compiler/tests/integration/queries/distinct.prql
55
---
66
1,1

prql-compiler/tests/integration/snapshots/integration__rdbms@genre_counts.prql.snap renamed to prql-compiler/tests/integration/snapshots/integration__results@genre_counts.prql.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: prql-compiler/tests/integration/main.rs
3-
expression: result_string
3+
expression: "let genre_count = (\n from genres\n aggregate a = count\n)\n\nfrom genre_count\nfilter a > 0\nselect a = -a\n"
44
input_file: prql-compiler/tests/integration/queries/genre_counts.prql
55
---
66
-25

prql-compiler/tests/integration/snapshots/integration__rdbms@group_all.prql.snap renamed to prql-compiler/tests/integration/snapshots/integration__results@group_all.prql.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: prql-compiler/tests/integration/main.rs
3-
expression: result_string
3+
expression: "from a=albums\ntake 10\njoin tracks [==album_id]\ngroup [a.album_id, a.title] (aggregate price = ((sum tracks.unit_price)))\nsort album_id\n"
44
input_file: prql-compiler/tests/integration/queries/group_all.prql
55
---
66
1,For Those About To Rock We Salute You,9.9

prql-compiler/tests/integration/snapshots/integration__rdbms@group_sort.prql.snap renamed to prql-compiler/tests/integration/snapshots/integration__results@group_sort.prql.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: prql-compiler/tests/integration/main.rs
3-
expression: result_string
3+
expression: "from tracks\nderive d = album_id + 1\ngroup d (\n aggregate [\n n1 = (track_id | sum),\n ]\n)\nsort d\ntake 10\nselect [ d1 = d, n1 ]\n"
44
input_file: prql-compiler/tests/integration/queries/group_sort.prql
55
---
66
2,91

prql-compiler/tests/integration/snapshots/integration__rdbms@invoice_totals.prql.snap renamed to prql-compiler/tests/integration/snapshots/integration__results@invoice_totals.prql.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: prql-compiler/tests/integration/main.rs
3-
expression: result_string
3+
expression: "# skip_mssql (error: The function 'LAG' may not have a window frame.)\nfrom i=invoices\njoin ii=invoice_items [==invoice_id]\nderive [\n city = i.billing_city,\n street = i.billing_address,\n]\ngroup [city, street] (\n aggregate [\n num_orders = s\"COUNT(DISTINCT {i.invoice_id})\",\n num_tracks = sum ii.quantity,\n total_price = sum (ii.unit_price * ii.quantity),\n ]\n)\ngroup [city] (\n sort street\n window expanding:true (\n derive [running_total_num_tracks = sum num_tracks]\n )\n)\nsort city\nderive [num_tracks_last_week = lag 7 num_tracks]\nselect [\n city,\n street,\n num_orders,\n num_tracks,\n running_total_num_tracks,\n num_tracks_last_week\n]\ntake 20\n"
44
input_file: prql-compiler/tests/integration/queries/invoice_totals.prql
55
---
66
Amsterdam,Lijnbaansgracht 120bg,7,38,38,

0 commit comments

Comments
 (0)