Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ If you have [Nix](https://nixos.org/download/) with flakes enabled, `nix develop
| `nix flake check` | formatting, plus the flake's own version assertions |
| `nix run .#lint-rust` | `cargo fmt --check` and `cargo clippy` |
| `nix run .#test-rust` | the Rust test suites |
| `nix run .#test-sql -- <name>` | run a single [SQL test file](./tests/sql_test_files/README.md) |
| `nix run .#test-browser` | the Playwright suites |
| `nix run .#test-examples` | one example's Hurl suite |
| `nix build .#odbc-drivers` | an `odbcinst.ini`; point `ODBCSYSINI` at it for the ODBC tests |
Expand Down
9 changes: 9 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,15 @@
'';
};

test-sql = {
description = "Run the SQL test file or files";
packages = cargoRuntime pkgs;
env = cargoEnv pkgs;
script = buildBrowserAssets + ''
SQL_TEST_FILE="''${1:-}" cargo test --test mod sql_test_files
'';
};

test-browser = {
description = "Drive the components in a browser with Playwright";
packages = cargoRuntime pkgs;
Expand Down
10 changes: 9 additions & 1 deletion tests/sql_test_files/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,12 @@ engine-specific SQL syntax) live in a subdirectory named after that database
(`sqlite`, `postgres`, `mysql`, `mssql`, `oracle`, `duckdb`, `snowflake`,
`generic`). They are run by a separate test, only when the current database
matches. Unlike the other directories, their file names do not need `_no...`
suffixes to exclude incompatible backends.
suffixes to exclude incompatible backends.

## Running one file

`SQL_TEST_FILE` limits a run to the files whose path contains its value. The `test-sql` gate sets it from its argument:

```bash
DATABASE_URL='postgres://root:Password123!@127.0.0.1/sqlpage' nix run .#test-sql -- money_with_parameters_983
```
4 changes: 4 additions & 0 deletions tests/sql_test_files/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,16 @@ fn read_sql_tests_in_dir(dir: &str, format: SqlTestFormat) -> Vec<SqlTestCase> {
let Ok(entries) = std::fs::read_dir(dir) else {
return Vec::new(); // no tests in this directory (e.g. no database-specific tests for this database)
};
let selected_name = std::env::var("SQL_TEST_FILE").unwrap_or_default();
entries
.filter_map(|e| {
let path = e.ok()?.path();
if path.is_dir() || path.extension()? != "sql" {
return None;
}
if !path.to_string_lossy().contains(&selected_name) {
return None;
}
Some(SqlTestCase { path, format })
})
.collect()
Expand Down
Loading