Skip to content

Commit bd43818

Browse files
author
Furkan Küçük
committed
Temporary tests removed
1 parent 5def695 commit bd43818

File tree

4 files changed

+4
-131
lines changed

4 files changed

+4
-131
lines changed

src/GitVersion.Configuration.Tests/Configuration/ConfigurationFileLocatorTests.cs

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -188,55 +188,6 @@ public void ReturnConfigurationFilePathIfCustomConfigurationIsSet()
188188
config.ShouldBe(Path.GetFullPath("Configuration/CustomConfig.yaml"));
189189
}
190190

191-
[Test]
192-
public void ReturnConfigurationFilePathIfCustomConfigurationIsSet_PerformanceComparison()
193-
{
194-
this.workingPath = this.repoPath;
195-
196-
this.gitVersionOptions = new() { ConfigurationInfo = { ConfigurationFile = Path.Combine(this.workingPath, "Configuration", "CustomConfig.yaml") } };
197-
198-
var serviceProvider = GetServiceProvider(this.gitVersionOptions);
199-
this.fileSystem = serviceProvider.GetRequiredService<IFileSystem>();
200-
201-
using var _ = this.fileSystem.SetupConfigFile(
202-
path: Path.Combine(this.workingPath, "Configuration"), fileName: "CustomConfig2.yaml"
203-
);
204-
this.configFileLocator = serviceProvider.GetRequiredService<IConfigurationFileLocator>();
205-
Stopwatch stopwatch = new();
206-
stopwatch.Start();
207-
var config = this.configFileLocator.GetConfigurationFile(this.workingPath);
208-
stopwatch.Stop();
209-
long et1 = stopwatch.ElapsedTicks;
210-
211-
stopwatch.Reset();
212-
stopwatch.Start();
213-
config = this.configFileLocator.GetConfigurationFileTemp(this.workingPath);
214-
stopwatch.Stop();
215-
long et2 = stopwatch.ElapsedTicks;
216-
217-
//et1.ShouldBeLessThan(et2);
218-
219-
stopwatch.Reset();
220-
stopwatch.Start();
221-
for (int i = 0; i < 1000000; i++)
222-
{
223-
config = this.configFileLocator.GetConfigurationFile(this.workingPath);
224-
}
225-
stopwatch.Stop();
226-
long et3 = stopwatch.ElapsedMilliseconds;
227-
228-
stopwatch.Reset();
229-
stopwatch.Start();
230-
for (int i = 0; i < 1000000; i++)
231-
{
232-
config = this.configFileLocator.GetConfigurationFileTemp(this.workingPath);
233-
}
234-
stopwatch.Stop();
235-
long et4 = stopwatch.ElapsedMilliseconds;
236-
237-
et3.ShouldBeLessThan(et4);
238-
}
239-
240191
[TestCase(null)]
241192
[TestCase("")]
242193
[TestCase(" ")]

src/GitVersion.Configuration/ConfigurationFileLocator.cs

Lines changed: 4 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -47,90 +47,14 @@ public void Verify(string? workingDirectory, string? projectRootDirectory)
4747
{
4848
this.log.Debug($"Trying to find configuration file {item} at '{directoryPath}'");
4949

50-
var configurationFilePath = item;
51-
if (!PathHelper.IsPathRooted(configurationFilePath))
50+
string configurationFilePath;
51+
if (!PathHelper.IsPathRooted(item))
5252
{
5353
if (string.IsNullOrEmpty(directoryPath))
5454
{
55-
throw new WarningException(
56-
$"The configuration file '{configurationFilePath}' is relative and no directory path known."
57-
);
58-
}
59-
configurationFilePath = Path.Combine(directoryPath, configurationFilePath);
60-
}
61-
62-
if (fileSystem.File.Exists(configurationFilePath))
63-
{
64-
this.log.Info($"Found configuration file at '{configurationFilePath}'");
65-
return configurationFilePath;
66-
}
67-
68-
this.log.Debug($"Configuration file {configurationFilePath} not found at '{directoryPath}'");
69-
}
70-
71-
return null;
72-
}
73-
74-
public string? GetConfigurationFileTemp(string? directoryPath)
75-
{
76-
// If configuration file overriden and its exists, return it
77-
if (!string.IsNullOrWhiteSpace(this.ConfigurationFile) &&
78-
PathHelper.IsPathRooted(this.ConfigurationFile) &&
79-
fileSystem.File.Exists(this.ConfigurationFile))
80-
{
81-
return this.ConfigurationFile;
82-
}
83-
84-
if (directoryPath is null) return null;
85-
86-
string[] candidates = !string.IsNullOrWhiteSpace(this.ConfigurationFile)
87-
? [this.ConfigurationFile, .. this.SupportedConfigFileNames]
88-
: this.SupportedConfigFileNames;
89-
90-
foreach (var fileName in candidates)
91-
{
92-
this.log.Debug($"Trying to find configuration file {fileName} at '{directoryPath}'");
93-
if (directoryPath != null && fileSystem.Directory.Exists(directoryPath))
94-
{
95-
var files = fileSystem.Directory.GetFiles(directoryPath);
96-
97-
var matchingFile = files.FirstOrDefault(file =>
98-
string.Equals(fileSystem.Path.GetFileName(file), fileName, StringComparison.OrdinalIgnoreCase));
99-
100-
if (matchingFile != null)
101-
{
102-
this.log.Info($"Found configuration file at '{matchingFile}'");
103-
return matchingFile;
55+
this.log.Info($"The configuration file '{item}' is relative and no directory path known.");
56+
continue;
10457
}
105-
}
106-
107-
this.log.Debug($"Configuration file {fileName} not found at '{directoryPath}'");
108-
}
109-
110-
return null;
111-
}
112-
113-
public string? GetConfigurationFileCombined(string? directoryPath)
114-
{
115-
if (!string.IsNullOrWhiteSpace(this.ConfigurationFile) &&
116-
PathHelper.IsPathRooted(this.ConfigurationFile) &&
117-
fileSystem.File.Exists(this.ConfigurationFile))
118-
{
119-
return this.ConfigurationFile;
120-
}
121-
122-
if (directoryPath is null) return null;
123-
124-
string[] configurationFilePaths = string.IsNullOrWhiteSpace(this.ConfigurationFile)
125-
? this.SupportedConfigFileNames : [this.ConfigurationFile, .. this.SupportedConfigFileNames];
126-
127-
foreach (var item in configurationFilePaths)
128-
{
129-
this.log.Debug($"Trying to find configuration file {item} at '{directoryPath}'");
130-
131-
string configurationFilePath;
132-
if (!PathHelper.IsPathRooted(item))
133-
{
13458
configurationFilePath = Path.Combine(directoryPath, item);
13559
}
13660
else

src/GitVersion.Core/Configuration/IConfigurationFileLocator.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ public interface IConfigurationFileLocator
44
{
55
void Verify(string? workingDirectory, string? projectRootDirectory);
66
string? GetConfigurationFile(string? directoryPath);
7-
string? GetConfigurationFileTemp(string? directoryPath);
87
}

src/GitVersion.Core/PublicAPI.Shipped.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ GitVersion.Configuration.IConfigurationBuilder.AddOverride(System.Collections.Ge
114114
GitVersion.Configuration.IConfigurationBuilder.Build() -> GitVersion.Configuration.IGitVersionConfiguration!
115115
GitVersion.Configuration.IConfigurationFileLocator
116116
GitVersion.Configuration.IConfigurationFileLocator.GetConfigurationFile(string? directoryPath) -> string?
117-
GitVersion.Configuration.IConfigurationFileLocator.GetConfigurationFileTemp(string? directoryPath) -> string?
118117
GitVersion.Configuration.IConfigurationFileLocator.Verify(string? workingDirectory, string? projectRootDirectory) -> void
119118
GitVersion.Configuration.IConfigurationProvider
120119
GitVersion.Configuration.IConfigurationProvider.Provide(System.Collections.Generic.IReadOnlyDictionary<object!, object?>? overrideConfiguration = null) -> GitVersion.Configuration.IGitVersionConfiguration!

0 commit comments

Comments
 (0)