From 7ad918da907cff3e6ae6f373e6ca6c4b79a0f835 Mon Sep 17 00:00:00 2001 From: ehennestad Date: Thu, 29 Oct 2026 16:10:56 +0100 Subject: [PATCH] test(fixture): derive the ProjectFixture profile name from a uuid ProjectFixture creates a NANSEN user profile under prefdir, a folder shared by every MATLAB process on the machine, and named it sprintf('test%d', randi(999)). A fresh MATLAB process always starts from the same default RNG seed, so two test processes that start together draw the same number and share one profile folder: the second one fails in nansen.mock.createMockProject with "A project with name MockProject already exists", and the first one's teardown then removes the shared folder underneath the second, which fails again in its own teardown. The name is now sprintf('test_%s', nansen.util.getuuid()), unique per process and per fixture instance. The "test" prefix stays so leftover profiles remain recognisable. The teardown is unchanged, and nothing else in code/ or tests/ depends on the test form. Co-Authored-By: Claude Fable 5.1 --- tests/+nansen/+fixture/ProjectFixture.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/+nansen/+fixture/ProjectFixture.m b/tests/+nansen/+fixture/ProjectFixture.m index 4934f007..250aaee3 100644 --- a/tests/+nansen/+fixture/ProjectFixture.m +++ b/tests/+nansen/+fixture/ProjectFixture.m @@ -21,7 +21,13 @@ function setup(fixture) F = fixture.applyFixture( TemporaryFolderFixture ); % Create a user profile for testing. Todo: make fixture - userProfileName = sprintf('test%d', randi(999)); + % The profile folder lives in prefdir, which all MATLAB processes + % on a machine share, and every fresh MATLAB process starts from + % the same default RNG seed, so a name drawn with randi can repeat + % across test processes that start together. A uuid is unique per + % process and per fixture instance. The "test" prefix keeps leftover + % profiles recognisable. + userProfileName = sprintf('test_%s', nansen.util.getuuid()); fixture.addTeardown( ... @() fixture.deleteUserProfile(userProfileName) )