Wait for precompiled file to change.

This commit is contained in:
Pranav K 2015-02-18 11:23:57 -08:00
parent 99eb8f06ad
commit 4ac3acca22
1 changed files with 13 additions and 9 deletions

View File

@ -18,7 +18,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
{ {
public class PrecompilationTest public class PrecompilationTest
{ {
private static readonly TimeSpan _cacheDelayInterval = TimeSpan.FromSeconds(2); private static readonly TimeSpan _cacheDelayInterval = TimeSpan.FromSeconds(1);
private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(PrecompilationWebSite)); private readonly IServiceProvider _services = TestHelper.CreateServices(nameof(PrecompilationWebSite));
private readonly Action<IApplicationBuilder> _app = new Startup().Configure; private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
@ -113,7 +113,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
// Act - 7 // Act - 7
// Add a new _GlobalImport file // Add a new _GlobalImport file
File.WriteAllText(Path.Combine(viewsDirectory, "..", "_GlobalImport.cshtml"), string.Empty); var newGlobalImport = await TouchFile(Path.GetDirectoryName(viewsDirectory), "_GlobalImport.cshtml");
responseContent = await client.GetStringAsync("http://localhost/Home/Index"); responseContent = await client.GetStringAsync("http://localhost/Home/Index");
// Assert - 7 // Assert - 7
@ -125,7 +125,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
// Act - 8 // Act - 8
// Remove new _GlobalImport file // Remove new _GlobalImport file
File.Delete(Path.Combine(viewsDirectory, "..", "_GlobalImport.cshtml")); File.Delete(newGlobalImport);
responseContent = await client.GetStringAsync("http://localhost/Home/Index"); responseContent = await client.GetStringAsync("http://localhost/Home/Index");
// Assert - 8 // Assert - 8
@ -216,11 +216,15 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
} }
} }
private static Task TouchFile(string viewsDir, string file) private static async Task<string> TouchFile(string viewsDir, string file)
{ {
File.AppendAllText(Path.Combine(viewsDir, file), " "); var path = Path.Combine(viewsDir, file);
// Delay to ensure we don't hit the cached file system. File.AppendAllText(path, " ");
return Task.Delay(_cacheDelayInterval);
// Delay to allow the file system watcher to catch up.
await Task.Delay(_cacheDelayInterval);
return path;
} }
private sealed class ParsedResponse private sealed class ParsedResponse