[Trait("Category", "mono-osx-failing")] // Disable on Mono OSX, since Mono doesn't implement EventSource. public void TestPerfLogEnabledProducedLogFile() { using (TestEnvironment testEnv = TestEnvironment.Create(_output)) { // Setup perf log. TransientTestFolder perfLogFolder = testEnv.CreateFolder(createFolder: true); testEnv.SetEnvironmentVariable("DOTNET_PERFLOG_DIR", perfLogFolder.Path); // Setup project directory. TransientTestFolder projectFolder = testEnv.CreateFolder(createFolder: true); TransientTestFile classLibrary = testEnv.CreateFile(projectFolder, "ClassLibrary.csproj", @"<Project> <Target Name=""ClassLibraryTarget""> <Message Text=""ClassLibraryBuilt""/> </Target> </Project> "); string projectPath = Path.Combine(projectFolder.Path, "ClassLibrary.csproj"); string msbuildParameters = "\"" + projectPath + "\""; RunnerUtilities.ExecMSBuild(msbuildParameters, out bool successfulExit); successfulExit.ShouldBeTrue(); // Look for the file. // NOTE: We don't explicitly look for one file because it's possible that more components will add files that will show up here. // It's most important to ensure that at least one file shows up because any others that show up will be there because MSBuild properly // enabled this functionality. string[] files = Directory.GetFiles(perfLogFolder.Path, "perf-*.log"); files.ShouldNotBeEmpty(); files.ShouldAllBe(f => new FileInfo(f).Length > 0); } }
public void TestPerfLogDirectoryDoesNotExist() { using (TestEnvironment testEnv = TestEnvironment.Create(_output)) { // Setup invalid perf log directory. TransientTestFolder perfLogFolder = testEnv.CreateFolder(createFolder: true); string perfLogPath = Path.Combine(perfLogFolder.Path, "logs"); testEnv.SetEnvironmentVariable("DOTNET_PERFLOG_DIR", perfLogPath); // Setup project directory. TransientTestFolder projectFolder = testEnv.CreateFolder(createFolder: true); TransientTestFile classLibrary = testEnv.CreateFile(projectFolder, "ClassLibrary.csproj", @"<Project> <Target Name=""ClassLibraryTarget""> <Message Text=""ClassLibraryBuilt""/> </Target> </Project> "); string projectPath = Path.Combine(projectFolder.Path, "ClassLibrary.csproj"); string msbuildParameters = "\"" + projectPath + "\""; Directory.Exists(perfLogPath).ShouldBeFalse(); RunnerUtilities.ExecMSBuild(msbuildParameters, out bool successfulExit); successfulExit.ShouldBeTrue(); Directory.Exists(perfLogPath).ShouldBeFalse(); } }
public void ExerciseCacheSerialization() { AssemblyRegistrationCache arc = new(); arc.AddEntry("foo", "bar"); AssemblyRegistrationCache arc2 = null; using (TestEnvironment env = TestEnvironment.Create()) { TransientTestFile file = env.CreateFile(); arc.SerializeCache(file.Path, null); arc2 = StateFileBase.DeserializeCache(file.Path, null, typeof(AssemblyRegistrationCache)) as AssemblyRegistrationCache; } arc2._assemblies.Count.ShouldBe(arc._assemblies.Count); arc2._assemblies[0].ShouldBe(arc._assemblies[0]); arc2._typeLibraries.Count.ShouldBe(arc._typeLibraries.Count); arc2._typeLibraries[0].ShouldBe(arc._typeLibraries[0]); }