diff --git a/src/Test/Perf/infra/automation.csx b/src/Test/Perf/infra/automation.csx
index 7e6b8880a8a16..b9360caa9df68 100644
--- a/src/Test/Perf/infra/automation.csx
+++ b/src/Test/Perf/infra/automation.csx
@@ -7,7 +7,7 @@
using Roslyn.Test.Performance.Utilities;
var directoryUtil = new RelativeDirectory();
-TestUtilities.InitUtilities();
+TestUtilities.InitUtilitiesFromCsx();
// Install the Vsixes to RoslynPerf hive
await RunFile(Path.Combine(directoryUtil.MyWorkingDirectory, "install_vsixes.csx"));
diff --git a/src/Test/Perf/infra/install.csx b/src/Test/Perf/infra/install.csx
index be49493077604..395fc3b65768a 100644
--- a/src/Test/Perf/infra/install.csx
+++ b/src/Test/Perf/infra/install.csx
@@ -13,7 +13,7 @@ using System.IO;
using Roslyn.Test.Performance.Utilities;
using static Roslyn.Test.Performance.Utilities.TestUtilities;
-TestUtilities.InitUtilities();
+TestUtilities.InitUtilitiesFromCsx();
// If we're being #load'ed by uninstall.csx, set the "uninstall" flag.
var uninstall = Environment.GetCommandLineArgs()[1] == "uninstall.csx";
diff --git a/src/Test/Perf/infra/install_vsixes.csx b/src/Test/Perf/infra/install_vsixes.csx
index 8e49ba7c1f152..eba37693be6d7 100644
--- a/src/Test/Perf/infra/install_vsixes.csx
+++ b/src/Test/Perf/infra/install_vsixes.csx
@@ -7,7 +7,7 @@
using System.IO;
using Roslyn.Test.Performance.Utilities;
-TestUtilities.InitUtilities();
+TestUtilities.InitUtilitiesFromCsx();
var directoryUtil = new RelativeDirectory();
var logger = new ConsoleAndFileLogger();
diff --git a/src/Test/Perf/util/TestUtilities.cs b/src/Test/Perf/util/TestUtilities.cs
index bbfd2474bf801..d2f47dd4d254b 100644
--- a/src/Test/Perf/util/TestUtilities.cs
+++ b/src/Test/Perf/util/TestUtilities.cs
@@ -20,7 +20,16 @@ public class TestUtilities
//
public static string _myWorkingFile = null;
- public static void InitUtilities([CallerFilePath] string sourceFilePath = "")
+ ///
+ /// This method should be called *ONLY* by the csx scripts.
+ /// This method *MUST NOT* be called from within the library itself. If this method is called within the library instead of csx scripts
+ /// then will be set to the path of the file when the library is actual built.
+ /// For Eg: If SomeLibarayFile.cs calls this method and if the library is built is some build machine where SomeLibarayFile.cs is saved at
+ /// Y:/Project/SomeLibarayFile.cs then when the library is used in any machine where there is no Y: drive then we will see errors saying
+ /// invalid directory path. Also note that will be set to "Y:/Project/SomeLibarayFile.cs" and not set to
+ /// the path of the file from where the call to SomeLibarayFile.cs which in turn called
+ ///
+ public static void InitUtilitiesFromCsx([CallerFilePath] string sourceFilePath = "")
{
_myWorkingFile = sourceFilePath;
}
@@ -30,102 +39,11 @@ public static string MyWorkingDirectory()
{
if (_myWorkingFile == null)
{
- throw new Exception("Tests must call InitUtilities before doing any path-dependent operations.");
+ throw new Exception("Tests must call InitUtilitiesFromCsx before doing any path-dependent operations.");
}
return Directory.GetParent(_myWorkingFile).FullName;
}
- /// Returns the directory that you can put artifacts like
- /// etl traces or compiled binaries
- public static string MyArtifactsDirectory()
- {
- var path = Path.Combine(MyWorkingDirectory(), "artifacts");
- Directory.CreateDirectory(path);
- return path;
- }
-
- public static string MyTempDirectory()
- {
- var workingDir = MyWorkingDirectory();
- var path = Path.Combine(workingDir, "temp");
- Directory.CreateDirectory(path);
- return path;
- }
-
- public static string RoslynDirectory()
- {
- var workingDir = MyWorkingDirectory();
- var binaryDebug = Path.Combine("Binaries", "Debug").ToString();
- int binaryDebugIndex = workingDir.IndexOf(binaryDebug, StringComparison.OrdinalIgnoreCase);
- if (binaryDebugIndex != -1)
- {
- return workingDir.Substring(0, binaryDebugIndex);
- }
-
- var binaryRelease= Path.Combine("Binaries", "Release").ToString();
- return workingDir.Substring(0, workingDir.IndexOf(binaryRelease, StringComparison.OrdinalIgnoreCase));
- }
-
- public static string CscPath()
- {
- return Path.Combine(MyBinaries(), "csc.exe");
- }
-
- public static string MyBinaries()
- {
- var workingDir = MyWorkingDirectory();
- // We may be a release or debug build
- var debug = workingDir.IndexOf("debug", StringComparison.CurrentCultureIgnoreCase);
- if (debug != -1)
- return workingDir.Substring(0, debug + "debug".Length);
-
- var release = workingDir.IndexOf("release", StringComparison.CurrentCultureIgnoreCase);
- if (release != -1)
- return workingDir.Substring(0, release + "release".Length);
-
- throw new Exception("You are attempting to run performance test from the src directory. Run it from binaries");
- }
-
- public static string PerfDirectory()
- {
- return Path.Combine(RoslynDirectory(), "src", "Test", "Perf");
- }
-
- public static string BinDirectory()
- {
- return Path.Combine(RoslynDirectory(), "Binaries");
- }
-
- public static string BinDebugDirectory()
- {
- return Path.Combine(BinDirectory(), "Debug");
- }
-
- public static string BinReleaseDirectory()
- {
- return Path.Combine(BinDirectory(), "Release");
- }
-
- public static string DebugCscPath()
- {
- return Path.Combine(BinDebugDirectory(), "csc.exe");
- }
-
- public static string ReleaseCscPath()
- {
- return Path.Combine(BinReleaseDirectory(), "csc.exe");
- }
-
- public static string DebugVbcPath()
- {
- return Path.Combine(BinDebugDirectory(), "vbc.exe");
- }
-
- public static string ReleaseVbcPath()
- {
- return Path.Combine(BinReleaseDirectory(), "vbc.exe");
- }
-
public static string GetCPCDirectoryPath()
{
return Environment.ExpandEnvironmentVariables(@"%SYSTEMDRIVE%\CPC");
@@ -154,6 +72,8 @@ public class ProcessResult
/// Shells out, and if the process fails, log the error
/// and quit the script.
+ /// NOTE: should be set when called inside the library and not from csx. see
+ /// for more information
public static void ShellOutVital(
string file,
string args,
@@ -170,6 +90,8 @@ public class ProcessResult
}
}
+ /// NOTE: should be set when called inside the library and not from csx. see
+ /// for more information
public static ProcessResult ShellOut(
string file,
string args,
@@ -240,9 +162,9 @@ public class ProcessResult
};
}
- public static string StdoutFrom(string program, bool verbose, ILogger logger, string args = "")
+ public static string StdoutFrom(string program, bool verbose, ILogger logger, string args = "", string workingDirectory = null)
{
- var result = ShellOut(program, args, verbose, logger);
+ var result = ShellOut(program, args, verbose, logger, workingDirectory);
if (result.Failed)
{
LogProcessResult(result, logger);
diff --git a/src/Test/Perf/util/Tools.cs b/src/Test/Perf/util/Tools.cs
index 61666787999d1..569a89a370bbe 100644
--- a/src/Test/Perf/util/Tools.cs
+++ b/src/Test/Perf/util/Tools.cs
@@ -119,7 +119,7 @@ public static string GetViBenchJsonFromCsv(string compilerTimeCsvFilePath, strin
arguments = arguments.Replace("\r\n", " ").Replace("\n", "");
- ShellOutVital(Path.Combine(GetCPCDirectoryPath(), "ViBenchToJson.exe"), arguments, verbose, logger);
+ ShellOutVital(Path.Combine(GetCPCDirectoryPath(), "ViBenchToJson.exe"), arguments, verbose, logger, workingDirectory: "");
return outJson;
}
@@ -168,7 +168,7 @@ public static void UploadTraces(string sourceFolderPath, string destinationFolde
public static void CopyDirectory(string source, ILogger logger, string destination, string argument = @"/mir")
{
- var result = ShellOut("Robocopy", $"{argument} {source} {destination}", verbose: true, logger: logger);
+ var result = ShellOut("Robocopy", $"{argument} {source} {destination}", verbose: true, logger: logger, workingDirectory: "");
// Robocopy has a success exit code from 0 - 7
if (result.Code > 7)
diff --git a/src/Test/Perf/util/TraceManager.cs b/src/Test/Perf/util/TraceManager.cs
index 540b6cd0a15b7..70f00b35c348a 100644
--- a/src/Test/Perf/util/TraceManager.cs
+++ b/src/Test/Perf/util/TraceManager.cs
@@ -28,10 +28,6 @@ public class TraceManager : ITraceManager
_scenarioGenerator = new ScenarioGenerator(scenarioPath);
_verbose = verbose;
_logger = logger;
-
- // Since TraceManager.Setup() and few other functions use ShellOutVital,
- // which requires the TestUtilities.InitUtilities() to be called
- InitUtilities();
}
public bool HasWarmUpIteration
@@ -63,24 +59,24 @@ public void Initialize()
public void Setup()
{
- ShellOutVital(_cpcPath, "/Setup /DisableArchive", _verbose, _logger);
+ ShellOutVital(_cpcPath, "/Setup /DisableArchive", _verbose, _logger, workingDirectory: "");
}
public void Start()
{
- ShellOutVital(_cpcPath, "/Start /DisableArchive", _verbose, _logger);
+ ShellOutVital(_cpcPath, "/Start /DisableArchive", _verbose, _logger, workingDirectory: "");
}
public void Stop()
{
var scenariosXmlPath = Path.Combine(GetCPCDirectoryPath(), "scenarios.xml");
var consumptionTempResultsPath = Path.Combine(GetCPCDirectoryPath(), "ConsumptionTempResults.xml");
- ShellOutVital(_cpcPath, $"/Stop /DisableArchive /ScenarioPath=\"{scenariosXmlPath}\" /ConsumptionTempResultsPath=\"{consumptionTempResultsPath}\"", _verbose, _logger);
+ ShellOutVital(_cpcPath, $"/Stop /DisableArchive /ScenarioPath=\"{scenariosXmlPath}\" /ConsumptionTempResultsPath=\"{consumptionTempResultsPath}\"", _verbose, _logger, workingDirectory: "");
}
public void Cleanup()
{
- ShellOutVital(_cpcPath, "/Cleanup /DisableArchive", _verbose, _logger);
+ ShellOutVital(_cpcPath, "/Cleanup /DisableArchive", _verbose, _logger, workingDirectory: "");
}
public void StartScenarios()