public TestResult RunTest(string name, IMachine machine, ITestResultBin bin, IDictionary <string, string> env) { ITestResource res = Repo.GetResource(name); TestResult tr = new TestResult(); try { string winDirectory = TestPathPrefix + name + "\\" + DateTime.Now.Ticks + "\\"; string targetFileName = winDirectory + name + ".bat"; using (Stream s = res.Read()) { machine.PutFile(targetFileName, s); } ProgramResult result = machine.RunProgram(targetFileName, "", winDirectory, env); // Hoover up artifacts *SLUURRRRRP* var artifacts = machine.ListFiles(winDirectory); foreach (var fileName in artifacts) { string tempFile = Path.GetTempFileName(); using (FileStream fs = File.Create(tempFile)) { machine.GetFile(fileName, fs); fs.Seek(0, SeekOrigin.Begin); bin.PutArtifact(new ArtifactInfo() { Name = fileName, Description = fileName, FileName = fileName }, fs); } File.Delete(tempFile); } tr.Success = result.ExitCode == 0; } catch (Exception e) { tr.Success = false; tr.StandardError = e.Message; } return(tr); }
public TestResult RunTest(string name, IMachine machine, ITestResultBin bin, IDictionary<string, string> env) { ITestResource res = Repo.GetResource(name); TestResult tr = new TestResult(); try { string winDirectory = TestPathPrefix + name + "\\" + DateTime.Now.Ticks + "\\"; string targetFileName = winDirectory + name + ".bat"; using (Stream s = res.Read()) { machine.PutFile(targetFileName, s); } ProgramResult result = machine.RunProgram(targetFileName, "", winDirectory, env); // Hoover up artifacts *SLUURRRRRP* var artifacts = machine.ListFiles(winDirectory); foreach(var fileName in artifacts) { string tempFile = Path.GetTempFileName(); using(FileStream fs = File.Create (tempFile)) { machine.GetFile (fileName, fs); fs.Seek (0, SeekOrigin.Begin); bin.PutArtifact(new ArtifactInfo() { Name = fileName, Description = fileName, FileName = fileName }, fs); } File.Delete(tempFile); } tr.Success = result.ExitCode == 0; } catch (Exception e) { tr.Success = false; tr.StandardError = e.Message; } return tr; }