Created
June 21, 2018 15:11
-
-
Save julesx/7a0cb167fba1e2d3483f2770f329b057 to your computer and use it in GitHub Desktop.
command line work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void RunSelectedTests(List<String> apexClasses) | |
{ | |
using (var cmdProcess = InitCmdProcess()) | |
{ | |
using (StreamWriter cmdProcessWriter = cmdProcess.StandardInput) | |
{ | |
var selectedTests = string.Join(",", apexClasses); | |
cmdProcessWriter.WriteLine("sfdx force:apex:test:run -n " + selectedTests);// + " -d \"c:\\my stuff\\logs\""); | |
} | |
String output; | |
while ((output = cmdProcess.StandardOutput.ReadLine()) != null) | |
{ | |
if (output.Contains("retrieve test results")) | |
{ | |
Regex regex = new Regex("([\"'])(?:(?=(\\\\?))\\2.)*?\\1"); | |
Match match = regex.Match(output); | |
if (match.Success) | |
{ | |
GetTestResults(match.Value.Trim('"'), apexClasses); | |
} | |
} | |
else | |
{ | |
Console.Error.WriteLine(output); | |
} | |
} | |
} | |
} | |
private static Process InitCmdProcess() | |
{ | |
var cmdProcess = new Process(); | |
cmdProcess.StartInfo.FileName = "cmd.exe"; | |
cmdProcess.StartInfo.RedirectStandardOutput = true; | |
cmdProcess.StartInfo.RedirectStandardInput = true; | |
cmdProcess.StartInfo.UseShellExecute = false; | |
cmdProcess.Start(); | |
return cmdProcess; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment