public void DiscoverTests(IEnumerable <string> sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) { ChutzpahTracer.TraceInformation("Begin Test Adapter Discover Tests"); var settingsProvider = discoveryContext.RunSettings.GetSettings(ChutzpahAdapterSettings.SettingsName) as ChutzpahAdapterSettingsService; var settings = settingsProvider != null ? settingsProvider.Settings : new ChutzpahAdapterSettings(); ChutzpahTracingHelper.Toggle(settings.EnabledTracing); var testOptions = new TestOptions { TestFileTimeoutMilliseconds = settings.TimeoutMilliseconds, TestingMode = settings.TestingMode, MaxDegreeOfParallelism = settings.MaxDegreeOfParallelism }; IList <TestError> errors; var testCases = testRunner.DiscoverTests(sources, testOptions, out errors); ChutzpahTracer.TraceInformation("Sending discovered tests to test case discovery sink"); foreach (var testCase in testCases) { var vsTestCase = testCase.ToVsTestCase(); discoverySink.SendTestCase(vsTestCase); } foreach (var error in errors) { logger.SendMessage(TestMessageLevel.Error, RunnerCallback.FormatFileErrorMessage(error)); } ChutzpahTracer.TraceInformation("End Test Adapter Discover Tests"); }
public void RunTests(IEnumerable <string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle) { ChutzpahTracer.TraceInformation("Begin Test Adapter Run Tests"); var settingsProvider = runContext.RunSettings.GetSettings(ChutzpahAdapterSettings.SettingsName) as ChutzpahAdapterSettingsService; var settings = settingsProvider != null ? settingsProvider.Settings : new ChutzpahAdapterSettings(); ChutzpahTracingHelper.Toggle(settings.EnabledTracing); var testOptions = new TestOptions { TestFileTimeoutMilliseconds = settings.TimeoutMilliseconds, TestingMode = settings.TestingMode, MaxDegreeOfParallelism = settings.MaxDegreeOfParallelism, }; testOptions.CoverageOptions.Enabled = runContext.IsDataCollectionEnabled; var callback = new ParallelRunnerCallbackAdapter(new ExecutionCallback(frameworkHandle, runContext)); testRunner.RunTests(sources, testOptions, callback); ChutzpahTracer.TraceInformation("End Test Adapter Run Tests"); }
private IEnumerable <ITestContainer> GetTestContainers() { ChutzpahTracer.TraceInformation("Begin GetTestContainers"); logger.Log("GetTestContainers() are called", "ChutzpahTestContainerDiscoverer", LogType.Information); ChutzpahTracingHelper.Toggle(settingsMapper.Settings.EnabledTracing); if (initialContainerSearch || forceFullContainerRefresh) { ChutzpahTracer.TraceInformation("Begin Initial test container search"); logger.Log("Initial test container search", "ChutzpahTestContainerDiscoverer", LogType.Information); // Before the full container search we clear the settings cache to make sure // we are getting the latest version of the settings // If the user changes the settings file after this it will cause a full search again chutzpahTestSettingsService.ClearCache(); cachedContainers.Clear(); var jsFiles = FindPotentialTestFiles(); UpdateTestContainersAndFileWatchers(jsFiles, true); initialContainerSearch = false; forceFullContainerRefresh = false; ChutzpahTracer.TraceInformation("End Initial test container search"); } ChutzpahTracer.TraceInformation("End GetTestContainers"); return(cachedContainers.Values); }
/// <summary> /// After a project is loaded or unloaded either add or remove from the file watcher /// all test potential items inside that project /// </summary> private void UpdateTestContainersAndFileWatchers(IEnumerable <TestFileCandidate> files, bool isAdd) { ChutzpahTracer.TraceInformation("Begin UpdateTestContainersAndFileWatchers"); Parallel.ForEach(files, file => { try { if (isAdd) { ChutzpahTracer.TraceInformation("Adding watch on {0}", file.Path); testFilesUpdateWatcher.AddWatch(file.Path); AddTestContainerIfTestFile(file); } else { ChutzpahTracer.TraceInformation("Removing watch on {0}", file.Path); testFilesUpdateWatcher.RemoveWatch(file.Path); RemoveTestContainer(file); } } catch (Exception e) { ChutzpahTracer.TraceError(e, "Failed in UpdateTestContainersAndFileWatchers"); } }); ChutzpahTracer.TraceInformation("End UpdateTestContainersAndFileWatchers"); }
public void RunTests(IEnumerable <string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle) { ChutzpahTracer.TraceInformation("Begin Test Adapter Run Tests"); var settingsProvider = runContext.RunSettings.GetSettings(AdapterConstants.SettingsName) as ChutzpahAdapterSettingsProvider; var settings = settingsProvider != null ? settingsProvider.Settings : new ChutzpahAdapterSettings(); ChutzpahTracingHelper.Toggle(settings.EnabledTracing); var testOptions = new TestOptions { TestLaunchMode = runContext.IsBeingDebugged ? TestLaunchMode.Custom: settings.OpenInBrowser ? TestLaunchMode.FullBrowser: TestLaunchMode.HeadlessBrowser, CustomTestLauncher = runContext.IsBeingDebugged ? new VsDebuggerTestLauncher() : null, MaxDegreeOfParallelism = runContext.IsBeingDebugged ? 1 : settings.MaxDegreeOfParallelism, ChutzpahSettingsFileEnvironments = new ChutzpahSettingsFileEnvironments(settings.ChutzpahSettingsFileEnvironments) }; testOptions.CoverageOptions.Enabled = runContext.IsDataCollectionEnabled; var callback = new ParallelRunnerCallbackAdapter(new ExecutionCallback(frameworkHandle, runContext)); testRunner.RunTests(sources, testOptions, callback); ChutzpahTracer.TraceInformation("End Test Adapter Run Tests"); }
private string GetOutputPath(string filePath, BatchCompileConfiguration compileConfiguration) { foreach (var pathMap in compileConfiguration.Paths) { if (filePath.IndexOf(pathMap.SourcePath, StringComparison.OrdinalIgnoreCase) >= 0) { // If the configured sourcePath is a full file path we just assume the fileName is the relative name // Otherwise we calculate the relative path from the configured sourcePath to the current file var relativePath = pathMap.SourcePathIsFile ? Path.GetFileName(pathMap.SourcePath) : FileProbe.GetRelativePath(pathMap.SourcePath, filePath); string outputPath = pathMap.OutputPath; if (!pathMap.OutputPathIsFile) { // If output path is not a file we calculate the file path using the input filePath's relative location compared // to the output directory outputPath = Path.Combine(outputPath, relativePath); outputPath = Path.ChangeExtension(outputPath, ".js"); } return(outputPath); } } ChutzpahTracer.TraceError("Can't find location for generated path on {0}", filePath); return(null); }
public ChutzpahWebServerHost CreateServer(ChutzpahWebServerConfiguration configuration) { if (ChutzpahWebServerHost.ActiveWebServer != null && ChutzpahWebServerHost.ActiveWebServer.RootPath.Equals(configuration.RootPath, StringComparison.OrdinalIgnoreCase)) { // If the requested server is already running just re-use it return(ChutzpahWebServerHost.ActiveWebServer); } var hostConfiguration = new HostConfiguration { RewriteLocalhost = true, UrlReservations = new UrlReservations { CreateAutomatically = true } }; var port = GetNextAvailablePort(configuration.DefaultPort.Value); var builtInDependencyFolder = fileProbe.BuiltInDependencyDirectory; ChutzpahTracer.TraceInformation("Creating Web Server Host at path {0} and port {1}", configuration.RootPath, port); var host = new NancyHost(new Uri(string.Format("http://localhost:{0}", port)), new NancySettingsBootstrapper(configuration.RootPath, builtInDependencyFolder), hostConfiguration); host.Start(); var chutzpahWebServerHost = ChutzpahWebServerHost.Create(host, configuration.RootPath, port); return(chutzpahWebServerHost); }
public void DiscoverTests(IEnumerable <string> sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) { if (Environment.GetEnvironmentVariable("ATTACH_DEBUGGER_CHUTZPAH") != null) { Debugger.Launch(); } ChutzpahTracer.TraceInformation("Begin Test Adapter Discover Tests"); var settingsProvider = discoveryContext.RunSettings.GetSettings(AdapterConstants.SettingsName) as ChutzpahAdapterSettingsProvider; var settings = settingsProvider != null ? settingsProvider.Settings : new ChutzpahAdapterSettings(); ChutzpahTracingHelper.Toggle(settings.EnabledTracing); var testOptions = new TestOptions { MaxDegreeOfParallelism = settings.MaxDegreeOfParallelism, ChutzpahSettingsFileEnvironments = new ChutzpahSettingsFileEnvironments(settings.ChutzpahSettingsFileEnvironments) }; ChutzpahTracer.TraceInformation("Sending discovered tests to test case discovery sink"); var callback = new ParallelRunnerCallbackAdapter(new DiscoveryCallback(logger, discoverySink)); var testCases = testRunner.DiscoverTests(sources, testOptions, callback); ChutzpahTracer.TraceInformation("End Test Adapter Discover Tests"); }
public void PrepareTestHarnessForCoverage(TestHarness harness, IFrameworkDefinition definition, ChutzpahTestSettingsFile testSettingsFile) { string blanketScriptName = GetBlanketScriptName(definition, testSettingsFile); // Construct array of scripts to exclude from instrumentation/coverage collection. var filesToExcludeFromCoverage = new List <string>(); var filesToIncludeInCoverage = new List <string>(); var extensionMap = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); foreach (TestHarnessItem refScript in harness.ReferencedScripts.Where(rs => rs.HasFile)) { // Skip files which the user is asking us to exclude if (!IsFileEligibleForInstrumentation(refScript.ReferencedFile.Path)) { filesToExcludeFromCoverage.Add(refScript.Attributes["src"]); } else { refScript.Attributes["type"] = "text/blanket"; // prevent Phantom/browser parsing } // Build extension map for when we conver to regex the include/exclude patterns if (!string.IsNullOrEmpty(refScript.ReferencedFile.GeneratedFilePath)) { var sourceExtension = Path.GetExtension(refScript.ReferencedFile.Path); extensionMap[sourceExtension] = ".js"; } } // Construct array of scripts to exclude from instrumentation/coverage collection. filesToExcludeFromCoverage.AddRange( harness.TestFrameworkDependencies.Concat(harness.CodeCoverageDependencies) .Where(dep => dep.HasFile && IsScriptFile(dep.ReferencedFile)) .Select(dep => dep.Attributes["src"]) .Concat(excludePatterns.Select(f => ToRegex(f, extensionMap)))); filesToIncludeInCoverage.AddRange(includePatterns.Select(f => ToRegex(f, extensionMap))); // Name the coverage object so that the JS runner can pick it up. harness.ReferencedScripts.Add(new Script(string.Format("window.{0}='_$blanket';", Constants.ChutzpahCoverageObjectReference))); // Configure Blanket. TestHarnessItem blanketMain = harness.CodeCoverageDependencies.Single( d => d.Attributes.ContainsKey("src") && (d.Attributes["src"].EndsWith(blanketScriptName) || d.Attributes["src"].Contains(blanketScriptName + "?"))); string dataCoverNever = "[" + string.Join(",", filesToExcludeFromCoverage.Select(file => "'" + file + "'")) + "]"; string dataCoverOnly = filesToIncludeInCoverage.Any() ? "[" + string.Join(",", filesToIncludeInCoverage.Select(file => "'" + file + "'")) + "]" : "//.*/"; ChutzpahTracer.TraceInformation("Adding data-cover-never attribute to blanket: {0}", dataCoverNever); blanketMain.Attributes.Add("data-cover-flags", "ignoreError autoStart"); blanketMain.Attributes.Add("data-cover-only", dataCoverOnly); blanketMain.Attributes.Add("data-cover-never", dataCoverNever); blanketMain.Attributes.Add("data-cover-timeout", testSettingsFile.CodeCoverageTimeout.HasValue ? testSettingsFile.CodeCoverageTimeout.Value.ToString() : "5000"); }
/// <summary> /// Handler to react to project load/unload events. /// </summary> private void OnSolutionProjectChanged(object sender, SolutionEventsListenerEventArgs e) { if (e != null) { string projectPath = VsSolutionHelper.GetProjectPath(e.Project); var files = FindPotentialTestFiles(e.Project); if (e.ChangedReason == SolutionChangedReason.Load) { ChutzpahTracer.TraceInformation("Project Loaded: '{0}'", projectPath); UpdateChutzpahEnvironmentForProject(projectPath); UpdateTestContainersAndFileWatchers(files, true); } else if (e.ChangedReason == SolutionChangedReason.Unload) { ChutzpahTracer.TraceInformation("Project Unloaded: '{0}'", projectPath); RemoveChutzpahEnvironmentForProject(projectPath); UpdateTestContainersAndFileWatchers(files, false); } } // Do not fire OnTestContainersChanged here. // This will cause us to fire this event too early before the UTE is ready to process containers and will result in an exception. // The UTE will query all the TestContainerDiscoverers once the solution is loaded. }
private ChutzpahWebServerHost BuildHost(string rootPath, int defaultPort, string builtInDependencyFolder) { var attemptLimit = Constants.WebServerCreationAttemptLimit; var success = false; do { // We can try multiple times to build the webserver. The reason is there is a possible race condition where // between when we find a free port and when we start the server that port may have been taken. To mitigate this we // can retry to hopefully avoid this issue. attemptLimit--; var port = FindFreePort(defaultPort); try { ChutzpahTracer.TraceInformation("Creating Web Server Host at path {0} and port {1}", rootPath, port); var host = new WebHostBuilder() .UseUrls($"http://localhost:{port}") .UseContentRoot(rootPath) .UseWebRoot("") .UseKestrel() .Configure((app) => { var env = (IHostingEnvironment)app.ApplicationServices.GetService(typeof(IHostingEnvironment)); app.UseStaticFiles(new StaticFileOptions { OnPrepareResponse = AddFileCacheHeaders, ServeUnknownFileTypes = true, FileProvider = new ChutzpahServerFileProvider(env.ContentRootPath, builtInDependencyFolder) }); app.Run(async(context) => { if (context.Request.Path == "/") { await context.Response.WriteAsync($"Chutzpah Web Server (Version { Assembly.GetEntryAssembly().GetName().Version})"); } else { context.Response.StatusCode = (int)HttpStatusCode.NotFound; } }); }) .Build(); host.Start(); success = true; return(ChutzpahWebServerHost.Create(host, rootPath, port)); } catch (Exception ex) when(attemptLimit > 0) { ChutzpahTracer.TraceError(ex, "Unable to create web server host at path {0} and port {1}. Trying again...", rootPath, port); } }while (!success && attemptLimit > 0); throw new ChutzpahException("Failed to create web server. This should never be hit!"); }
/// <summary> /// Fire Events to Notify testcontainerdiscoverer listeners that containers have changed. /// This is the push notification VS uses to update the unit test window. /// /// The initialContainerSearch check is meant to prevent us from notifying VS about updates /// until it is ready /// </summary> private void OnTestContainersChanged() { ChutzpahTracer.TraceInformation("Begin OnTestContainersChanged"); if (TestContainersUpdated != null && !initialContainerSearch) { TestContainersUpdated(this, EventArgs.Empty); } ChutzpahTracer.TraceInformation("End OnTestContainersChanged"); }
int GetNextAvailablePort(int port) { while (!IsPortOpen(port)) { ChutzpahTracer.TraceWarning("Unable to get port {0} so trying next one", port); port++; } return(port); }
public static void Toggle(bool enable) { var path = Path.Combine(Path.GetTempPath(), Chutzpah.Constants.LogFileName); if (enable) { ChutzpahTracer.AddFileListener(path); } else { ChutzpahTracer.RemoveFileListener(path); } }
public void Dispose() { try { ChutzpahTracer.TraceInformation("Tearing down Web Server Host at path {0} and port {1}", RootPath, Port); IsRunning = false; WebHost.Dispose(); } catch (Exception e) { ChutzpahTracer.TraceError(e, "Error tearing down Web Server Host at path {0} and port {1}", RootPath, Port); } }
public void CheckTracing() { var path = Path.Combine(Path.GetTempPath(), Chutzpah.Constants.LogFileName); if (Settings.EnabledTracing) { ChutzpahTracer.AddFileListener(path); } else { ChutzpahTracer.RemoveFileListener(path); } }
private void SerializeObject(string name, ConcurrentDictionary <string, Tuple <DateTime, string> > objectToSerialize) { try { using (var stream = filesystem.Open(name, FileMode.Create, FileAccess.Write)) { binarySerializer.Serialize(stream, objectToSerialize); } } catch (IOException e) { ChutzpahTracer.TraceError(e, "Failed to save compiler cache"); } }
private bool IsTestFile(string path) { try { return(HasTestFileExtension(path) && testRunner.IsTestFile(path, settingsMapper.Settings.ChutzpahSettingsFileEnvironmentsWrapper)); } catch (Exception e) { ChutzpahTracer.TraceError(e, "ChutzpahTestContainerDiscoverer::Error when detecting a test file"); logger.Log("Error when detecting a test file", "ChutzpahTestContainerDiscoverer", e); } return(false); }
/// <summary> /// Handler to react to test file Add/remove/rename andcontents changed events /// </summary> private void OnProjectItemChanged(object sender, TestFileChangedEventArgs e) { ChutzpahTracer.TraceInformation("Begin OnProjectItemChanged"); if (e != null) { // If a chutzpah.json file changed then we set the flag to // ensure next time get if (fileProbe.IsChutzpahSettingsFile(e.File.Path)) { forceFullContainerRefresh = true; return; } // Don't do anything for files we are sure can't be test files if (!HasTestFileExtension(e.File.Path)) { return; } logger.Log(string.Format("Changed detected for {0} with change type of {1}", e.File, e.ChangedReason), "ChutzpahTestContainerDiscoverer", LogType.Information); switch (e.ChangedReason) { case TestFileChangedReason.Added: ChutzpahTracer.TraceInformation("Adding watch on {0}", e.File.Path); testFilesUpdateWatcher.AddWatch(e.File.Path); AddTestContainerIfTestFile(e.File); break; case TestFileChangedReason.Removed: ChutzpahTracer.TraceInformation("Removing watch on {0}", e.File.Path); testFilesUpdateWatcher.RemoveWatch(e.File.Path); RemoveTestContainer(e.File); break; case TestFileChangedReason.Changed: AddTestContainerIfTestFile(e.File); break; } OnTestContainersChanged(); } ChutzpahTracer.TraceInformation("End OnProjectItemChanged"); }
private IEnumerable <TestFileCandidate> FindPotentialTestFiles() { try { ChutzpahTracer.TraceInformation("Begin enumerating loaded projects for test files"); var solution = (IVsSolution)serviceProvider.GetService(typeof(SVsSolution)); var loadedProjects = solution.EnumerateLoadedProjects(__VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION).OfType <IVsProject>(); return(loadedProjects.SelectMany(FindPotentialTestFiles).ToList()); } finally { ChutzpahTracer.TraceInformation("End enumerating loaded projects for test files"); } }
/// <summary> /// Will remove a test container for a given file path /// </summary> /// <param name="file"></param> private void RemoveTestContainer(TestFileCandidate file) { // If a settings file don't add a container if (fileProbe.IsChutzpahSettingsFile(file.Path)) { return; } var index = cachedContainers.FindIndex(x => x.Source.Equals(file.Path, StringComparison.OrdinalIgnoreCase)); if (index >= 0) { ChutzpahTracer.TraceInformation("Removed test container for '{0}'", file.Path); cachedContainers.RemoveAt(index); } }
private void RunBatchCompile(ChutzpahTestSettingsFile testSettings) { try { var result = processHelper.RunBatchCompileProcess(testSettings.Compile); if (result.ExitCode > 0) { throw new ChutzpahCompilationFailedException(result.StandardError, testSettings.SettingsFileName); } } catch (Exception e) { ChutzpahTracer.TraceError(e, "Error during batch compile of {0}", testSettings.SettingsFileName); throw new ChutzpahCompilationFailedException(e.Message, testSettings.SettingsFileName, e); } }
/// <summary> /// Will remove a test container for a given file path /// </summary> /// <param name="file"></param> private void RemoveTestContainer(TestFileCandidate file) { // If a settings file don't add a container if (fileProbe.IsChutzpahSettingsFile(file.Path)) { return; } ITestContainer container; var res = cachedContainers.TryRemove(file.Path, out container); if (res) { ChutzpahTracer.TraceInformation("Removed test container for '{0}'", file.Path); } }
public void Will_run_multiple_files_and_aggregate_results() { var testRunner = TestRunner.Create(); ChutzpahTracer.Enabled = true; ChutzpahTracer.AddConsoleListener(); var tests = new List <string> { @"JS\Test\basic-qunit.js", @"JS\Test\basic-qunit.html" }; TestCaseSummary result = testRunner.RunTests(tests, new ExceptionThrowingRunnerCallback()); Assert.Equal(2, result.FailedCount); Assert.Equal(6, result.PassedCount); Assert.Equal(8, result.TotalCount); }
public void PrepareTestHarnessForCoverage(TestHarness harness, IFrameworkDefinition definition, ChutzpahTestSettingsFile testSettingsFile) { string blanketScriptName = GetBlanketScriptName(definition, testSettingsFile); // Construct array of scripts to exclude from instrumentation/coverage collection. var filesToExcludeFromCoverage = harness.TestFrameworkDependencies.Concat(harness.CodeCoverageDependencies) .Where(dep => dep.HasFile && IsScriptFile(dep.ReferencedFile)) .Select(dep => dep.Attributes["src"]) .Concat(excludePatterns.Select(ToRegex)) .ToList(); var filesToIncludeInCoverage = includePatterns.Select(ToRegex).ToList(); foreach (TestHarnessItem refScript in harness.ReferencedScripts.Where(rs => rs.HasFile)) { // Exclude files which the user is asking us to ignores if (!IsFileEligibleForInstrumentation(refScript.ReferencedFile.Path)) { filesToExcludeFromCoverage.Add(refScript.Attributes["src"]); } else { refScript.Attributes["type"] = "text/blanket"; // prevent Phantom/browser parsing } } // Name the coverage object so that the JS runner can pick it up. harness.ReferencedScripts.Add(new Script(string.Format("window.{0}='_$blanket';", Constants.ChutzpahCoverageObjectReference))); // Configure Blanket. TestHarnessItem blanketMain = harness.CodeCoverageDependencies.Single( d => d.Attributes.ContainsKey("src") && d.Attributes["src"].EndsWith(blanketScriptName)); string dataCoverNever = "[" + string.Join(",", filesToExcludeFromCoverage.Select(file => "'" + file + "'")) + "]"; string dataCoverOnly = filesToIncludeInCoverage.Any() ? "[" + string.Join(",", filesToIncludeInCoverage.Select(file => "'" + file + "'")) + "]" : "//.*/"; ChutzpahTracer.TraceInformation("Adding data-cover-never attribute to blanket: {0}", dataCoverNever); blanketMain.Attributes.Add("data-cover-flags", "ignoreError autoStart"); blanketMain.Attributes.Add("data-cover-only", dataCoverOnly); blanketMain.Attributes.Add("data-cover-never", dataCoverNever); }
public void Dispose() { try { ChutzpahTracer.TraceInformation("Tearing down Web Server Host at path {0} and port {1}", RootPath, Port); NancyHost.Dispose(); } catch (Exception e) { ChutzpahTracer.TraceError(e, "Error tearing down Web Server Host at path {0} and port {1}", RootPath, Port); } finally { // Set active server to null Interlocked.Exchange(ref activeWebServer, null); } }
/// <summary> /// Adds a test container for the given file if it is a test file. /// This will first remove any existing container for that file /// </summary> /// <param name="file"></param> private void AddTestContainerIfTestFile(TestFileCandidate file) { // If a settings file don't add a container if (fileProbe.IsChutzpahSettingsFile(file.Path)) { return; } var isTestFile = IsTestFile(file.Path); RemoveTestContainer(file); // Remove if there is an existing container if (isTestFile) { ChutzpahTracer.TraceInformation("Added test container for '{0}'", file.Path); var container = new JsTestContainer(this, file.Path.ToLowerInvariant(), AdapterConstants.ExecutorUri); cachedContainers[container.Source] = container; } }
private string GetOutputPath(string sourcePath, BatchCompileConfiguration compileConfiguration) { if (sourcePath.IndexOf(compileConfiguration.SourceDirectory, StringComparison.OrdinalIgnoreCase) >= 0) { var relativePath = FileProbe.GetRelativePath(compileConfiguration.SourceDirectory, sourcePath); var outputPath = Path.Combine(compileConfiguration.OutDirectory, relativePath); outputPath = Path.ChangeExtension(outputPath, ".js"); return(outputPath); } else { ChutzpahTracer.TraceWarning( "Can't find location for generated path on {0} since it is not inside of configured source dir {1}", sourcePath, compileConfiguration.SourceDirectory); } return(null); }
/// <summary> /// Comapre this test container to another one /// They are the same if same source and timestamp /// </summary> /// <param name="other"></param> /// <returns></returns> public int CompareTo(ITestContainer other) { var testContainer = other as JsTestContainer; if (testContainer == null) { return(-1); } var result = String.Compare(this.Source, testContainer.Source, StringComparison.OrdinalIgnoreCase); if (result != 0) { return(result); } ChutzpahTracer.TraceInformation("Test container comparision {0} vs {1} for {2}", this.timeStamp, testContainer.timeStamp, this.Source); return(this.timeStamp.CompareTo(testContainer.timeStamp)); }
private IEnumerable <TestFileCandidate> FindPotentialTestFiles(IVsProject project) { string projectPath = VsSolutionHelper.GetProjectPath(project); try { ChutzpahTracer.TraceInformation("Begin selecting potential test files from project '{0}'", projectPath); return((from item in VsSolutionHelper.GetProjectItems(project) let hasTestExtension = HasTestFileExtension(item) let isChutzpahSettingsFile = fileProbe.IsChutzpahSettingsFile(item) where !fileProbe.IsTemporaryChutzpahFile(item) && (hasTestExtension || isChutzpahSettingsFile) select new TestFileCandidate { Path = item }).ToList()); } finally { ChutzpahTracer.TraceInformation("End selecting potential test files from project '{0}'", projectPath); } }