From 1d33e49057f6e198df8f83ce01b7801441115461 Mon Sep 17 00:00:00 2001 From: Matt Phillips Date: Fri, 21 Jun 2013 09:34:32 -0500 Subject: [PATCH] When a compilation error occurs, fail any of the tests that are based on that compilation. --- tests/Core/BrowserTest.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/Core/BrowserTest.cs b/tests/Core/BrowserTest.cs index 5b450750a..d807e7f4e 100644 --- a/tests/Core/BrowserTest.cs +++ b/tests/Core/BrowserTest.cs @@ -22,6 +22,7 @@ public abstract class BrowserTest { private static readonly string[] _codeFiles = new string[] { "OOP.cs" }; + private static string _compilationFailures; private const int _port = 3976; @@ -40,16 +41,24 @@ public abstract class BrowserTest { File.Copy(Path.Combine(binDirectory, script), Path.Combine(scriptsDirectory, script), overwrite: true); } + List codeFailures = new List(); + string mscorlibPath = Path.Combine(binDirectory, "mscorlib.dll"); foreach (string codeFile in _codeFiles) { string script = Path.GetFileNameWithoutExtension(codeFile) + Path.ChangeExtension(".cs", ".js"); SimpleCompilation compilation = new SimpleCompilation(Path.Combine(scriptsDirectory, script)); - compilation.AddReference(mscorlibPath) + bool result = compilation.AddReference(mscorlibPath) .AddSource(Path.Combine(codeDirectory, codeFile)) .Execute(); + + if (!result) { + codeFailures.Add(codeFile); + } } + _compilationFailures = (codeFailures.Count == 0) ? null : string.Join(", ", codeFailures); + _webTest = new WebTest(); _webTest.StartWebServer(_port, webRoot); } @@ -64,6 +73,11 @@ public abstract class BrowserTest { } protected void RunTest(string url) { + if (_compilationFailures != null) { + Assert.Fail("Could not run test due to compilation failure of " + _compilationFailures + "."); + return; + } + Uri testUri = _webTest.GetTestUri(url); WebTestResult result = _webTest.RunTest(testUri, WebBrowser.Chrome);