From 17d137ca11e893107280db4f9e091cb5dbd2d5d0 Mon Sep 17 00:00:00 2001 From: LucaCappelletti94 Date: Sun, 17 May 2026 15:38:13 +0200 Subject: [PATCH 1/2] Now running wasm tests in CI --- .github/workflows/rust.yml | 14 ++ Cargo.lock | 310 ++++++++++++++++++++++++++++++++++++- Cargo.toml | 3 + src/ast.rs | 5 + src/comments.rs | 21 +++ src/docs.rs | 8 + src/error.rs | 11 ++ src/source.rs | 4 + src/sql_doc.rs | 10 ++ 9 files changed, 385 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index cb92c36..e7da277 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -55,6 +55,20 @@ jobs: - name: Test no_std build run: cargo test --no-default-features + wasm_test: + name: WASM tests (wasm32-unknown-unknown, node) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + targets: wasm32-unknown-unknown + - uses: jetli/wasm-pack-action@v0.4.0 + with: + version: latest + - name: Run WASM tests via Node + run: wasm-pack test --node --no-default-features + fmt: name: Rustfmt runs-on: ubuntu-latest diff --git a/Cargo.lock b/Cargo.lock index 3ba6d3b..0552387 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,6 +11,35 @@ dependencies = [ "object", ] +[[package]] +name = "async-trait" +version = "0.1.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "bumpalo" +version = "3.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" + +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + [[package]] name = "cc" version = "1.2.52" @@ -33,12 +62,60 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f449e6c6c08c865631d4890cfacf252b3d396c9bcc83adb6623cdb02a8336c41" +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "js-sys" +version = "0.3.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67df7112613f8bfd9150013a0314e196f4800d3201ae742489d999db2f979f08" +dependencies = [ + "cfg-if", + "futures-util", + "once_cell", + "wasm-bindgen", +] + [[package]] name = "libc" version = "0.2.180" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + [[package]] name = "log" version = "0.4.29" @@ -51,6 +128,35 @@ version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" +[[package]] +name = "minicov" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4869b6a491569605d66d3952bcdf03df789e5b536e5f0cf7758a7f08a55ae24d" +dependencies = [ + "cc", + "walkdir", +] + +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + [[package]] name = "object" version = "0.32.2" @@ -60,6 +166,24 @@ dependencies = [ "memchr", ] +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "oorandom" +version = "11.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + [[package]] name = "proc-macro2" version = "1.0.105" @@ -108,17 +232,82 @@ dependencies = [ "syn", ] +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + [[package]] name = "shlex" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + [[package]] name = "sql_docs" -version = "1.3.0" +version = "1.3.1" dependencies = [ "sqlparser", + "wasm-bindgen-test", ] [[package]] @@ -160,6 +349,119 @@ version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.121" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49ace1d07c165b0864824eee619580c4689389afa9dc9ed3a4c75040d82e6790" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96492d0d3ffba25305a7dc88720d250b1401d7edca02cc3bcd50633b424673b8" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.121" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e68e6f4afd367a562002c05637acb8578ff2dea1943df76afb9e83d177c8578" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.121" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d95a9ec35c64b2a7cb35d3fead40c4238d0940c86d107136999567a4703259f2" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.121" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4e0100b01e9f0d03189a92b96772a1fb998639d981193d7dbab487302513441" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-bindgen-test" +version = "0.3.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af5ec93229ad9ccd0a545a516dec76dc276613f278f6a91aa6b463d5b33d42d0" +dependencies = [ + "async-trait", + "cast", + "js-sys", + "libm", + "minicov", + "nu-ansi-term", + "num-traits", + "oorandom", + "serde", + "serde_json", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test-macro", + "wasm-bindgen-test-shared", +] + +[[package]] +name = "wasm-bindgen-test-macro" +version = "0.3.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c81b9fef827e575e0e54431736d1baa0d700315d8c62cfef1f61fa3aad0cbeb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "wasm-bindgen-test-shared" +version = "0.2.121" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f4d8ae7ad5440360e9799dfd42857d126454a88441ddf72d288ef83fa47f527" + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys", +] + [[package]] name = "windows-sys" version = "0.59.0" @@ -232,3 +534,9 @@ name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/Cargo.toml b/Cargo.toml index 1d77a65..bbd7803 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,9 @@ fuzzing = [] [dependencies] sqlparser = { git = "https://github.com/LucaCappelletti94/sqlparser-rs", branch = "dialect-derives" } +[target.'cfg(target_arch = "wasm32")'.dev-dependencies] +wasm-bindgen-test = "0.3" + [lints.rust] missing_docs = "forbid" unreachable_patterns = "forbid" diff --git a/src/ast.rs b/src/ast.rs index 2d3c080..833eb4e 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -113,6 +113,9 @@ mod tests { use super::*; use crate::source::SqlSource; + #[cfg(target_arch = "wasm32")] + use wasm_bindgen_test::wasm_bindgen_test; + #[cfg(feature = "std")] #[test] fn parsed_sql_file_parses_single_statement() -> Result<(), Box> { @@ -179,6 +182,7 @@ mod tests { } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn parsed_sql_file_parse_postgres_handles_pg_function_syntax() -> Result<(), Box> { let sql = r" @@ -256,6 +260,7 @@ mod tests { } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn parsed_sql_file_parse_invalid_sql_returns_error() { let sql = "CREATE TABLE"; let src = SqlSource::from(sql.to_owned()); diff --git a/src/comments.rs b/src/comments.rs index 52d5bae..bac03e9 100644 --- a/src/comments.rs +++ b/src/comments.rs @@ -464,6 +464,9 @@ pub enum MultiFlatten<'a> { #[cfg(test)] mod tests { + #[cfg(target_arch = "wasm32")] + use wasm_bindgen_test::wasm_bindgen_test; + use alloc::{ borrow::ToOwned, boxed::Box, @@ -476,6 +479,7 @@ mod tests { use crate::comments::{Comment, CommentError, CommentKind, Comments, Location, Span}; #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn location_new_and_default() { let mut location = Location::new(2, 5); location.column = 20; @@ -488,6 +492,7 @@ mod tests { } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn span_default_and_updates() { let default = Span::default(); assert_eq!(default.start, Location::default()); @@ -500,6 +505,7 @@ mod tests { } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn comments_with_comment_kind() { let raw_comment = "-- a comment"; let len = raw_comment.len() as u64; @@ -519,6 +525,7 @@ mod tests { } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn multiline_comment_span() { let kind = CommentKind::MultiLine; let span = Span::new(Location { line: 1, column: 1 }, Location { line: 2, column: 9 }); @@ -859,6 +866,7 @@ CREATE TABLE posts ( } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn test_comment_error() { let unterminated = CommentError::UnterminatedMultiLineComment { start: Location::default() }; @@ -872,6 +880,7 @@ CREATE TABLE posts ( } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn test_comments() { let comment_vec = vec![ Comment::new( @@ -902,11 +911,13 @@ CREATE TABLE posts ( } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn leading_comment_capture_default_is_single_nearest() { assert_eq!(LeadingCommentCapture::default(), LeadingCommentCapture::SingleNearest); } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn leading_comments_single_nearest_and_all_leading_basic_runover() -> Result<(), Box> { let src = "\ @@ -925,6 +936,7 @@ CREATE TABLE t (id INTEGER); } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn leading_comments_all_leading_stops_at_blank_line() -> Result<(), Box> { let src = "\ @@ -941,6 +953,7 @@ CREATE TABLE t (id INTEGER); } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn leading_comments_all_single_one_multi_collects_singles_and_one_multiline() -> Result<(), Box> { let src = "\ @@ -958,6 +971,7 @@ CREATE TABLE t (id INTEGER); } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn leading_comments_all_single_one_multi_stops_before_second_multiline() -> Result<(), Box> { let src = "\ @@ -974,6 +988,7 @@ CREATE TABLE t (id INTEGER); } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn leading_comments_single_nearest_can_return_multiline() -> Result<(), Box> { let src = "\ @@ -989,12 +1004,14 @@ CREATE TABLE t (id INTEGER); } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn collapse_comments_empty_returns_none() { let comments = Comments::new(vec![]); assert!(comments.collapse_comments(crate::comments::MultiFlatten::NoFlat).is_none()); } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn collapse_comments_single_returns_same_comment() { let c = Comment::new( "solo".to_owned(), @@ -1012,6 +1029,7 @@ CREATE TABLE t (id INTEGER); } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn collapse_comments_multiple_joins_text_and_expands_span_and_sets_multiline_kind() { let c1 = Comment::new( "a".to_owned(), @@ -1040,6 +1058,7 @@ CREATE TABLE t (id INTEGER); } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn collapse_comments_with_leading_comments_allleading_collapses_correctly() -> Result<(), Box> { let src = "\ @@ -1066,6 +1085,7 @@ CREATE TABLE t (id INTEGER); } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn collapse_comments_with_leading_comments_single_nearest_preserves_kind() -> Result<(), Box> { let src = "\ @@ -1087,6 +1107,7 @@ CREATE TABLE t (id INTEGER); } use crate::comments::flatten_lines; #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn test_flatten_lines_behavior() { let input = "a\nb\nc"; let no_sep = flatten_lines(input, crate::comments::MultiFlatten::FlattenWithNone); diff --git a/src/docs.rs b/src/docs.rs index 5e77dd5..29b3998 100644 --- a/src/docs.rs +++ b/src/docs.rs @@ -355,6 +355,9 @@ fn schema_and_table(name: &ObjectName) -> Result<(Option, String), DocEr #[cfg(test)] mod tests { + #[cfg(target_arch = "wasm32")] + use wasm_bindgen_test::wasm_bindgen_test; + use alloc::{borrow::ToOwned, boxed::Box, string::String, vec}; #[cfg(feature = "std")] use core::fmt; @@ -371,6 +374,7 @@ mod tests { #[cfg(not(feature = "std"))] #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn test_sql_docs_struct() { let column_doc = ColumnDoc::new("id".to_owned(), Some("The ID for the table".to_owned())); let columns = vec![column_doc]; @@ -753,6 +757,7 @@ CREATE TABLE posts ( } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn schema_and_table_errors_when_no_identifier_parts() { let name = ObjectName(vec![func_part("now")]); @@ -770,6 +775,7 @@ CREATE TABLE posts ( } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn schema_and_table_single_identifier() { let name = ObjectName(vec![ObjectNamePart::Identifier(ident("users"))]); @@ -783,6 +789,7 @@ CREATE TABLE posts ( } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn schema_and_table_schema_and_table_with_function_ignored() -> Result<(), Box> { let name = ObjectName(vec![ @@ -868,6 +875,7 @@ CREATE TABLE posts ( } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn column_doc_set_doc_updates_doc() { let mut col = ColumnDoc::new("id".to_owned(), None); assert_eq!(col.name(), "id"); diff --git a/src/error.rs b/src/error.rs index 58d75d4..ddc90fd 100644 --- a/src/error.rs +++ b/src/error.rs @@ -132,6 +132,9 @@ impl From for DocError { #[cfg(test)] mod tests { + #[cfg(target_arch = "wasm32")] + use wasm_bindgen_test::wasm_bindgen_test; + #[cfg(not(feature = "std"))] use alloc::{string::ToString, vec}; @@ -246,6 +249,7 @@ mod tests { TableDoc::new(None, name.to_string(), None, vec![], None) } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn test_doc_error_display_invalid_object_name() { let e = DocError::InvalidObjectName { message: "bad object".to_string(), line: 12, column: 34 }; @@ -253,6 +257,7 @@ mod tests { } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn test_doc_error_display_table_not_found() { let e = DocError::TableNotFound { name: "users".to_string() }; assert_eq!(e.to_string(), "Table not found in SqlDoc: users"); @@ -270,6 +275,7 @@ mod tests { } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn test_doc_error_source_none_for_non_wrapped_variants() { use core::error::Error as _; let invalid = DocError::InvalidObjectName { message: "x".to_string(), line: 1, column: 1 }; @@ -281,12 +287,14 @@ mod tests { } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn test_doc_error_display_column_not_found() { let e = DocError::ColumnNotFound { name: "id".to_string() }; assert_eq!(e.to_string(), "Column not found in TableDoc: id"); } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn test_doc_error_display_duplicate_columns_found() { use crate::docs::ColumnDoc; @@ -300,6 +308,7 @@ mod tests { } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn test_doc_error_source_none_for_column_variants() { use core::error::Error as _; @@ -311,6 +320,7 @@ mod tests { } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn test_doc_error_display_table_with_schema_not_found() { let e = DocError::TableWithSchemaNotFound { name: "events".to_string(), @@ -320,6 +330,7 @@ mod tests { } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn test_doc_error_source_none_for_table_with_schema_not_found() { use core::error::Error as _; let e = DocError::TableWithSchemaNotFound { diff --git a/src/source.rs b/src/source.rs index d0f77d1..2242612 100644 --- a/src/source.rs +++ b/src/source.rs @@ -90,6 +90,9 @@ impl SqlSource { #[cfg(test)] mod tests { + #[cfg(target_arch = "wasm32")] + use wasm_bindgen_test::wasm_bindgen_test; + use crate::source::SqlSource; #[cfg(feature = "std")] @@ -129,6 +132,7 @@ mod tests { #[cfg(not(feature = "std"))] #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn test_sql_file_new_from_str_has_no_path_and_preserves_content() { use crate::alloc::borrow::ToOwned; let sql = "SELECT * FROM users;"; diff --git a/src/sql_doc.rs b/src/sql_doc.rs index f580afb..ed05d04 100644 --- a/src/sql_doc.rs +++ b/src/sql_doc.rs @@ -521,6 +521,9 @@ fn generate_docs_from_strs_with_paths( #[cfg(test)] mod tests { + #[cfg(target_arch = "wasm32")] + use wasm_bindgen_test::wasm_bindgen_test; + use alloc::{boxed::Box, vec}; use sqlparser::dialect::{GenericDialect, PostgreSqlDialect}; @@ -613,6 +616,7 @@ mod tests { } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn test_table_err() { let empty_set = SqlDoc::new(vec![]); let empty_table_err = empty_set.table("name", None); @@ -812,6 +816,7 @@ mod tests { } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn test_preserve_multiline_keeps_newlines_in_docs() -> Result<(), Box> { let sql = r" /* Table Doc line1 @@ -832,6 +837,7 @@ mod tests { } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn test_flatten_multiline_no_separator_removes_newlines() -> Result<(), Box> { let sql = r" @@ -854,6 +860,7 @@ mod tests { } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn test_flatten_multiline_with_separator_inserts_separator() -> Result<(), Box> { let sql = r" @@ -888,6 +895,7 @@ mod tests { } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn test_builder_build_with_flattening() -> Result<(), Box> { let sql = r" /* Table Doc line1 @@ -1138,6 +1146,7 @@ mod tests { } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn test_postgres_dialect_parses_postgres_only_function_syntax() -> Result<(), Box> { let sql = r" @@ -1161,6 +1170,7 @@ mod tests { } #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn test_generic_dialect_ignores_non_table_pg_statements_and_still_builds() -> Result<(), Box> { let sql = r" From 1c314fbf1e51c5850d74259984b324c62302a742 Mon Sep 17 00:00:00 2001 From: LucaCappelletti94 Date: Sun, 17 May 2026 15:43:59 +0200 Subject: [PATCH 2/2] fmt --- src/error.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/error.rs b/src/error.rs index ddc90fd..f3c022d 100644 --- a/src/error.rs +++ b/src/error.rs @@ -135,7 +135,6 @@ mod tests { #[cfg(target_arch = "wasm32")] use wasm_bindgen_test::wasm_bindgen_test; - #[cfg(not(feature = "std"))] use alloc::{string::ToString, vec};