Skip to content

Commit

Permalink
Print only whole version on release branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
nohwnd committed Aug 21, 2020
2 parents fd2748b + 1d30394 commit f5e870b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 14 deletions.
3 changes: 2 additions & 1 deletion scripts/verify-nupkgs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ function Unzip
function Verify-Nuget-Packages($packageDirectory)
{
Write-Log "Starting Verify-Nuget-Packages."
$expectedNumOfFiles = @{"Microsoft.CodeCoverage" = 29;
$expectedNumOfFiles = @{
"Microsoft.CodeCoverage" = 29;
"Microsoft.NET.Test.Sdk" = 13;
"Microsoft.TestPlatform" = 469;
"Microsoft.TestPlatform.Build" = 19;
Expand Down
17 changes: 14 additions & 3 deletions scripts/vsts-prebuild.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# Sets variables which are used across the build tasks.

$buildSuffix = $args[0]
$IsRtmBuild = $args[1]
param (
[Parameter(Mandatory)]
[string] $BuildSuffix,
[Parameter(Mandatory)]
[string] $IsRtmBuild,
[Parameter(Mandatory)]
$Branch
)

$TP_ROOT_DIR = (Get-Item (Split-Path $MyInvocation.MyCommand.Path)).Parent.FullName

Expand All @@ -11,9 +17,14 @@ $buildPrefix = $TpVersion.Trim()

if ($IsRtmBuild.ToLower() -eq "false")
{
if ($null -ne $Branch -and $Branch -like "refs/heads/rel/*")
{
$BuildSuffix = $BuildSuffix -replace "preview", "release"
}

$packageVersion = $buildPrefix+"-"+$buildSuffix
}
else
else
{
$packageVersion = $buildPrefix
$buildSuffix = [string]::Empty
Expand Down
18 changes: 14 additions & 4 deletions src/vstest.console/CommandLine/Executor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ internal int Execute(params string[] args)
}
else
{
this.PrintSplashScreen();
var isDiag = args != null && args.Any(arg => arg.StartsWith("--diag", StringComparison.OrdinalIgnoreCase));
this.PrintSplashScreen(isDiag);
}

int exitCode = 0;
Expand Down Expand Up @@ -375,10 +376,19 @@ private bool ExecuteArgumentProcessor(IArgumentProcessor processor, ref int exit
/// <summary>
/// Displays the Company and Copyright splash title info immediately after launch
/// </summary>
private void PrintSplashScreen()
private void PrintSplashScreen(bool isDiag)
{
string assemblyVersion = string.Empty;
assemblyVersion = Product.Version;
string assemblyVersion = Product.Version;
if (!isDiag)
{
var end = Product.Version?.IndexOf("-release");

if (end >= 0)
{
assemblyVersion = Product.Version?.Substring(0, end.Value);
}
}

string commandLineBanner = string.Format(CultureInfo.CurrentUICulture, CommandLineResources.MicrosoftCommandLineTitle, assemblyVersion);
this.Output.WriteLine(commandLineBanner, OutputLevel.Information);
this.Output.WriteLine(CommandLineResources.CopyrightCommandLineTitle, OutputLevel.Information);
Expand Down
15 changes: 9 additions & 6 deletions test/vstest.console.UnitTests/ExecutorUnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests
using Utilities;

using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources;
using System;

[TestClass]
public class ExecutorUnitTests
Expand Down Expand Up @@ -50,12 +51,14 @@ public void ExecutorPrintsSplashScreenTest()
Assert.IsNotNull(mockOutput.Messages.First().Message, "First Printed Message cannot be null or empty");

// Just check first 20 characters - don't need to check whole thing as assembly version is variable
Assert.IsTrue(
mockOutput.Messages.First()
.Message.Contains(CommandLineResources.MicrosoftCommandLineTitle.Substring(0, 20)),
"First Printed message must be Microsoft Copyright");

Assert.IsTrue(mockOutput.Messages.First().Message.EndsWith(assemblyVersion));
// "First Printed message must be Microsoft Copyright");
StringAssert.Contains(mockOutput.Messages.First().Message,
CommandLineResources.MicrosoftCommandLineTitle.Substring(0, 20));

var suffixIndex = assemblyVersion.IndexOf("-");
var version = suffixIndex == -1 ? assemblyVersion : assemblyVersion.Substring(0, suffixIndex);
StringAssert.Contains(mockOutput.Messages.First().Message,
version);
}

[TestMethod]
Expand Down

0 comments on commit f5e870b

Please sign in to comment.