Skip to content

Commit

Permalink
TS-38867 Fix formatting with CodeMaid
Browse files Browse the repository at this point in the history
  • Loading branch information
snowbagoly committed May 23, 2024
1 parent cc23ab2 commit 90daedc
Showing 1 changed file with 114 additions and 114 deletions.
228 changes: 114 additions & 114 deletions UploadDaemon_Test/UploadDaemonSystemTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,37 @@

namespace UploadDaemon
{
[TestFixture]
public class UploadDaemonSystemTest
{
// 100663427 corresponds to MainViewModel#get_SelectedBitnessIndex in ProfilerGUI.pdb
// obtained with cvdump.exe
private static readonly uint ExistingMethodToken = 100663427;

private static string TargetDir => Path.Combine(TestUtils.TestTempDirectory, "targetdir");
private static string UploadDir => Path.Combine(TestUtils.TestTempDirectory, "upload");
private static string RevisionFile => Path.Combine(TestUtils.TestTempDirectory, "revision.txt");
private static string TestProgramRoot => Path.Combine(TestUtils.SolutionRoot.FullName, "test-data", "test-programs");
private static string PdbDirectory => TestUtils.TestDataDirectory;

[SetUp]
public void CreateTemporaryTestDir()
[TestFixture]
public class UploadDaemonSystemTest
{
var testDir = new DirectoryInfo(TestUtils.TestTempDirectory);
if (testDir.Exists)
{
testDir.Delete(true);
}

testDir.Create();
new DirectoryInfo(TargetDir).Create();
new DirectoryInfo(UploadDir).Create();
}

[Test]
public void TestTrailingSlashInUrl()
{
ConfigForProcess configWithTrailingSlash = Config.Read($@"
// 100663427 corresponds to MainViewModel#get_SelectedBitnessIndex in ProfilerGUI.pdb
// obtained with cvdump.exe
private static readonly uint ExistingMethodToken = 100663427;

private static string TargetDir => Path.Combine(TestUtils.TestTempDirectory, "targetdir");
private static string UploadDir => Path.Combine(TestUtils.TestTempDirectory, "upload");
private static string RevisionFile => Path.Combine(TestUtils.TestTempDirectory, "revision.txt");
private static string TestProgramRoot => Path.Combine(TestUtils.SolutionRoot.FullName, "test-data", "test-programs");
private static string PdbDirectory => TestUtils.TestDataDirectory;

[SetUp]
public void CreateTemporaryTestDir()
{
var testDir = new DirectoryInfo(TestUtils.TestTempDirectory);
if (testDir.Exists)
{
testDir.Delete(true);
}

testDir.Create();
new DirectoryInfo(TargetDir).Create();
new DirectoryInfo(UploadDir).Create();
}

[Test]
public void TestTrailingSlashInUrl()
{
ConfigForProcess configWithTrailingSlash = Config.Read($@"
match:
- profiler:
targetdir: {TargetDir}
Expand All @@ -49,9 +49,9 @@ public void TestTrailingSlashInUrl()
url: http://localhost:8080/
").CreateConfigForProcess("test.exe");

Assert.That(configWithTrailingSlash.Teamscale.Url, Is.EqualTo("http://localhost:8080"));
Assert.That(configWithTrailingSlash.Teamscale.Url, Is.EqualTo("http://localhost:8080"));

ConfigForProcess configWithoutTrailingSlash = Config.Read($@"
ConfigForProcess configWithoutTrailingSlash = Config.Read($@"
match:
- profiler:
targetdir: {TargetDir}
Expand All @@ -62,18 +62,18 @@ public void TestTrailingSlashInUrl()
url: http://localhost:8080
").CreateConfigForProcess("test.exe");

Assert.That(configWithoutTrailingSlash.Teamscale.Url, Is.EqualTo("http://localhost:8080"));
}
Assert.That(configWithoutTrailingSlash.Teamscale.Url, Is.EqualTo("http://localhost:8080"));
}

[Test]
public void TestSimpleDirectoryUpload()
{
string coverageFileName = "coverage_1_1.txt";
File.WriteAllText(Path.Combine(TargetDir, coverageFileName), @"Assembly=VersionAssembly:1 Version:4.0.0.0
[Test]
public void TestSimpleDirectoryUpload()
{
string coverageFileName = "coverage_1_1.txt";
File.WriteAllText(Path.Combine(TargetDir, coverageFileName), @"Assembly=VersionAssembly:1 Version:4.0.0.0
Process=foo.exe
Inlined=1:33555646:100678050");

new UploadDaemon().RunOnce(Config.Read($@"
new UploadDaemon().RunOnce(Config.Read($@"
match:
- profiler:
targetdir: {TargetDir}
Expand All @@ -82,25 +82,25 @@ public void TestSimpleDirectoryUpload()
directory: {UploadDir}
"));

Assert.Multiple(() =>
{
Assert.That(File.Exists(Path.Combine(UploadDir, coverageFileName)), Is.True, "file was uploaded successfully");
Assert.That(File.Exists(Path.Combine(TargetDir, coverageFileName)), Is.False, "file was removed from profiler output dir");
Assert.That(File.Exists(Path.Combine(TargetDir, "uploaded", coverageFileName)), Is.True, "file was archived");
});
}

[Test]
public void TestSimpleDirectoryLineCoverageUpload()
{
string coverageFileName = "coverage_1_1.txt";
File.WriteAllText(Path.Combine(TargetDir, coverageFileName), $@"Assembly=ProfilerGUI:2 Version:1.0.0.0
Assert.Multiple(() =>
{
Assert.That(File.Exists(Path.Combine(UploadDir, coverageFileName)), Is.True, "file was uploaded successfully");
Assert.That(File.Exists(Path.Combine(TargetDir, coverageFileName)), Is.False, "file was removed from profiler output dir");
Assert.That(File.Exists(Path.Combine(TargetDir, "uploaded", coverageFileName)), Is.True, "file was archived");
});
}

[Test]
public void TestSimpleDirectoryLineCoverageUpload()
{
string coverageFileName = "coverage_1_1.txt";
File.WriteAllText(Path.Combine(TargetDir, coverageFileName), $@"Assembly=ProfilerGUI:2 Version:1.0.0.0
Process=foo.exe
Inlined=2:{ExistingMethodToken}");

File.WriteAllText(RevisionFile, "revision: 12345");
File.WriteAllText(RevisionFile, "revision: 12345");

new UploadDaemon().RunOnce(Config.Read($@"
new UploadDaemon().RunOnce(Config.Read($@"
match:
- profiler:
targetdir: {TargetDir}
Expand All @@ -110,25 +110,25 @@ public void TestSimpleDirectoryLineCoverageUpload()
pdbDirectory: {PdbDirectory}
"));

IEnumerable<string> uploadedFiles = Directory.GetFiles(UploadDir);
IEnumerable<string> uploadedFiles = Directory.GetFiles(UploadDir);

Assert.Multiple(() =>
{
Assert.That(uploadedFiles.Select(file => Path.GetExtension(file)), Is.EquivalentTo(new string[] { ".simple", ".metadata" }));
Assert.That(File.Exists(Path.Combine(TargetDir, coverageFileName)), Is.False, "file was removed from profiler output dir");
Assert.That(File.Exists(Path.Combine(TargetDir, "uploaded", coverageFileName)), Is.True, "file was archived");
});
}
Assert.Multiple(() =>
{
Assert.That(uploadedFiles.Select(file => Path.GetExtension(file)), Is.EquivalentTo(new string[] { ".simple", ".metadata" }));
Assert.That(File.Exists(Path.Combine(TargetDir, coverageFileName)), Is.False, "file was removed from profiler output dir");
Assert.That(File.Exists(Path.Combine(TargetDir, "uploaded", coverageFileName)), Is.True, "file was archived");
});
}

[Test]
public void TestArchivePurging()
{
File.WriteAllText(Path.Combine(TargetDir, "coverage_1_1.txt"), @"Assembly=VersionAssembly:1 Version:4.0.0.0
[Test]
public void TestArchivePurging()
{
File.WriteAllText(Path.Combine(TargetDir, "coverage_1_1.txt"), @"Assembly=VersionAssembly:1 Version:4.0.0.0
Process=foo.exe
Inlined=1:33555646:100678050");
File.WriteAllText(Path.Combine(TargetDir, "coverage_1_2.txt"), @"");
File.WriteAllText(Path.Combine(TargetDir, "coverage_1_2.txt"), @"");

new UploadDaemon().RunOnce(Config.Read($@"
new UploadDaemon().RunOnce(Config.Read($@"
archivePurgingThresholdsInDays:
uploadedTraces: 0
emptyTraces: 0
Expand All @@ -140,21 +140,21 @@ public void TestArchivePurging()
directory: {UploadDir}
"));

IEnumerable<string> archivedFiles = Directory.GetFiles(TargetDir, "*.txt", SearchOption.AllDirectories);
Assert.That(archivedFiles, Is.Empty);
}
IEnumerable<string> archivedFiles = Directory.GetFiles(TargetDir, "*.txt", SearchOption.AllDirectories);
Assert.That(archivedFiles, Is.Empty);
}

[Test]
public void TestNet6EmbeddedAssembly()
{
string coverageFileName = "coverage_1_1.txt";
string targetAssembly = Path.Combine(TestProgramRoot, "Net6ConsoleApp.dll");
File.WriteAllText(Path.Combine(TargetDir, coverageFileName), $@"Assembly=ProfilerTestee:2 Version:1.0.0.0 Path:{targetAssembly}
[Test]
public void TestNet6EmbeddedAssembly()
{
string coverageFileName = "coverage_1_1.txt";
string targetAssembly = Path.Combine(TestProgramRoot, "Net6ConsoleApp.dll");
File.WriteAllText(Path.Combine(TargetDir, coverageFileName), $@"Assembly=ProfilerTestee:2 Version:1.0.0.0 Path:{targetAssembly}
Process={targetAssembly}
Inlined=2:100663298");
TeamscaleMockServer mockServer = new TeamscaleMockServer(1337);
mockServer.SetResponse(200);
new UploadDaemon().RunOnce(Config.Read($@"
TeamscaleMockServer mockServer = new TeamscaleMockServer(1337);
mockServer.SetResponse(200);
new UploadDaemon().RunOnce(Config.Read($@"
match:
- profiler:
targetdir: {TargetDir}
Expand All @@ -169,29 +169,29 @@ public void TestNet6EmbeddedAssembly()
"));

List<string> requests = mockServer.GetReceivedRequests();
mockServer.StopServer();
Assert.Multiple(() =>
{
Assert.That(requests[0], Contains.Substring("api/projects/TestProject/"));
Assert.That(requests[0], Contains.Substring("revision=master%3aHEAD"));
Assert.That(File.Exists(Path.Combine(TargetDir, coverageFileName)), Is.False, "File is in upload folder.");
Assert.That(File.Exists(Path.Combine(TargetDir, "uploaded", coverageFileName)), Is.True, "File was properly archived.");
});
}

[Test]
public void TestEmbeddedLibrarySetup()
{
string coverageFileName = "coverage_1_1.txt";
string programmAssembly = "Assembly=PdfizerConsole:2 Version:1.1.1.0 Path:" + Path.Combine(TestProgramRoot, "PdfizerConsole.exe");
string libraryAssembly = "Assembly=NetFrameworkEmbeddedLibrary:4 Version:1.0.0.0 Path:" + Path.Combine(TestProgramRoot, "NetFrameworkEmbeddedLibrary.dll");
string process = "Process=" + Path.Combine(TestProgramRoot, "PdfizerConsole.exe");
string coverageStatement = "Jitted=2:100663297";
File.WriteAllText(Path.Combine(TargetDir, coverageFileName), programmAssembly + "\n" + libraryAssembly + "\n" + process + "\n" + coverageStatement);
TeamscaleMockServer mockServer = new TeamscaleMockServer(1337);
mockServer.SetResponse(200);
new UploadDaemon().RunOnce(Config.Read($@"
List<string> requests = mockServer.GetReceivedRequests();
mockServer.StopServer();
Assert.Multiple(() =>
{
Assert.That(requests[0], Contains.Substring("api/projects/TestProject/"));
Assert.That(requests[0], Contains.Substring("revision=master%3aHEAD"));
Assert.That(File.Exists(Path.Combine(TargetDir, coverageFileName)), Is.False, "File is in upload folder.");
Assert.That(File.Exists(Path.Combine(TargetDir, "uploaded", coverageFileName)), Is.True, "File was properly archived.");
});
}

[Test]
public void TestEmbeddedLibrarySetup()
{
string coverageFileName = "coverage_1_1.txt";
string programmAssembly = "Assembly=PdfizerConsole:2 Version:1.1.1.0 Path:" + Path.Combine(TestProgramRoot, "PdfizerConsole.exe");
string libraryAssembly = "Assembly=NetFrameworkEmbeddedLibrary:4 Version:1.0.0.0 Path:" + Path.Combine(TestProgramRoot, "NetFrameworkEmbeddedLibrary.dll");
string process = "Process=" + Path.Combine(TestProgramRoot, "PdfizerConsole.exe");
string coverageStatement = "Jitted=2:100663297";
File.WriteAllText(Path.Combine(TargetDir, coverageFileName), programmAssembly + "\n" + libraryAssembly + "\n" + process + "\n" + coverageStatement);
TeamscaleMockServer mockServer = new TeamscaleMockServer(1337);
mockServer.SetResponse(200);
new UploadDaemon().RunOnce(Config.Read($@"
match:
- profiler:
targetdir: {TargetDir}
Expand All @@ -205,15 +205,15 @@ public void TestEmbeddedLibrarySetup()
partition: my_partition
"));
List<string> requests = mockServer.GetReceivedRequests();
mockServer.StopServer();
Assert.Multiple(() =>
{
Assert.That(requests[0], Contains.Substring("api/projects/MyFancyProject/"));
Assert.That(requests[0], Contains.Substring("revision=MyFancyRevision"));
Assert.That(File.Exists(Path.Combine(TargetDir, coverageFileName)), Is.False, "File is in upload folder.");
Assert.That(File.Exists(Path.Combine(TargetDir, "uploaded", coverageFileName)), Is.True, "File was properly archived.");
});
List<string> requests = mockServer.GetReceivedRequests();
mockServer.StopServer();
Assert.Multiple(() =>
{
Assert.That(requests[0], Contains.Substring("api/projects/MyFancyProject/"));
Assert.That(requests[0], Contains.Substring("revision=MyFancyRevision"));
Assert.That(File.Exists(Path.Combine(TargetDir, coverageFileName)), Is.False, "File is in upload folder.");
Assert.That(File.Exists(Path.Combine(TargetDir, "uploaded", coverageFileName)), Is.True, "File was properly archived.");
});
}
}
}
}

0 comments on commit 90daedc

Please sign in to comment.