Skip to content

Commit

Permalink
When time increases by a digit, overwrite NodeStatus (#9563)
Browse files Browse the repository at this point in the history
Fixes #9562 by triggering a full-line redraw when the length of the duration string increases.
  • Loading branch information
rainersigwald authored Dec 21, 2023
1 parent 40f51a5 commit a1ad6b8
Show file tree
Hide file tree
Showing 46 changed files with 274 additions and 88 deletions.
61 changes: 61 additions & 0 deletions .vsts-dotnet-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ jobs:
mergeTestResults: true
continueOnError: true
condition: always()
- task: CmdLine@2
displayName: 'Set flag to publish Verify *.received.* files when test step fails'
condition: failed()
inputs:
script: 'echo "##vso[task.setvariable variable=publishverify]Yes"'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: logs'
inputs:
Expand All @@ -49,6 +54,22 @@ jobs:
ArtifactName: 'FullOnWindows test logs'
continueOnError: true
condition: always()
- task: CopyFiles@2
condition: eq(variables['publishverify'], 'Yes')
displayName: 'Copy Verify *.received.* files to Artifact Staging'
inputs:
contents: '**\*.received.*'
targetFolder: '$(Build.ArtifactStagingDirectory)\Verify'
cleanTargetFolder: true
overWrite: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Verify *.received.* files as Artifacts'
name: 'verifypublish'
condition: eq(variables['publishverify'], 'Yes')
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)\Verify'
ArtifactName: 'Windows-on-full Verify $(System.JobAttempt)'


- job: BootstrapMSBuildOnCoreWindows
displayName: "Windows Core"
Expand Down Expand Up @@ -185,6 +206,11 @@ jobs:
mergeTestResults: true
continueOnError: true
condition: always()
- task: CmdLine@2
displayName: 'Set flag to publish Verify *.received.* files when test step fails'
condition: failed()
inputs:
script: 'echo "##vso[task.setvariable variable=publishverify]Yes"'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: logs'
inputs:
Expand All @@ -199,6 +225,21 @@ jobs:
ArtifactName: 'CoreOnLinux test logs'
continueOnError: true
condition: always()
- task: CopyFiles@2
condition: eq(variables['publishverify'], 'Yes')
displayName: 'Copy Verify *.received.* files to Artifact Staging'
inputs:
contents: '**/*.received.*'
targetFolder: '$(Build.ArtifactStagingDirectory)/Verify'
cleanTargetFolder: true
overWrite: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Verify *.received.* files as Artifacts'
name: 'verifypublish'
condition: eq(variables['publishverify'], 'Yes')
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/Verify'
ArtifactName: 'Linux Verify $(System.JobAttempt)'

- job: CoreOnMac
displayName: "macOS Core"
Expand All @@ -219,6 +260,11 @@ jobs:
mergeTestResults: true
continueOnError: true
condition: always()
- task: CmdLine@2
displayName: 'Set flag to publish Verify *.received.* files when test step fails'
condition: failed()
inputs:
script: 'echo "##vso[task.setvariable variable=publishverify]Yes"'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: logs'
inputs:
Expand All @@ -233,5 +279,20 @@ jobs:
ArtifactName: 'CoreOnMac test logs'
continueOnError: true
condition: always()
- task: CopyFiles@2
condition: eq(variables['publishverify'], 'Yes')
displayName: 'Copy Verify *.received.* files to Artifact Staging'
inputs:
contents: '**/*.received.*'
targetFolder: '$(Build.ArtifactStagingDirectory)/Verify'
cleanTargetFolder: true
overWrite: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Verify *.received.* files as Artifacts'
name: 'verifypublish'
condition: eq(variables['publishverify'], 'Yes')
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/Verify'
ArtifactName: 'macOS Verify $(System.JobAttempt)'

- template: /eng/common/templates/jobs/source-build.yml
34 changes: 34 additions & 0 deletions src/MSBuild.UnitTests/MockStopwatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.Build.Logging.TerminalLogger;

namespace Microsoft.Build.CommandLine.UnitTests;

internal sealed class MockStopwatch : StopwatchAbstraction
{
public override double ElapsedSeconds
{
get
{
return _elapsed;
}
}

public override void Start()
{
IsStarted = true;
Tick();
}

public override void Stop() => IsStarted = false;

public bool IsStarted { get; private set; }

private double _elapsed = 0d;

public void Tick(double seconds = 0.1)
{
_elapsed += seconds;
}
}
20 changes: 10 additions & 10 deletions src/MSBuild.UnitTests/NodeStatus_Tests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
Expand All @@ -21,7 +21,7 @@ namespace Microsoft.Build.CommandLine.UnitTests;
[UsesVerify]
public class NodeStatus_Tests
{
private readonly NodeStatus _status = new("Namespace.Project", "TargetFramework", "Target", new());
private readonly NodeStatus _status = new("Namespace.Project", "TargetFramework", "Target", new MockStopwatch());

public NodeStatus_Tests()
{
Expand All @@ -31,32 +31,32 @@ public NodeStatus_Tests()
[Fact]
public async Task EverythingFits()
{
NodesFrame frame = new(new[] { _status }, width: 80, height: 5);
NodesFrame frame = new([_status], width: 80, height: 5);

await Verify(frame.RenderNodeStatus(_status).ToString());
await Verify(frame.RenderNodeStatus(0).ToString());
}

[Fact]
public async Task TargetIsTruncatedFirst()
{
NodesFrame frame = new(new[] { _status }, width: 45, height: 5);
NodesFrame frame = new([_status], width: 45, height: 5);

await Verify(frame.RenderNodeStatus(_status).ToString());
await Verify(frame.RenderNodeStatus(0).ToString());
}

[Fact]
public async Task NamespaceIsTruncatedNext()
{
NodesFrame frame = new(new[] { _status }, width: 40, height: 5);
NodesFrame frame = new([_status], width: 40, height: 5);

await Verify(frame.RenderNodeStatus(_status).ToString());
await Verify(frame.RenderNodeStatus(0).ToString());
}

[Fact]
public async Task GoesToProject()
{
NodesFrame frame = new(new[] { _status }, width: 10, height: 5);
NodesFrame frame = new([_status], width: 10, height: 5);

await Verify(frame.RenderNodeStatus(_status).ToString());
await Verify(frame.RenderNodeStatus(0).ToString());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
]9;4;3;\[?25l
project Build (111.2s)
[?25h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[?25l
project Build (111.2s)
[?25h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
]9;4;3;\[?25l
project Build (111.2s)
[?25h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
]9;4;3;\[?25l
project tfName Build (0.0s)
project tfName Build (0.2s)
[?25h[?25l
 project tf2 Build (0.0s)
 project tf2 Build (0.2s)
[?25h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[?25l
project tfName Build (0.0s)
project tfName Build (0.2s)
[?25h[?25l
 project tf2 Build (0.0s)
 project tf2 Build (0.2s)
[?25h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
]9;4;3;\[?25l
project tfName Build (0.0s)
project tfName Build (0.2s)
[?25h[?25l
 project tf2 Build (0.0s)
 project tf2 Build (0.2s)
[?25h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
]9;4;3;\[?25l
project Build (0.0s)
project Build (0.2s)
[?25h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[?25l
project Build (0.0s)
project Build (0.2s)
[?25h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
]9;4;3;\[?25l
project Build (0.0s)
project Build (0.2s)
[?25h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
]9;4;3;\[?25l
[?25h
Build failed in 0.0s
Build failed in 5.0s
]9;4;0;\
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[?25l
[?25h
Build failed in 0.0s
Build failed in 5.0s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
]9;4;3;\[?25l
[?25h
Build failed in 0.0s
Build failed in 5.0s
]9;4;0;\
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
]9;4;3;\ project failed with errors (0.0s)
]9;4;3;\ project failed with errors (0.2s)
directory/file(1,2,3,4): error AA0000: Error!
[?25l
[?25h
Build failed with errors in 0.0s
Build failed with errors in 5.0s
]9;4;0;\
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
 project failed with errors (0.0s)
 project failed with errors (0.2s)
directory/file(1,2,3,4): error AA0000: Error!
[?25l
[?25h
Build failed with errors in 0.0s
Build failed with errors in 5.0s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
]9;4;3;\ project failed with errors (0.0s)
]9;4;3;\ project failed with errors (0.2s)
directory/file(1,2,3,4): error AA0000: Error!
[?25l
[?25h
Build failed with errors in 0.0s
Build failed with errors in 5.0s
]9;4;0;\
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
]9;4;3;\ project succeeded with warnings (0.0s)
]9;4;3;\ project succeeded with warnings (0.2s)
directory/file(1,2,3,4): warning AA0000: Warning!
[?25l
[?25h
Build succeeded with warnings in 0.0s
Build succeeded with warnings in 5.0s
]9;4;0;\
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
 project succeeded with warnings (0.0s)
 project succeeded with warnings (0.2s)
directory/file(1,2,3,4): warning AA0000: Warning!
[?25l
[?25h
Build succeeded with warnings in 0.0s
Build succeeded with warnings in 5.0s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
]9;4;3;\ project succeeded with warnings (0.0s)
]9;4;3;\ project succeeded with warnings (0.2s)
directory/file(1,2,3,4): warning AA0000: Warning!
[?25l
[?25h
Build succeeded with warnings in 0.0s
Build succeeded with warnings in 5.0s
]9;4;0;\
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
]9;4;3;\[?25l
[?25h
Build succeeded in 0.0s
Build succeeded in 5.0s
]9;4;0;\
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[?25l
[?25h
Build succeeded in 0.0s
Build succeeded in 5.0s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
]9;4;3;\[?25l
[?25h
Build succeeded in 0.0s
Build succeeded in 5.0s
]9;4;0;\
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
]9;4;3;\The plugin credential provider could not acquire credentials.Authentication may require manual action. Consider re-running the command with --interactive for `dotnet`, /p:NuGetInteractive="true" for MSBuild or removing the -NonInteractive switch for `NuGet`
[?25l
[?25h
Build succeeded in 0.0s
Build succeeded in 5.0s
]9;4;0;\
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The plugin credential provider could not acquire credentials.Authentication may require manual action. Consider re-running the command with --interactive for `dotnet`, /p:NuGetInteractive="true" for MSBuild or removing the -NonInteractive switch for `NuGet`
[?25l
[?25h
Build succeeded in 0.0s
Build succeeded in 5.0s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
]9;4;3;\The plugin credential provider could not acquire credentials.Authentication may require manual action. Consider re-running the command with --interactive for `dotnet`, /p:NuGetInteractive="true" for MSBuild or removing the -NonInteractive switch for `NuGet`
[?25l
[?25h
Build succeeded in 0.0s
Build succeeded in 5.0s
]9;4;0;\
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
]9;4;3;\directory/file(1,2,3,4): warning AA0000: [CredentialProvider]DeviceFlow: https://testfeed/index.json
directory/file(1,2,3,4): warning AA0000: [CredentialProvider]ATTENTION: User interaction required.**********************************************************************To sign in, use a web browser to open the page https://devicelogin and enter the code XXXXXX to authenticate.**********************************************************************
project succeeded with warnings (0.0s)
project succeeded with warnings (0.2s)
directory/file(1,2,3,4): warning AA0000: [CredentialProvider]DeviceFlow: https://testfeed/index.json
directory/file(1,2,3,4): warning AA0000: [CredentialProvider]ATTENTION: User interaction required.**********************************************************************To sign in, use a web browser to open the page https://devicelogin and enter the code XXXXXX to authenticate.**********************************************************************
[?25l
[?25h
Build succeeded with warnings in 0.0s
Build succeeded with warnings in 5.0s
]9;4;0;\
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
directory/file(1,2,3,4): warning AA0000: [CredentialProvider]DeviceFlow: https://testfeed/index.json
directory/file(1,2,3,4): warning AA0000: [CredentialProvider]ATTENTION: User interaction required.**********************************************************************To sign in, use a web browser to open the page https://devicelogin and enter the code XXXXXX to authenticate.**********************************************************************
project succeeded with warnings (0.0s)
project succeeded with warnings (0.2s)
directory/file(1,2,3,4): warning AA0000: [CredentialProvider]DeviceFlow: https://testfeed/index.json
directory/file(1,2,3,4): warning AA0000: [CredentialProvider]ATTENTION: User interaction required.**********************************************************************To sign in, use a web browser to open the page https://devicelogin and enter the code XXXXXX to authenticate.**********************************************************************
[?25l
[?25h
Build succeeded with warnings in 0.0s
Build succeeded with warnings in 5.0s
Loading

0 comments on commit a1ad6b8

Please sign in to comment.