Skip to content

Commit af0950b

Browse files
Add type-only testing
1 parent baedfaf commit af0950b

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

crates/cli/tests/reference.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@
5252
//! // FLAGS: --target=web
5353
//! // FLAGS: --target=nodejs
5454
//! ```
55+
//!
56+
//! ## Testing only types
57+
//!
58+
//! In some cases, we are only interested in testing the generated `.d.ts` file.
59+
//! In this case, add a comment at the top of the test file:
60+
//!
61+
//! ```rust
62+
//! // TYPES ONLY
63+
//! ```
5564
5665
use anyhow::{bail, Result};
5766
use assert_cmd::prelude::*;
@@ -119,6 +128,8 @@ fn runtest(test: &Path) -> Result<()> {
119128
let root = repo_root();
120129
let root = root.display();
121130

131+
let types_only = contents.contains("// TYPES ONLY");
132+
122133
// parse target declarations
123134
let mut all_flags: Vec<_> = contents
124135
.lines()
@@ -215,7 +226,7 @@ fn runtest(test: &Path) -> Result<()> {
215226
_ => "reference_test.js",
216227
};
217228

218-
if !contents.contains("async") {
229+
if !types_only {
219230
let js = fs::read_to_string(out_dir.join(main_js_file))?;
220231
assert_same(&js, &test.with_extension("js"))?;
221232
let wat = sanitize_wasm(&out_dir.join("reference_test_bg.wasm"))?;

crates/cli/tests/reference/async-number.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// TYPES ONLY
2+
13
use wasm_bindgen::prelude::*;
24

35
#[wasm_bindgen]

crates/cli/tests/reference/async-void.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// TYPES ONLY
2+
13
use wasm_bindgen::prelude::*;
24

35
#[wasm_bindgen]

0 commit comments

Comments
 (0)