Andrew Marshall
07/08/2025, 8:39 AMlet result = RUNTIME.block_on(async {
let result = load_plugin(&dependency).await;
// Add a small delay to let asynchronous tasks to complete
sleep(Duration::from_millis(500)).await;
result
});
I've tried using a fixture to make the plugin and provider instance persistent across multiple tests, but haven't had much luck (it looks like there's some state not being cleaned up between unit test runs - or maybe ths issue is with our plugin?) - the first test passes but subsequent ones fail due to contract verification failures.
I can probably provide a minimal example but I thought I'd ask first in case you had any ideas.
Many thanks!Yousaf Nabi (pactflow.io)
pactffi_using_plugin
needs to start the plugin, wait for it to start up and report back its running port before it can move on. pactffi_using_plugin
is called on the consumer side, for the provider side, it is read from the pact itself and I don’t think it will call that function.
Looking at the history, it was added in to fix a race condition
https://github.com/pact-foundation/pact-reference/commit/213d1459c578662532e64ec7a1b1ce9af15cb676
and then again the code was subsequently updated
https://github.com/pact-foundation/pact-reference/commit/d41e2440a8d5011e51a90eeb44dcaa7dbe448b0dYousaf Nabi (pactflow.io)
pactffi_cleanup_mock_server
or if that method isn’t being called, it isn’t shutting down the plugin.
Repro would be really useful.Andrew Marshall
07/08/2025, 9:58 AMAndrew Marshall
07/16/2025, 4:04 PMTEST_2
fails, because in the second test, pact_ffi_mock_server_matched
still checks for the interactions that were specified in TEST_1
(even though a new mock server has been created on a different port). You can see this if you write out the pact file from each test.
I need some way of clearing all the interactions from the PactHandle
at the end of each test, so that I can reuse the PactHandle
(and hence its plugins).Andrew Marshall
07/16/2025, 4:06 PMYousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)
Andrew Marshall
07/16/2025, 4:15 PMYousaf Nabi (pactflow.io)
Andrew Marshall
07/17/2025, 9:32 AM0
worked fine for me (and reduced my test suite runtime from 3 minutes to 18s).