sqlx/tests/ui-tests.rs
依云 5b8bb3b28b
Add a "sqlite-unbundled" feature that dynamically links to system libsqlite3.so library (#3507)
* Add a "sqlite-unbundled" feature that dynamically links to system libsqlite3.so library

* update README abouot the newly-added `sqlite-unbundled` feature

* Update README.md to make it clear with bulleted list

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>

* more cfg feature updates

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>

* update documentation in sqlx-sqlx/src/lib.rs too

and also mention possible build time increasement.

* cargo fmt

* Add "sqlite-unbundled" feature to sqlx-cli

* Add sqlite-unbundled to gituhb actions tests

* cfg(feature = "sqlite") => cfg(any(feature = "sqlite", feature = "sqlite-unbundled"))

* fix

* CI: make sqlite-unbundled tests workaround required-features

by duplicating the relevant test section

* use an internal "_sqlite" feature to do the conditional compilation

---------

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2024-10-02 11:55:21 -07:00

46 lines
1.4 KiB
Rust

use std::path::Path;
#[test]
#[ignore]
fn ui_tests() {
let t = trybuild::TestCases::new();
if cfg!(feature = "postgres") {
t.compile_fail("tests/ui/postgres/*.rs");
// UI tests for column types that require gated features
if cfg!(not(feature = "chrono")) && cfg!(not(feature = "time")) {
t.compile_fail("tests/ui/postgres/gated/chrono.rs");
}
if cfg!(not(feature = "uuid")) {
t.compile_fail("tests/ui/postgres/gated/uuid.rs");
}
if cfg!(not(feature = "ipnetwork")) {
t.compile_fail("tests/ui/postgres/gated/ipnetwork.rs");
}
}
if cfg!(feature = "mysql") {
t.compile_fail("tests/ui/mysql/*.rs");
// UI tests for column types that require gated features
if cfg!(not(feature = "chrono")) && cfg!(not(feature = "time")) {
t.compile_fail("tests/ui/mysql/gated/chrono.rs");
}
}
if cfg!(feature = "_sqlite") {
if dotenvy::var("DATABASE_URL").map_or(true, |v| {
Path::is_relative(v.trim_start_matches("sqlite://").as_ref())
}) {
// this isn't `Trybuild`'s fault: https://github.com/dtolnay/trybuild/issues/69#issuecomment-620329526
panic!("DATABASE_URL must contain an absolute path for SQLite UI tests")
}
t.compile_fail("tests/ui/sqlite/*.rs");
}
t.compile_fail("tests/ui/*.rs");
}