Permalink
Browse files

Merge pull request #385 from mattjphillips/fail_on_compiler_error

When a compilation error occurs, fail any of the tests that are based on...
  • Loading branch information...
2 parents 6dae908 + 1d33e49 commit a8b0a363c69dfd711bd51978f9118b9a5747c290 @nikhilk committed Jun 23, 2013
Showing with 15 additions and 1 deletion.
  1. +15 −1 tests/Core/BrowserTest.cs
View
@@ -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<string> codeFailures = new List<string>();
+
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);

0 comments on commit a8b0a36

Please sign in to comment.