/// <inheritdoc /> public override void BxlInvocation(BxlInvocationEventData data) { var conf = data.Configuration.Logging; m_pathTranslator = GetPathTranslator(conf.SubstSource, conf.SubstTarget, PathTable); }
public static void WriteCmd(string commandLine, IIdeConfiguration config, AbsolutePath configFile, PathTable pathTable, [CanBeNull] PathTranslator translator) { var enlistmentRoot = configFile.GetParent(pathTable).ToString(pathTable); var builder = new StringBuilder(); builder.AppendLine("@echo off"); if (translator == null) { builder.AppendLine("cd " + enlistmentRoot); } else { enlistmentRoot = translator.Translate(enlistmentRoot); } // Remove trailing file path separators. enlistmentRoot = enlistmentRoot.TrimEnd('\\'); foreach (DictionaryEntry envVar in Environment.GetEnvironmentVariables()) { var key = (string)envVar.Key; var value = (string)envVar.Value; // If the value contains '<' or '>', add escape character; otherwise we will see syntax error when running build.cmd. value = Regex.Replace(value, @"[<>]", m => $"^{m.Value}"); // Scrub newlines and tabs as they will break the generated build.cmd value = Regex.Replace(value, @"[\r,\n,\t]", m => " "); builder.AppendLine("Set " + key + "=" + value); } commandLine = FixCommandLine(commandLine); // Prepend to the command line the RunInSubst executable and its parameters int exeIndex = commandLine.IndexOf($"\\{Branding.ProductExecutableName}", StringComparison.OrdinalIgnoreCase); string binRoot = exeIndex > -1 ? commandLine.Substring(0, exeIndex) : Path.GetDirectoryName(AssemblyHelper.GetAssemblyLocation(System.Reflection.Assembly.GetEntryAssembly())); if (translator != null) { binRoot = translator.Translate(binRoot); } string substedCommandLine = I($@"""{binRoot}\RunInSubst.exe"" B={enlistmentRoot} {commandLine} /server+ @%~dp0\build.cmd.rsp @%~dp0\domino.cmd.rsp %*"); // Also add the legacy response file domino.rsp for old plugins builder.AppendLine(substedCommandLine); builder.AppendLine("set RETURN_CODE=%ERRORLEVEL%"); // Map the drive back. // RunInSubst is unmapping the drive to follow WDG protocol, but to run unit tests we need the drive still mapped. builder.AppendLine(string.Format(CultureInfo.InvariantCulture, "subst B: {0}", enlistmentRoot)); // Return the exit code of BuildXL. builder.AppendLine("exit /b %RETURN_CODE%"); builder.AppendLine(); var solutionDirPath = GetSolutionPath(config, pathTable).GetParent(pathTable).ToString(pathTable); File.WriteAllText(Path.Combine(solutionDirPath, "build.cmd.rsp"), string.Empty); File.WriteAllText(Path.Combine(solutionDirPath, "build.cmd"), builder.ToString()); // Legacy file to support old plugins File.WriteAllText(Path.Combine(solutionDirPath, "domino.cmd"), "@call %~dp0build.cmd %*"); File.WriteAllText(Path.Combine(solutionDirPath, "domino.cmd.rsp"), string.Empty); // Legacy response file for old plugin }
public bool IsSolutionInitialized() { if (Environment.OSVersion.Platform != PlatformID.MacOSX && Environment.OSVersion.Platform != PlatformID.Unix && _configuration.AllSettings("mm-ProfilerSetup") != "DONTRUN") { var minimizer = getMinimizer(); if (!File.Exists(minimizer.GetDBName())) { return(false); } var dbInfo = new FileInfo(minimizer.GetDBName()); if (dbInfo.Length == 0 && DateTime.Now.Subtract(dbInfo.CreationTime).TotalMinutes <= 2) { return(false); } } var hasValidMMFile = false; var cache = BootStrapper.Services.Locate <ICache>(); var projects = cache.GetAll <Project>(); foreach (var project in projects) { Logger.WriteDebug("Preparing existence check for project: " + project.Key); var assembly = project.GetAssembly(_configuration.CustomOutputPath); if (assembly == "") { Logger.WriteDebug("Could not build assembly path"); continue; } var extension = Path.GetExtension(assembly); try { var mm = Path.Combine(Path.GetDirectoryName(assembly), Path.GetFileNameWithoutExtension(assembly) + ".mm" + extension); mm = new PathTranslator(_configuration.WatchToken).Translate(mm); Logger.WriteDebug("Checking for the existence of " + mm); if (File.Exists(mm)) { hasValidMMFile = true; continue; } if (!File.Exists(assembly)) { if (project.Value != null) { project.Value.RebuildOnNextRun(); } continue; } File.Copy(assembly, mm); if (project.Value != null) { project.Value.RebuildOnNextRun(); } } catch (Exception ex) { Logger.WriteError("Failed to check for " + assembly); Logger.WriteError(ex.ToString()); } } return(hasValidMMFile); }
/// <summary> /// Process a created file response. /// </summary> public override void Process() { Manager manager = new Manager(Services.Repository.WorkingPath); String localPath = this.ReadLine(); String reposPath = this.ReadLine(); String entry = this.ReadLine(); String flags = this.ReadLine(); String sizeStr = this.ReadLine(); PathTranslator orgPath = new PathTranslator(Services.Repository, reposPath); String localPathAndFilename = orgPath.LocalPathAndFilename; String directory = orgPath.LocalPath; bool compress = sizeStr[0] == 'z'; if (compress) { sizeStr = sizeStr.Substring(1); } int size = Int32.Parse(sizeStr); if (!Directory.Exists(orgPath.LocalPath)) { Directory.CreateDirectory(orgPath.LocalPath); } if (Services.NextFile != null && Services.NextFile.Length > 0) { localPathAndFilename = Services.NextFile; Services.NextFile = null; } Factory factory = new Factory(); Entry e = (Entry) factory.CreateCvsObject(orgPath.CurrentDir, Entry.FILE_NAME, entry); if (e.IsBinaryFile) { Services.UncompressedFileHandler.ReceiveBinaryFile(Stream, localPathAndFilename, size); } else { Services.UncompressedFileHandler.ReceiveTextFile(Stream, localPathAndFilename, size); } e.Date = Services.NextFileDate; Services.NextFileDate = null; manager.Add(e); LOGGER.Debug("In created response, just added entry. File date=[" + e.Date + "]"); manager.SetFileTimeStamp(e.FullPath, e.TimeStamp, e.IsUtcTimeStamp); UpdateMessage message = new UpdateMessage(); message.Module = Services.Repository.WorkingDirectoryName; message.Repository = orgPath.RelativePath; message.Filename = e.Name; Services.SendMessage(message.Message); }
public PreProcessedTesRuns PreProcess(PreProcessedTesRuns preProcessed) { // Clean up profiler logs before we start var logFiles = getProfilerOutput(); cleanUpFiles(logFiles); var runMinimized = !(_isFullRun || minimizerIsDisabled() || _minimizerPaused); Logger.WriteDebug("Run minimized is " + runMinimized.ToString()); if (runMinimized) { _bus.Publish(new RunInformationMessage(InformationType.PreProcessing, "", "", typeof(MinimizingPreProcessor))); } var finalDetails = new List <RunInfo>(); var details = preProcessed.RunInfos; if (!minimizerGraphsAndRiskIsOff()) { try { var assemblies = GetAssemblies(); //var hash = details.ToDictionary(current => current.Assembly); if (!runMinimized || _runCount % 10 == 0) { _minimizer.LoadOldCachedFiles(assemblies); } _runCount++; var tests = _minimizer.GetTestsFor(assemblies); Logger.WriteDebug("minimizer returns " + tests.Count + " tests"); if (runMinimized) { var profiled = GetProfiledEntries(); Logger.WriteDebug("profiler returns " + profiled.Count() + " tests"); var all = Combine(tests, profiled); //TODO THIS IS A HACK TO ENRICH PROFILED TESTS, REFACTOR ME foreach (var t in all) { var original = t.TestAssembly .Replace(".mm.dll", ".dll") .Replace(".mm.exe", ".exe"); var testAssembly = original; testAssembly = new PathTranslator(_configuration.WatchToken).TranslateFrom(testAssembly); if (testAssembly == null) { testAssembly = original; } Logger.WriteDebug("Translated TestAssembly is: " + testAssembly + " original is: " + t.TestAssembly); var current = details.FirstOrDefault(x => x.Assembly.Equals(testAssembly)); if (current == null) { current = finalDetails.FirstOrDefault(x => x.Assembly.Equals(testAssembly)); if (current == null) { current = GetRunInfoFromAssembly(testAssembly); } if (current == null) { throw new Exception("unable to match assembly for test. - assembly is " + testAssembly); } if (!finalDetails.Exists(x => x.Assembly.Equals(testAssembly))) { finalDetails.Add(current); } } foreach (var s in t.TestRunners) { var runner = ConvertStringToTestRunnerEnum(s); var test = getTestSignature(t, runner); Logger.WriteDetails(string.Format("Adding test {0} to runner {1} on run info {2}", test, runner, current.Assembly)); current.AddTestsToRun(runner, test); } } if (runMinimized) { addCurrentBrokenTests(details); } foreach (var detail in details) { detail.ShouldOnlyRunSpcifiedTestsFor(TestRunner.Any); } Logger.WritePreprocessor(string.Format("Found {0} affected tests", tests.Count)); _bus.Publish(new AssembliesMinimizedMessage()); finalDetails.AddRange(details); } } catch (Exception ex) { Logger.WriteError(ex.ToString()); var newDetails = new List <RunInfo>(); foreach (var detail in details) { var newDetail = new RunInfo(detail.Project); newDetail.SetAssembly(detail.Assembly); if (detail.ShouldBeBuilt) { newDetail.ShouldBuild(); } newDetails.Add(newDetail); } } Logger.WriteDebug("Running 2nd generation garbage collection"); GC.Collect(2); Logger.WriteDebug("Waiting for finalizers"); GC.WaitForPendingFinalizers(); Logger.WriteDebug("GC done"); } Logger.WriteDebug("Getting profiler wrapper"); _profilerWrapper = getProfilerWrapper(); if (!runMinimized) { var wrapper = _profilerWrapper; _profilerWrapper = null; Logger.WriteDebug("Returning original runinfos"); return(new PreProcessedTesRuns(wrapper, preProcessed.RunInfos)); // return original runInfos } finalDetails.ForEach(x => _runsToProfile.Add(x.CloneToTestRunInfo())); Logger.WriteDebug("Returning modified details"); return(new PreProcessedTesRuns(_profilerWrapper, finalDetails.ToArray())); }