public void Handle(List <ChangedFile> files) { IsRunning = true; _bus.Publish(new RunStartedMessage(files.ToArray())); var runReport = new RunReport(); AutoTest.Core.DebugLog.Debug.WriteDebug("Reading configuration"); var configsString = _config.AllSettings("php.phpunit.configs"); var configs = configsString.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var config in configs) { var configLocation = _config.AllSettings("php.phpunit." + config + ".configlocation"); var patterns = _config.AllSettings("php.phpunit." + config + ".Convention.Pattern"); var testPaths = _config.AllSettings("php.phpunit." + config + ".Convention.TestPaths"); var testLocations = new List <string>(); if (patterns.Length == 0 && testPaths.Length == 0) { testLocations.Add(""); } else { var matcher = new PhpFileConventionMatcher( _config.WatchPath, patterns.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries), testPaths.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); foreach (var file in files) { foreach (var location in matcher.Match(file.FullName)) { if (!Directory.Exists(location)) { continue; } if (!testLocations.Contains(location)) { testLocations.Add(location); } } } } if (configLocation != "") { configLocation = "-c " + configLocation + " "; } AutoTest.Core.DebugLog.Debug.WriteDebug("Running tests for test locations"); foreach (var location in testLocations) { var results = new PhpUnitRunner(_cache) .Run( configLocation + location, _config.WatchPath, location, (line) => { sendLiveFeedback(line); }); AutoTest.Core.DebugLog.Debug.WriteDebug("Returned " + results.Count.ToString() + " results"); var resultList = new List <TestRunResults>(); var runInfos = results.Select(x => new TestRunInfo(new Project(x.Project, null), x.Assembly)).ToArray(); resultList.AddRange(results); resultList.AddRange(_removedTestLocator.RemoveUnmatchedRunInfoTests(results.ToArray(), runInfos)); foreach (var result in resultList) { AutoTest.Core.DebugLog.Debug.WriteDebug("Result contains " + result.All.Length.ToString() + " tests for " + result.Project); runReport.AddTestRun( result.Project, result.Assembly, result.TimeSpent, result.Passed.Length, result.Ignored.Length, result.Failed.Length); _bus.Publish(new TestRunMessage(result)); } } } // Oh my god.. please fix this // Issue with ordering of TestRunMessage and RunFinishedMessage System.Threading.Thread.Sleep(500); _bus.Publish(new RunFinishedMessage(runReport)); IsRunning = false; }
private void assert(PhpFileConventionMatcher matcher, string file, string[] responses) { var matches = matcher.Match(file); Assert.That(matches.Length, Is.EqualTo(responses.Length)); for (int i = 0; i < matches.Length; i++) Assert.That(matches[i], Is.EqualTo(responses[i])); }
public void When_having_multiple_patterns_and_multiple_test_paths_it_will_return_all_variations(string file, string[] responses) { var matcher = new PhpFileConventionMatcher("/", new[] {"Bundle/","Framework/"}, new[] {"Tests/1","Tests/2"}); assert(matcher, file, responses); }
public void When_testpath_ends_with_star_it_will_apply_directorys_after_pattern(string file, string[] responses) { var matcher = new PhpFileConventionMatcher("/token", new[] {"Bundle/"}, new[] {"Tests*"}); assert(matcher, file, responses); }
public void When_given_matching_path_it_will_respond_with_test_path(string file, string[] responses) { var matcher = new PhpFileConventionMatcher("/token", new[] {"Bundle/"}, new[] {"Tests"}); assert(matcher, file, responses); }
public void Handle(List<ChangedFile> files) { IsRunning = true; _bus.Publish(new RunStartedMessage(files.ToArray())); var runReport = new RunReport(); var configsString = _config.AllSettings("php.phpunit.configs"); var configs = configsString.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries); foreach (var config in configs) { var configLocation = _config.AllSettings("php.phpunit." + config + ".configlocation"); var patterns = _config.AllSettings("php.phpunit." + config + ".Convention.Pattern"); var testPaths = _config.AllSettings("php.phpunit." + config + ".Convention.TestPaths"); var testLocations = new List<string>(); if (patterns.Length == 0 && testPaths.Length == 0) { testLocations.Add(""); } else { var matcher = new PhpFileConventionMatcher( _config.WatchPath, patterns.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries), testPaths.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries)); foreach (var file in files) { foreach (var location in matcher.Match(file.FullName)) { if (!Directory.Exists(location)) continue; if (!testLocations.Contains(location)) testLocations.Add(location); } } } if (configLocation != "") configLocation = "-c " + configLocation + " "; foreach (var location in testLocations) { var results = new PhpUnitRunner(_cache) .Run( configLocation + location, _config.WatchPath, location, (line) => { sendLiveFeedback(line); }); AutoTest.Core.DebugLog.Debug.WriteDebug("Returned " + results.Count.ToString() + " results"); var resultList = new List<TestRunResults>(); var runInfos = results.Select(x => new TestRunInfo(new Project(x.Project, null), x.Assembly)).ToArray(); resultList.AddRange(results); resultList.AddRange(_removedTestLocator.RemoveUnmatchedRunInfoTests(results.ToArray(), runInfos)); foreach (var result in resultList) { AutoTest.Core.DebugLog.Debug.WriteDebug("Result contains " + result.All.Length.ToString() + " tests"); runReport.AddTestRun( result.Project, result.Assembly, result.TimeSpent, result.Passed.Length, result.Ignored.Length, result.Failed.Length); _bus.Publish(new TestRunMessage(result)); } } } // Oh my god.. please fix this // Issue with ordering of TestRunMessage and RunFinishedMessage System.Threading.Thread.Sleep(100); _bus.Publish(new RunFinishedMessage(runReport)); IsRunning = false; }