Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SmokeTests use repo infrastructure #19290

Merged
merged 79 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
a3a75bd
Make SmokeTests use repo infrastructure
ViktorHofer Apr 3, 2024
15501b2
PR feedback
ViktorHofer Apr 3, 2024
29a19a4
Fixes
ViktorHofer Apr 3, 2024
1b35086
More PR feedback
ViktorHofer Apr 3, 2024
1f6c7e9
Better calculate SdkTarballPath and SourceBuiltSdkVersion
ViktorHofer Apr 3, 2024
a8ae19c
Clean-up
ViktorHofer Apr 3, 2024
1b96515
Merge branch 'main' into RefactorSmokeTests
ViktorHofer Apr 3, 2024
45cdca3
Add restore flag
ViktorHofer Apr 4, 2024
c1b59a7
Merge branch 'RefactorSmokeTests' of https://github.com/dotnet/instal…
ViktorHofer Apr 4, 2024
812c3d9
Fix bugs
ViktorHofer Apr 4, 2024
025bfe6
Fix SDK version
ViktorHofer Apr 4, 2024
b1b8fc9
YML updates
ViktorHofer Apr 4, 2024
9552f76
nit
ViktorHofer Apr 4, 2024
6263ca4
Merge branch 'main' into RefactorSmokeTests
ViktorHofer Apr 4, 2024
ba97bfa
Update Config.cs
ViktorHofer Apr 4, 2024
0169f88
Update build.ps1
ViktorHofer Apr 4, 2024
0d06bd5
More fixes and clean-up
ViktorHofer Apr 4, 2024
594b289
More fixes and clean-up
ViktorHofer Apr 4, 2024
458085f
Updates to smoketest dependency and revert most of DetermineSourceBui…
ViktorHofer Apr 4, 2024
53c3f02
Fix missing Project tag
ViktorHofer Apr 4, 2024
d4727b9
Revert the non desirable changes in instaler.proj
ViktorHofer Apr 4, 2024
33709bd
Missed one
ViktorHofer Apr 4, 2024
4e1ecae
One more
ViktorHofer Apr 4, 2024
0709b16
Improve condition in smoketests
ViktorHofer Apr 4, 2024
d8de1bd
Fix windows script
ViktorHofer Apr 4, 2024
a509077
Fix missing \
ViktorHofer Apr 4, 2024
5af6d28
Add verbosity
ViktorHofer Apr 4, 2024
8ee8c9f
Allow to override nuget cache and don't incrementally re-build VMR fo…
ViktorHofer Apr 4, 2024
486fed2
Comment indentation in YML
ViktorHofer Apr 4, 2024
d8b6ace
Update sdk-diff-tests.yml
ViktorHofer Apr 4, 2024
531c354
Restore tasks correctly and avoid locking issues
ViktorHofer Apr 4, 2024
ded55a3
Merge branch 'RefactorSmokeTests' of https://github.com/dotnet/instal…
ViktorHofer Apr 4, 2024
6cc17e1
Don't set NUGET_PACKAGES
ViktorHofer Apr 4, 2024
3b79346
Fix unbound variable
ViktorHofer Apr 4, 2024
38ad0a8
Merge remote-tracking branch 'origin/main' into RefactorSmokeTests
ViktorHofer Apr 4, 2024
f385b51
Update Microsoft.DotNet.UnifiedBuild.Tests.csproj
ViktorHofer Apr 4, 2024
bdfacca
Update vmr-build.yml
ViktorHofer Apr 4, 2024
3a6300f
Update Directory.Build.props
ViktorHofer Apr 4, 2024
d0666dc
Update Directory.Build.props
ViktorHofer Apr 4, 2024
987bd49
Update Directory.Build.props
ViktorHofer Apr 4, 2024
239ef21
Update README.md
ViktorHofer Apr 4, 2024
a8a4eb3
Fix NuGetPackageRoot
ViktorHofer Apr 4, 2024
1d15c16
Merge branch 'RefactorSmokeTests' of https://github.com/dotnet/instal…
ViktorHofer Apr 4, 2024
5001dfa
Really fix NuGetPackageRoot
ViktorHofer Apr 4, 2024
fb35970
Pass NUGET_PACKAGES to nuget-client
ViktorHofer Apr 4, 2024
d00d93d
Ignore smoke-tests package cache
ViktorHofer Apr 5, 2024
3f92629
Fix test invocation
ViktorHofer Apr 5, 2024
5109ea5
Fix binlog switch
ViktorHofer Apr 5, 2024
2322341
Add testNoBuild and fixes
ViktorHofer Apr 5, 2024
9644e02
Update build.ps1
ViktorHofer Apr 5, 2024
4757b02
Fix variable name
ViktorHofer Apr 5, 2024
ff44007
Update Microsoft.DotNet.SourceBuild.SmokeTests.csproj
ViktorHofer Apr 5, 2024
658c597
Set IsTestProject early enough
ViktorHofer Apr 5, 2024
6212fbc
Merge branch 'main' into RefactorSmokeTests
ViktorHofer Apr 5, 2024
711270c
Use IsUnitTestProject instead
ViktorHofer Apr 5, 2024
40176db
PR feedback
ViktorHofer Apr 5, 2024
52f69fc
Respect externally provided LogDirectory in tests
ViktorHofer Apr 5, 2024
540487f
Update artifacts logs lookup in YML
ViktorHofer Apr 5, 2024
1ed428d
Use TestResultsDir and improve paths
ViktorHofer Apr 5, 2024
db4436e
Fix test execution and introduce TestUtilities project
ViktorHofer Apr 6, 2024
73c57a4
Merge remote-tracking branch 'origin/main' into RefactorSmokeTests
ViktorHofer Apr 6, 2024
a0873f6
More test fixes
ViktorHofer Apr 6, 2024
dc42e60
Simplify TestExtensions
ViktorHofer Apr 6, 2024
e5b83be
Entry-point fixes
ViktorHofer Apr 6, 2024
4a6ddca
Fix NuGetPackagesRoot and log filename
ViktorHofer Apr 6, 2024
3d69206
Add dotnet-eng online feed for smoke tests
ViktorHofer Apr 6, 2024
e0c777b
Don't use dotnet-eng or repo infra for smoke tests
ViktorHofer Apr 6, 2024
74c74a3
Upload artifacts also in failure case
ViktorHofer Apr 7, 2024
e83b6b8
Throw in case of not found tar artifact
ViktorHofer Apr 7, 2024
95c0a32
Downgrade version to 8.0.0 to avoid breaking change
ViktorHofer Apr 7, 2024
6eedd6b
Merge branch 'main' into RefactorSmokeTests
ViktorHofer Apr 8, 2024
911b11c
Include trx files in artifacts log publish
ViktorHofer Apr 8, 2024
3a9a7ba
Update vmr-build.yml
ViktorHofer Apr 8, 2024
ed0a320
Update SourceBuiltArtifactsTests.cs
ViktorHofer Apr 8, 2024
830d0ef
Remove --test-no-build/-testNoBuild switch
ViktorHofer Apr 8, 2024
3380d9f
Update xunit namespace to TestUtilities
ViktorHofer Apr 8, 2024
2f75f98
Fix build error in TestUtilities
ViktorHofer Apr 8, 2024
0c6058e
Fix compliation error and revert artifacts change
ViktorHofer Apr 8, 2024
9976f8a
revert unnecessary changes in SourceBuiltArtifactsTests
ViktorHofer Apr 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/SourceBuild/content/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@
/artifacts
/prereqs/packages
/src/nuget-client/NuGet.config
/test/Microsoft.DotNet.SourceBuild.SmokeTests/bin
/test/Microsoft.DotNet.SourceBuild.SmokeTests/obj
/test/Microsoft.DotNet.SourceBuild.SmokeTests/TestResults
*.binlog
1 change: 1 addition & 0 deletions src/SourceBuild/content/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
<PoisonMarkerFile>.prebuilt.xml</PoisonMarkerFile>
<PoisonReportDataFile>$(PackageReportDir)poison-catalog.xml</PoisonReportDataFile>
<PoisonedReportFile>$(PackageReportDir)poisoned.txt</PoisonedReportFile>
<PoisonUsageReportFile>$(PackageReportDir)poison-usage.xml</PoisonUsageReportFile>
</PropertyGroup>

<Import Project="$(GitInfoAllRepoPropsFile)" />
Expand Down
2 changes: 2 additions & 0 deletions src/SourceBuild/content/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="$(MicrosoftExtensionsFileSystemGlobbingVersion)" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="$(MicrosoftExtensionsLoggingConsoleVersion)" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingVersion)" />
<!-- External dependencies -->
<PackageVersion Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
</ItemGroup>

</Project>
31 changes: 14 additions & 17 deletions src/SourceBuild/content/build.proj
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<Project Sdk="Microsoft.Build.Traversal">

<PropertyGroup>
<!-- Fake, to satisfy the SDK. -->
<TargetFramework>netstandard2.0</TargetFramework>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="$(RepoProjectsDir)$(RootRepo).proj" />
<!-- TODO: condition the test projects on something like "$(BuildTest)' == 'true'". -->
<ProjectReference Include="test\Microsoft.DotNet.SourceBuild.SmokeTests\Microsoft.DotNet.SourceBuild.SmokeTests.csproj" />
<ProjectReference Include="test\Microsoft.DotNet.UnifiedBuild.Tests\Microsoft.DotNet.UnifiedBuild.Tests.csproj"
Condition="'$(ShortStack)' != 'true' and '$(PortableBuild)' == 'true' and '$(PgoInstrument)' != 'true'" />
</ItemGroup>

<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />

<Target Name="Build">
<Target Name="PrintInfo" BeforeTargets="Build">
<PropertyGroup>
<BuildModeInfoText Condition="'$(DotNetBuildSourceOnly)' == 'true'">source-build</BuildModeInfoText>
<BuildModeInfoText Condition="'$(DotNetBuildSourceOnly)' != 'true'">non-source-build</BuildModeInfoText>
</PropertyGroup>

<Message Text="Build Mode: $(BuildModeInfoText)" Importance="high" />
<Message Text="Build Environment: $(TargetArchitecture) $(Configuration) $(TargetOS) $(TargetRid)" Importance="high" />
</Target>

<MSBuild Projects="$(ToolsDir)init-build.proj;
$(RepoProjectsDir)$(RootRepo).proj"
Targets="Build"
BuildInParallel="false"
StopOnFirstFailure="true" />
<Target Name="InitBuild" BeforeTargets="Build">
<MSBuild Projects="$(ToolsDir)init-build.proj" Targets="Build" />
</Target>

<!-- Create a merge manifest from the individual repository manifest files. -->
Expand All @@ -48,8 +45,8 @@
<!-- Intentionally below the import to appear at the end. -->
<Target Name="LogBuildOutputFolders"
AfterTargets="Build">
<Message Importance="high" Text="Shipping packages are located in '$(ArtifactsShippingPackagesDir)'." />
<Message Importance="high" Text="Shipping assets are located in '$(ArtifactsAssetsDir)'." />
<Message Importance="high" Text="Shipping packages are located in '$(ArtifactsShippingPackagesDir)'." />
<Message Importance="high" Text="Shipping assets are located in '$(ArtifactsAssetsDir)'." />
</Target>

</Project>
2 changes: 1 addition & 1 deletion src/SourceBuild/content/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ while [[ $# > 0 ]]; do
;;
-test|-t)
export NUGET_PACKAGES=$NUGET_PACKAGES/smoke-tests
properties="$properties /t:RunSmokeTest"
properties="$properties /t:Test"
test=true
;;

Expand Down
10 changes: 6 additions & 4 deletions src/SourceBuild/content/eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@
-->
<PrivateSourceBuiltSdkVersion>9.0.100-preview.4.24179.1</PrivateSourceBuiltSdkVersion>
<PrivateSourceBuiltArtifactsVersion>9.0.100-preview.4.24179.1</PrivateSourceBuiltArtifactsVersion>
<!-- msbuild -->
<!-- command-line-api dependencies -->
<SystemCommandLineVersion>2.0.0-beta4.24126.1</SystemCommandLineVersion>
<!-- msbuild dependencies -->
<MicrosoftBuildVersion>17.8.3</MicrosoftBuildVersion>
<!-- runtime -->
<!-- runtime dependencies -->
<MicrosoftExtensionsFileSystemGlobbingVersion>9.0.0-preview.2.24128.5</MicrosoftExtensionsFileSystemGlobbingVersion>
<MicrosoftExtensionsLoggingConsoleVersion>9.0.0-preview.2.24128.5</MicrosoftExtensionsLoggingConsoleVersion>
<MicrosoftExtensionsLoggingVersion>9.0.0-preview.2.24128.5</MicrosoftExtensionsLoggingVersion>
<!-- command-line-api -->
<SystemCommandLineVersion>2.0.0-beta4.24126.1</SystemCommandLineVersion>
ViktorHofer marked this conversation as resolved.
Show resolved Hide resolved
<!-- external dependencies -->
<NewtonsoftJsonVersion>13.0.3</NewtonsoftJsonVersion>
</PropertyGroup>
</Project>
72 changes: 0 additions & 72 deletions src/SourceBuild/content/eng/build.sourcebuild.targets
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<Project>

<PropertyGroup>
<SmokeTestsDir>$([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'test', 'Microsoft.DotNet.SourceBuild.SmokeTests'))</SmokeTestsDir>
</PropertyGroup>

<PropertyGroup Condition="'$(EnablePoison)' == 'true'">
<PoisonUsageReportFile>$(PackageReportDir)poison-usage.xml</PoisonUsageReportFile>
</PropertyGroup>

<!-- After building, generate a prebuilt usage report. -->
<Target Name="ReportPrebuiltUsage"
AfterTargets="Build"
Expand Down Expand Up @@ -121,70 +113,6 @@
</Touch>
</Target>

<Target Name="RunSmokeTest">
<ItemGroup>
<SdkTarballItem Include="$(ArtifactsAssetsDir)dotnet-sdk*$(ArchiveExtension)" />
<SourceBuiltArtifactsItem Include="$(ArtifactsAssetsDir)$(SourceBuiltArtifactsTarballName).*$(ArchiveExtension)" />
</ItemGroup>

<PropertyGroup>
<CustomTestEnvVars Condition="'$(EnablePoison)' == 'true'">SMOKE_TESTS_POISON_REPORT_PATH=$(PoisonUsageReportFile);</CustomTestEnvVars>
<SdkTarballPath>%(SdkTarballItem.Identity)</SdkTarballPath>
<SourceBuiltArtifactsPath>%(SourceBuiltArtifactsItem.Identity)</SourceBuiltArtifactsPath>
<SmokeTestConsoleVerbosity Condition="'$(SmokeTestConsoleVerbosity)' == ''">normal</SmokeTestConsoleVerbosity>
</PropertyGroup>

<!-- Multiple loggers are specified so that results are captured in trx and pipelines can fail with AzDO pipeline warnings -->
<!-- Workaround https://github.com/dotnet/source-build/issues/4003 by disabling VSTestUseMSBuildOutput -->
<Exec Command="$(DotnetTool) test $(SmokeTestsDir) --logger:trx --logger:'console;verbosity=$(SmokeTestConsoleVerbosity)' -c $(Configuration) -p:VSTestUseMSBuildOutput=false"
IgnoreStandardErrorWarningFormat="true"
EnvironmentVariables="
SMOKE_TESTS_SDK_TARBALL_PATH=$(SdkTarballPath);
SMOKE_TESTS_SOURCEBUILT_ARTIFACTS_PATH=$(SourceBuiltArtifactsPath);
SMOKE_TESTS_TARGET_RID=$(TargetRid);
SMOKE_TESTS_PORTABLE_RID=$(PortableRid);
SMOKE_TESTS_CUSTOM_PACKAGES_PATH=$(CustomSourceBuiltPackagesPath);
$(CustomTestEnvVars)" />
</Target>

<Target Name="CreateSmokeTestPrereqsTarball"
AfterTargets="RunSmokeTest"
Condition="'$(SkipSmokeTestPrereqsTarballCreation)' != 'true'"
DependsOnTargets="
CheckIfCreateSmokeTestPrereqsExistToPack;
CreateSmokeTestPrereqsTarballIfPrereqsExist"/>

<Target Name="CheckIfCreateSmokeTestPrereqsExistToPack">
<PropertyGroup>
<SmokeTestsArtifactsDir>$(SmokeTestsDir)bin/$(Configuration)/$(NetCurrent)/</SmokeTestsArtifactsDir>
<SmokeTestsPackagesDir>$(SmokeTestsArtifactsDir)packages/</SmokeTestsPackagesDir>
</PropertyGroup>

<ItemGroup>
<SmokeTestsPrereqs Include="$(SmokeTestsPackagesDir)**/*.nupkg" />
</ItemGroup>

<Message Text="Found @(SmokeTestsPrereqs->Count()) prereqs in '$(SmokeTestsPackagesDir)'." Importance="High" />
</Target>

<Target Name="CreateSmokeTestPrereqsTarballIfPrereqsExist"
DependsOnTargets="DetermineSourceBuiltSdkVersion"
Condition="'@(SmokeTestsPrereqs->Count())' != '0'">
<PropertyGroup>
<SmokeTestPrereqsTarball>$(ArtifactsAssetsDir)dotnet-smoke-test-prereqs.$(SourceBuiltSdkVersion).$(TargetRid)$(ArchiveExtension)</SmokeTestPrereqsTarball>
<SmokeTestsPrereqPackagesDir>$(SmokeTestsArtifactsDir)prereq-packages/</SmokeTestsPrereqPackagesDir>
</PropertyGroup>

<Copy SourceFiles="@(SmokeTestsPrereqs)"
DestinationFolder="$(SmokeTestsPrereqPackagesDir)" />

<MakeDir Directories="$([System.IO.Path]::GetDirectoryName('$(SmokeTestPrereqsTarball)'))" />
<Exec Command="tar --numeric-owner -czf $(SmokeTestPrereqsTarball) ."
WorkingDirectory="$(SmokeTestsPrereqPackagesDir)"/>

<Message Importance="High" Text="Packaged smoke-test prereqs in '$(SmokeTestPrereqsTarball)'" />
</Target>

<Target Name="CreatePrebuiltsTarball"
AfterTargets="Build"
DependsOnTargets="
Expand Down
8 changes: 0 additions & 8 deletions src/SourceBuild/content/eng/tools/init-build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
UnpackTarballs;
BuildUnifiedBuildTasks;
BuildMSBuildSdkResolver;
RestoreUnifiedBuildValidationTests;
BuildLeakDetection;
ExtractToolPackage;
GenerateRootFs;
Expand Down Expand Up @@ -113,13 +112,6 @@
</Touch>
</Target>

<Target Name="RestoreUnifiedBuildValidationTests"
Condition="'$(ShortStack)' != 'true' and '$(PortableBuild)' == 'true' and '$(PgoInstrument)' != 'true'" >
<MSBuild Projects="../../test/Microsoft.DotNet.UnifiedBuild.Tests/Microsoft.DotNet.UnifiedBuild.Tests.csproj"
Targets="Restore"
Properties="MSBuildRestoreSessionId=$([System.Guid]::NewGuid())" />
</Target>

<Target Name="GenerateRootFs"
Condition="'$(BuildOS)' != 'windows' and '$(CrossBuild)' == 'true' and '$(ROOTFS_DIR)' == ''">
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,9 @@ public ArtifactsSizeTest(ITestOutputHelper outputHelper) : base(outputHelper)
}
}

[SkippableFact(Config.IncludeArtifactsSizeEnv, skipOnFalseEnv: true)]
[ConditionalFact(typeof(Config), nameOf(IncludeArtifactsSize))]
public void CompareArtifactsToBaseline()
{
Utilities.ValidateNotNullOrWhiteSpace(Config.SourceBuiltArtifactsPath, Config.SourceBuiltArtifactsPathEnv);
ViktorHofer marked this conversation as resolved.
Show resolved Hide resolved
Utilities.ValidateNotNullOrWhiteSpace(Config.SdkTarballPath, Config.SdkTarballPathEnv);
Utilities.ValidateNotNullOrWhiteSpace(Config.TargetRid, Config.TargetRidEnv);

var tarEntries = ProcessSdkAndArtifactsTarballs();
ScanForDifferences(tarEntries);
UpdateBaselineFile();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Reflection;
using Xunit;

namespace Microsoft.DotNet.SourceBuild.SmokeTests;

/// <summary>
/// A Fact that conditionally runs based on a type's boolean property member
/// </summary>
internal sealed class ConditionalFactAttribute : FactAttribute
{
public ConditionalFactAttribute(Type calleeType, string memberName, string? reason = null)
{
EvaluateSkip(calleeType, memberName, reason, (skip) => Skip = skip);
}

internal static void EvaluateSkip(Type calleeType, string memberName, string? reason = null, Action<string> setSkip)
{
TypeInfo typeInfo = calleeType.GetTypeInfo();
bool shouldRun = (bool?)typeInfo.GetProperty(memberName)?.GetValue(null) ?? false;
if (!shouldRun)
{
setSkip(reason ?? "Skipped");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Xunit;

namespace Microsoft.DotNet.SourceBuild.SmokeTests;

/// <summary>
/// A Theory that conditionally runs based on a type's boolean property member.
/// </summary>
internal sealed class ConditionalTheoryAttribute : TheoryAttribute
{
public ConditionalTheoryAttribute(Type calleeType, string memberName, string? reason = null)
{
ConditionalFactAttribute.EvaluateSkip(calleeType, memberName, reason, (skip) => Skip = skip);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,28 @@ namespace Microsoft.DotNet.SourceBuild.SmokeTests;

internal static class Config
{
public const string DotNetDirectoryEnv = "SMOKE_TESTS_DOTNET_DIR";
public const string ExcludeOmniSharpEnv = "SMOKE_TESTS_EXCLUDE_OMNISHARP";
public const string IncludeArtifactsSizeEnv = "SMOKE_TESTS_INCLUDE_ARTIFACTSSIZE";
public const string MsftSdkTarballPathEnv = "SMOKE_TESTS_MSFT_SDK_TARBALL_PATH";
public const string PoisonReportPathEnv = "SMOKE_TESTS_POISON_REPORT_PATH";
public const string PortableRidEnv = "SMOKE_TESTS_PORTABLE_RID";
public const string PrereqsPathEnv = "SMOKE_TESTS_PREREQS_PATH";
public const string CustomPackagesPathEnv = "SMOKE_TESTS_CUSTOM_PACKAGES_PATH";
public const string SdkTarballPathEnv = "SMOKE_TESTS_SDK_TARBALL_PATH";
public const string SourceBuiltArtifactsPathEnv = "SMOKE_TESTS_SOURCEBUILT_ARTIFACTS_PATH";
public const string TargetRidEnv = "SMOKE_TESTS_TARGET_RID";
public const string WarnSdkContentDiffsEnv = "SMOKE_TESTS_WARN_SDK_CONTENT_DIFFS";
public const string WarnLicenseScanDiffsEnv = "SMOKE_TESTS_WARN_LICENSE_SCAN_DIFFS";
public const string RunningInCIEnv = "SMOKE_TESTS_RUNNING_IN_CI";
public const string LicenseScanPathEnv = "SMOKE_TESTS_LICENSE_SCAN_PATH";
const string ConfigSwitchPrefix = "Microsoft.DotNet.SourceBuild.SmokeTests.";

public static string DotNetDirectory { get; } =
Environment.GetEnvironmentVariable(DotNetDirectoryEnv) ?? Path.Combine(Directory.GetCurrentDirectory(), ".dotnet");
public static string? MsftSdkTarballPath { get; } = Environment.GetEnvironmentVariable(MsftSdkTarballPathEnv);
public static string? PoisonReportPath { get; } = Environment.GetEnvironmentVariable(PoisonReportPathEnv);
public static string PortableRid { get; } = Environment.GetEnvironmentVariable(PortableRidEnv) ??
throw new InvalidOperationException($"'{Config.PortableRidEnv}' must be specified");
public static string? PrereqsPath { get; } = Environment.GetEnvironmentVariable(PrereqsPathEnv);
public static string? CustomPackagesPath { get; } = Environment.GetEnvironmentVariable(CustomPackagesPathEnv);
public static string? SdkTarballPath { get; } = Environment.GetEnvironmentVariable(SdkTarballPathEnv);
public static string? SourceBuiltArtifactsPath { get; } = Environment.GetEnvironmentVariable(SourceBuiltArtifactsPathEnv);
public static string TargetRid { get; } = Environment.GetEnvironmentVariable(TargetRidEnv) ??
throw new InvalidOperationException($"'{Config.TargetRidEnv}' must be specified");
public static string TargetArchitecture { get; } = TargetRid.Split('-')[1];
public static bool WarnOnSdkContentDiffs { get; } =
bool.TryParse(Environment.GetEnvironmentVariable(WarnSdkContentDiffsEnv), out bool warnOnSdkContentDiffs) && warnOnSdkContentDiffs;
public static bool WarnOnLicenseScanDiffs { get; } =
bool.TryParse(Environment.GetEnvironmentVariable(WarnLicenseScanDiffsEnv), out bool warnOnLicenseScanDiffs) && warnOnLicenseScanDiffs;
public static string DotNetDirectory => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(DotNetDirectory)) ?? throw new InvalidOperationException("DotNetDirectory must be specified");
public static string PortableRid => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(PortableRid)) ?? throw new InvalidOperationException("Portable RID must be specified");
public static string TargetRid => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(TargetRid)) ?? throw new InvalidOperationException("Target RID must be specified");

public static string? CustomPackagesPath => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(CustomPackagesPath));
public static bool ExcludeOmniSharpTests => bool.TryParse((string)AppContext.GetData(ConfigSwitchPrefix + nameof(ExcludeOmniSharpTests)), out bool excludeOmniSharpTests) && excludeOmniSharpTests;
public static bool IncludeArtifactsSize => bool.TryParse((string)AppContext.GetData(ConfigSwitchPrefix + nameof(IncludeArtifactsSize)), out bool includeArtifactsSize) && includeArtifactsSize;
public static string? LicenseScanPath => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(LicenseScanPath));
public static string? MsftSdkTarballPath => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(MsftSdkTarballPath));
public static string? PoisonReportPath => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(PoisonReportPath));
public static string? PrereqsPath => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(PrereqsPath));
public static string? SdkTarballPath => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(SdkTarballPath));
public static string? SourceBuiltArtifactsPath => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(SourceBuiltArtifactsPath));
public static bool WarnOnLicenseScanDiffs => bool.TryParse((string)AppContext.GetData(ConfigSwitchPrefix + nameof(WarnOnLicenseScanDiffs)), out bool warnOnLicenseScanDiffs) && warnOnLicenseScanDiffs;
public static bool WarnOnSdkContentDiffs => bool.TryParse((string)AppContext.GetData(ConfigSwitchPrefix + nameof(WarnOnSdkContentDiffs)), out bool warnOnSdkContentDiffs) && warnOnSdkContentDiffs;

// Indicates whether the tests are being run in the context of a CI pipeline
public static bool RunningInCI { get; } =
bool.TryParse(Environment.GetEnvironmentVariable(RunningInCIEnv), out bool runningInCI) && runningInCI;

public static string? LicenseScanPath { get; } = Environment.GetEnvironmentVariable(LicenseScanPathEnv);
public static bool RunningInCI => !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DOTNET_CI")) ||
!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("HELIX_WORKITEM_ROOT")) ||
ViktorHofer marked this conversation as resolved.
Show resolved Hide resolved
!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("AGENT_OS"));

public static string TargetArchitecture => TargetRid.Split('-')[1];
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private static void InitNugetConfig()
if (!Directory.Exists(Config.PrereqsPath))
{
throw new InvalidOperationException(
$"Prereqs path '{Config.PrereqsPath}' specified in {Config.PrereqsPathEnv} does not exist.");
$"Prereqs path '{Config.PrereqsPath}' specified via /p:SmokeTestsPrereqsPath='...' does not exist.");
}

string nugetConfig = File.ReadAllText(nugetConfigPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,15 @@ public class LicenseScanTests : TestBase

private readonly string _targetRepo;

public bool ShouldScanForLicenses => !string.IsNullOrWhiteSpace(Config.LicenseScanPath);

public LicenseScanTests(ITestOutputHelper outputHelper) : base(outputHelper)
{
Assert.NotNull(Config.LicenseScanPath);
_targetRepo = new DirectoryInfo(Config.LicenseScanPath).Name;
}

[SkippableFact(Config.LicenseScanPathEnv, skipOnNullOrWhiteSpaceEnv: true)]
[ConditionalFact(typeof(typeof(LicenseScanTests), nameof(ShouldScanForLicenses))]
ViktorHofer marked this conversation as resolved.
Show resolved Hide resolved
public void ScanForLicenses()
{
Assert.NotNull(Config.LicenseScanPath);
Expand Down
Loading
Loading