Skip to content

Commit

Permalink
When a compilation error occurs, fail any of the tests that are based…
Browse files Browse the repository at this point in the history
… on that compilation.
  • Loading branch information
mattjphillips committed Jun 21, 2013
1 parent 35444d0 commit 1d33e49
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/Core/BrowserTest.cs
Expand Up @@ -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;

Expand All @@ -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);
}
Expand All @@ -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);
Expand Down

0 comments on commit 1d33e49

Please sign in to comment.