public RunningTest StartNewTest(string deviceType, string artifactname, string artifactDownloadPath) { var testDevice = _availableDevices.Find(device => device.DeviceType == deviceType); if (testDevice != null) { var job = new TestJob { TestId = Guid.NewGuid(), DeviceType = deviceType, DeviceName = testDevice.DeviceName, FirmwareImage = "latest", TestLibraries = new[] { "nanoFramework.CoreLibrary.Tests" } }; File.WriteAllText(Path.Combine(_jobDirectory.FullName, string.Concat(job.TestId, ".json~")), JsonConvert.SerializeObject(job, Formatting.Indented)); File.Move(Path.Combine(_jobDirectory.FullName, string.Concat(job.TestId, ".json~")), Path.Combine(_jobDirectory.FullName, string.Concat(job.TestId, ".json"))); if (!_runAtSameMachine && _wakeOnLanMacAddress != null) { WakeOnLan(); } var test = new RunningTest { DeviceName = testDevice.DeviceName, DeviceType = deviceType, TestId = job.TestId, EstimatedRemainingTime = new TimeSpan(0, 1, 0) }; _runningTests.Add(test); _availableDevices.Remove(_availableDevices.Find(device => device.DeviceName == testDevice.DeviceName)); return(test); } return(null); }
public TestResult GetTestResults(Guid testId) { TestResult result = new TestResult { TestId = testId }; RunningTest running = _runningTests.Find(test => test.TestId == testId); if (running != null) { result.DeviceName = running.DeviceName; result.DeviceType = running.DeviceType; result.Result = "Currently running. Not finished."; result.Details = new string[] { "n.a." }; } else { FileInfo[] files = _resultsDirectory.GetFiles($"*{testId}.json"); if (files.Length > 0) { result.DeviceName = running.DeviceName; result.DeviceType = running.DeviceType; result.Result = "Finished!"; result.Details = File.ReadAllLines(files[0].FullName); } } return(result); }