Skip to content

Commit eda3c8f

Browse files
committed
add debug assertions to round-trip tests
See the docs for `Instance::enable_concurrent_state_debug` and `Instance::assert_concurrent_state_empty` for what this does.` Signed-off-by: Joel Dice <[email protected]>
1 parent ea6bab6 commit eda3c8f

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

crates/misc/component-async-tests/tests/scenario/round_trip.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ pub async fn test_round_trip(
237237
let mut store = make_store();
238238

239239
let instance = linker.instantiate_async(&mut store, &component).await?;
240+
instance.enable_concurrent_state_debug(&mut store, true);
240241
let round_trip =
241242
component_async_tests::round_trip::bindings::RoundTrip::new(&mut store, &instance)?;
242243

@@ -258,6 +259,8 @@ pub async fn test_round_trip(
258259
{
259260
assert_eq!(expected, actual);
260261
}
262+
263+
instance.assert_concurrent_state_empty(&mut store);
261264
}
262265

263266
if call_style == 1 || !cfg!(miri) {
@@ -294,6 +297,8 @@ pub async fn test_round_trip(
294297
}
295298
})
296299
.await??;
300+
301+
instance.assert_concurrent_state_empty(&mut store);
297302
}
298303

299304
if call_style == 2 || !cfg!(miri) {
@@ -352,6 +357,8 @@ pub async fn test_round_trip(
352357
);
353358

354359
instance.run(&mut store, rx).await??;
360+
361+
instance.assert_concurrent_state_empty(&mut store);
355362
}
356363

357364
if call_style == 3 || !cfg!(miri) {
@@ -370,6 +377,8 @@ pub async fn test_round_trip(
370377
.await?
371378
);
372379
}
380+
381+
instance.assert_concurrent_state_empty(&mut store);
373382
}
374383
}
375384

@@ -425,6 +434,8 @@ pub async fn test_round_trip(
425434
};
426435
assert_eq!(expected, actual);
427436
}
437+
438+
instance.assert_concurrent_state_empty(&mut store);
428439
}
429440

430441
if call_style == 5 || !cfg!(miri) {
@@ -444,6 +455,8 @@ pub async fn test_round_trip(
444455
assert_eq!(*expected, actual);
445456
foo_function.post_return_async(&mut store).await?;
446457
}
458+
459+
instance.assert_concurrent_state_empty(&mut store);
447460
}
448461
}
449462

crates/misc/component-async-tests/tests/scenario/round_trip_many.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ async fn test_round_trip_many(
245245
let mut store = make_store();
246246

247247
let instance = linker.instantiate_async(&mut store, &component).await?;
248+
instance.enable_concurrent_state_debug(&mut store, true);
248249
let round_trip_many = component_async_tests::round_trip_many::bindings::RoundTripMany::new(
249250
&mut store, &instance,
250251
)?;
@@ -279,22 +280,24 @@ async fn test_round_trip_many(
279280
actual
280281
);
281282
}
283+
284+
instance.assert_concurrent_state_empty(&mut store);
282285
}
283286

284287
if call_style == 1 {
285288
// Now do it again using `TypedFunc::call_async`-based bindings:
286289
let e = component_async_tests::round_trip_many::non_concurrent_export_bindings::exports::local::local::many::Stuff {
287-
a: vec![42i32; 42],
288-
b: true,
289-
c: 424242,
290-
};
290+
a: vec![42i32; 42],
291+
b: true,
292+
c: 424242,
293+
};
291294
let f = Some(e.clone());
292295
let g = Err(());
293296

294297
let round_trip_many = component_async_tests::round_trip_many::non_concurrent_export_bindings::RoundTripMany::instantiate_async(
295-
&mut store, &component, &linker,
296-
)
297-
.await?;
298+
&mut store, &component, &linker,
299+
)
300+
.await?;
298301

299302
for (input, expected) in inputs_and_outputs {
300303
assert_eq!(
@@ -322,6 +325,8 @@ async fn test_round_trip_many(
322325
.await?
323326
);
324327
}
328+
329+
instance.assert_concurrent_state_empty(&mut store);
325330
}
326331
}
327332

@@ -402,6 +407,8 @@ async fn test_round_trip_many(
402407
};
403408
assert_eq!(make(&expected), actual);
404409
}
410+
411+
instance.assert_concurrent_state_empty(&mut store);
405412
}
406413

407414
if call_style == 3 {
@@ -417,6 +424,8 @@ async fn test_round_trip_many(
417424
assert_eq!(&make(expected), actual);
418425
foo_function.post_return_async(&mut store).await?;
419426
}
427+
428+
instance.assert_concurrent_state_empty(&mut store);
420429
}
421430
}
422431

0 commit comments

Comments
 (0)