Skip to content

Commit

Permalink
ci: setup miri test
Browse files Browse the repository at this point in the history
  • Loading branch information
seqre committed Nov 20, 2024
1 parent 7de23e0 commit d37215b
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,36 @@ jobs:
# Update Cargo.lock to minimal version dependencies.
cargo update -Z minimal-versions
cargo hack check --all-features --ignore-private
miri:
if: github.event_name == 'push' || github.event_name == 'schedule' ||
github.event.pull_request.head.repo.full_name != github.repository

name: Miri test
runs-on: ubuntu-latest
needs: ["build"]
steps:
- name: Checkout source
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: miri

- name: Install cargo-nextest
uses: taiki-e/install-action@v2
with:
tool: nextest

- name: Cache Cargo registry
uses: Swatinem/rust-cache@v2

- name: Miri setup
run: cargo miri setup

- name: Miri test
run: cargo miri nextest run -E 'not (test(db) | test(password_hash))' --no-fail-fast --all-features
env:
MIRIFLAGS: -Zmiri-disable-isolation
1 change: 1 addition & 0 deletions flareon-cli/tests/migration_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use flareon_cli::migration_generator::{
/// Test that the migration generator can generate a create model migration for
/// a given model which compiles successfully.
#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: extern static `pidfd_spawnp` is not supported by Miri
fn create_model_compile_test() {
let mut generator = MigrationGenerator::new(
PathBuf::from("Cargo.toml"),
Expand Down
1 change: 1 addition & 0 deletions flareon-macros/src/dbtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub(super) fn fn_to_dbtest(test_function_decl: ItemFn) -> syn::Result<TokenStrea

let result = quote! {
#[::tokio::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `sqlite3_open_v2`
async fn #sqlite_ident() {
let mut database = flareon::test::TestDatabase::new_sqlite().await.unwrap();

Expand Down
3 changes: 3 additions & 0 deletions flareon-macros/tests/compile_tests.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#[rustversion::attr(not(nightly), ignore)]
#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: extern static `pidfd_spawnp` is not supported by Miri
fn derive_form() {
let t = trybuild::TestCases::new();
t.pass("tests/ui/derive_form.rs");
}

#[rustversion::attr(not(nightly), ignore)]
#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: extern static `pidfd_spawnp` is not supported by Miri
fn attr_model() {
let t = trybuild::TestCases::new();
t.pass("tests/ui/attr_model.rs");
Expand All @@ -18,6 +20,7 @@ fn attr_model() {

#[rustversion::attr(not(nightly), ignore)]
#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: extern static `pidfd_spawnp` is not supported by Miri
fn func_query() {
let t = trybuild::TestCases::new();
t.pass("tests/ui/func_query.rs");
Expand Down
2 changes: 2 additions & 0 deletions flareon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `sqlite3_open_v2`
async fn flareon_project_builder() {
let project = FlareonProject::builder()
.register_app_with_views(MockFlareonApp {}, "/app")
Expand All @@ -767,6 +768,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `sqlite3_open_v2`
async fn flareon_project_router() {
let project = FlareonProject::builder()
.register_app_with_views(MockFlareonApp {}, "/app")
Expand Down
2 changes: 2 additions & 0 deletions flareon/src/static_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ mod tests {
use crate::{FlareonApp, FlareonProject};

#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `sqlite3_open_v2`
fn static_files_add_and_get_file() {
let mut static_files = StaticFiles::new();
static_files.add_file("test.txt", "This is a test file");
Expand Down Expand Up @@ -338,6 +339,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `sqlite3_open_v2`
async fn static_files_middleware_from_app_context() {
struct App1;
impl FlareonApp for App1 {
Expand Down
1 change: 1 addition & 0 deletions flareon/tests/flareon_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ async fn hello(_request: Request) -> flareon::Result<Response> {
}

#[tokio::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `sqlite3_open_v2`
async fn flareon_project_router_sub_path() {
struct App1;
impl FlareonApp for App1 {
Expand Down
2 changes: 2 additions & 0 deletions flareon/tests/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ async fn parameterized(request: Request) -> flareon::Result<Response> {
}

#[tokio::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `sqlite3_open_v2`
async fn test_index() {
let mut client = Client::new(project().await);

Expand All @@ -31,6 +32,7 @@ async fn test_index() {
}

#[tokio::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `sqlite3_open_v2`
async fn path_params() {
let mut client = Client::new(project().await);

Expand Down

0 comments on commit d37215b

Please sign in to comment.