Skip to content

Commit 0eaf884

Browse files
Mpdreamzclaude
andcommitted
Fix ConfigurationFileProvider file lock and GitCheckoutInformation type check
ConfigurationFileProvider: use a unique subdirectory per instance under ApplicationData/config-runtime/{guid} to avoid Windows file-locking collisions when multiple tests run in parallel writing the same versions.yml/products.yml files. Original CreateTempSubdirectory gave unique dirs; the fixed path broke parallel test isolation on Windows. GitCheckoutInformation.Create: the guard `fileSystem is not FileSystem` returned hardcoded test data for any ScopedFileSystem, including RealRead wrapping a real FileSystem. RealRead is used in GitCheckoutInformationTests which expects real git metadata. Change to check the type name for "Mock" so only MockFileSystem-backed instances return test data. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent a8bc2f3 commit 0eaf884

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/Elastic.Documentation.Configuration/ConfigurationFileProvider.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ public ConfigurationFileProvider(
4545
_fileSystem = fileSystem;
4646
_assemblyName = typeof(ConfigurationFileProvider).Assembly.GetName().Name!;
4747
SkipPrivateRepositories = skipPrivateRepositories;
48-
var configRuntimeDir = Path.Join(Paths.ApplicationData.FullName, "config-runtime");
48+
// Use a unique subdirectory per instance to avoid file-locking collisions when
49+
// multiple processes or parallel tests share the same ApplicationData path.
50+
var configRuntimeDir = Path.Join(Paths.ApplicationData.FullName, "config-runtime", Guid.NewGuid().ToString("N"));
4951
TemporaryDirectory = fileSystem.DirectoryInfo.New(configRuntimeDir);
50-
if (!TemporaryDirectory.Exists)
51-
TemporaryDirectory.Create();
52+
TemporaryDirectory.Create();
5253

5354
// TODO: This doesn't work as expected if a github actions consumer repo has a `config` directory.
5455
// ConfigurationSource = configurationSource ?? (

src/Elastic.Documentation/GitCheckoutInformation.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ public static GitCheckoutInformation Create(IDirectoryInfo? source, IFileSystem
4545
if (source is null)
4646
return Unavailable;
4747

48-
if (fileSystem is not FileSystem)
48+
// Return test data for in-memory (mock) file systems. ScopedFileSystem wraps the real
49+
// FileSystem so we check if the FS implementation name indicates an in-memory mock.
50+
if (fileSystem.GetType().Name.Contains("Mock", StringComparison.OrdinalIgnoreCase))
4951
{
5052
return new GitCheckoutInformation
5153
{

0 commit comments

Comments
 (0)