-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuildTests.cs
84 lines (67 loc) · 2.42 KB
/
BuildTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
using System.Runtime.InteropServices;
using FluentAssertions;
using IntegrationTests.Helpers;
namespace IntegrationTests;
[UsesVerify]
public class BuildTests
{
[Fact]
public Task DistributionStructure()
{
var distributionFolder = EnvironmentHelper.GetNukeBuildOutput();
var files = Directory.GetFiles(distributionFolder, "*", SearchOption.AllDirectories);
var relativesPaths = new List<string>(files.Length);
foreach (var file in files)
{
relativesPaths.Add(file.Substring(distributionFolder.Length));
}
relativesPaths.Sort(StringComparer.Ordinal);
var systemName = GetSystemName();
return Verifier.Verify(relativesPaths)
.UseTextForParameters(systemName)
.DisableDiff();
}
#if NET
[Fact]
public void NetFolderDoesNotContainAnyLibraryFromAdditionalStore()
{
var distributionFolder = EnvironmentHelper.GetNukeBuildOutput();
var netFilePaths = Directory.GetFiles(Path.Join(distributionFolder, "net"), "*", SearchOption.AllDirectories);
var additionalStoreFilePaths = Directory.GetFiles(Path.Join(distributionFolder, "store"), "*", SearchOption.AllDirectories);
var netFileNames = netFilePaths.Select(Path.GetFileNameWithoutExtension).ToArray();
var additionalStoreFileNames = additionalStoreFilePaths.Select(Path.GetFileNameWithoutExtension).Distinct().ToArray();
netFileNames.Should().NotContain(additionalStoreFileNames);
}
#endif
private static string GetSystemName()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
return "osx";
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
if (Environment.GetEnvironmentVariable("IsAlpine") == "true")
{
return $"alpine-linux-{GetPlatform()}";
}
return $"linux-{GetPlatform()}";
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return "windows";
}
return "unknown";
}
private static string GetPlatform()
{
return RuntimeInformation.ProcessArchitecture switch
{
Architecture.X64 => "x64",
Architecture.Arm64 => "arm64",
_ => throw new PlatformNotSupportedException()
};
}
}