Skip to content

Commit 0759ece

Browse files
authored
Replace other instances of Env.CurrentDir with Assembly.GetExecutingA… (#1380)
1 parent 86b0587 commit 0759ece

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

test/E2ETests/Automation.CLI/CLITestBase.common.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ public partial class CLITestBase : TestContainer
1515
private const string TestAssetsFolder = "TestAssets";
1616
private const string PackagesFolder = "packages";
1717
private const string EngineeringFolder = "eng";
18+
private const string ArtifactsFolder = "artifacts";
1819

1920
// This value is automatically updated by "build.ps1" script.
2021
private const string TestPlatformCLIPackageName = "Microsoft.TestPlatform";
2122
private const string VstestConsoleRelativePath = @"tools\net462\Common7\IDE\Extensions\TestPlatform\vstest.console.exe";
2223

2324
protected XmlDocument ReadVersionProps()
2425
{
25-
var versionPropsFilePath = Path.Combine(Environment.CurrentDirectory, EngineeringFolder, "Versions.props");
26+
var versionPropsFilePath = Path.Combine(GetRepositoryRootFolder(), EngineeringFolder, "Versions.props");
2627
using var fileStream = File.OpenRead(versionPropsFilePath);
2728
using var xmlTextReader = new XmlTextReader(fileStream) { Namespaces = false };
2829
var versionPropsXml = new XmlDocument();
@@ -39,18 +40,18 @@ protected string GetTestPlatformVersion()
3940
return testSdkVersion.InnerText;
4041
}
4142

42-
protected string GetArtifactsFolder()
43+
protected string GetRepositoryRootFolder()
4344
{
4445
var assemblyLocation = System.Reflection.Assembly.GetExecutingAssembly().Location;
4546

46-
return Path.Combine(assemblyLocation, @"..\..\..\..");
47+
return Path.Combine(assemblyLocation, @"..\..\..\..\..");
4748
}
4849

4950
/// <summary>
5051
/// Gets the path of test assets folder.
5152
/// </summary>
5253
/// <returns>Path to testassets folder.</returns>
53-
protected string GetAssetFolderPath() => Path.Combine(GetArtifactsFolder(), TestAssetsFolder);
54+
protected string GetAssetFolderPath() => Path.Combine(GetRepositoryRootFolder(), ArtifactsFolder, TestAssetsFolder);
5455

5556
/// <summary>
5657
/// Gets the full path to a test asset.
@@ -75,7 +76,7 @@ protected string GetAssetFullPath(string assetName)
7576

7677
protected string GetTestAdapterPath()
7778
{
78-
var testAdapterPath = Path.Combine(GetArtifactsFolder(), TestAssetsFolder);
79+
var testAdapterPath = Path.Combine(GetRepositoryRootFolder(), ArtifactsFolder, TestAssetsFolder);
7980
return testAdapterPath;
8081
}
8182

test/E2ETests/Automation.CLI/CLITestBase.e2e.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void InvokeVsTestForExecution(string[] sources, string runSettings = "",
6868
/// <returns>Full path to <c>vstest.console.exe</c>.</returns>
6969
public string GetConsoleRunnerPath()
7070
{
71-
var vstestConsolePath = Path.Combine(Environment.CurrentDirectory, PackagesFolder, TestPlatformCLIPackageName, GetTestPlatformVersion(), VstestConsoleRelativePath);
71+
var vstestConsolePath = Path.Combine(GetRepositoryRootFolder(), PackagesFolder, TestPlatformCLIPackageName, GetTestPlatformVersion(), VstestConsoleRelativePath);
7272

7373
File.Exists(vstestConsolePath).Should().BeTrue("GetConsoleRunnerPath: Path not found: {0}", vstestConsolePath);
7474

0 commit comments

Comments
 (0)