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

TestOnExecuteCustomCommand fails with Assert.Equal #1724

Open
trylek opened this issue Jan 14, 2020 · 10 comments · Fixed by #32947
Open

TestOnExecuteCustomCommand fails with Assert.Equal #1724

trylek opened this issue Jan 14, 2020 · 10 comments · Fixed by #32947

Comments

@trylek
Copy link
Member

trylek commented Jan 14, 2020

Platform: Windows_NT x64/x86 Release
Pipeline: runtime-libraries outerloop
Example builds:

Proximate diagnostic info:

  Starting:    System.ServiceProcess.ServiceController.Tests (parallel test collections = on, max threads = 2)
    System.ServiceProcess.Tests.ServiceBaseTests.TestOnExecuteCustomCommand [FAIL]
      Assert.Equal() Failure
      Expected: 128
      Actual:   129
      Stack Trace:
        /_/src/libraries/System.ServiceProcess.ServiceController/tests/ServiceBaseTests.cs(156,0): at System.ServiceProcess.Tests.ServiceBaseTests.TestOnExecuteCustomCommand()
  Finished:    System.ServiceProcess.ServiceController.Tests
=== TEST EXECUTION SUMMARY ===
   System.ServiceProcess.ServiceController.Tests  Total: 22, Errors: 0, Failed: 1, Skipped: 0, Time: 23.417s
@danmoseley
Copy link
Member

Usually those pass, most skip unless you’re elevated , and those are all failing: #1262

@jaredpar
Copy link
Member

@danmosemsft it's failing on the last three outerloop builds. Updated the issue to link to the builds. Seems 100% at this moment.

jaredpar added a commit to jaredpar/runtime that referenced this issue Jan 15, 2020
This is failing on the libraries outerloop builds.

Tracked by dotnet#1724
stephentoub pushed a commit that referenced this issue Jan 15, 2020
This is failing on the libraries outerloop builds.

Tracked by #1724
@danmoseley
Copy link
Member

@Anipik owns this test

@Anipik
Copy link
Contributor

Anipik commented Jan 15, 2020

I will try to take look at this by the end of this week

@ericstj
Copy link
Member

ericstj commented Jan 15, 2020

@danmosemsft it looks like you regressed it with #1234.

// Response from test service:
// 128 => Environment.UserInteractive == false
// 129 => Environment.UserInteractive == true
//
// On Windows Nano and other SKU that do not expose Window Stations, Environment.UserInteractive
// will always return true, even within a service process.
// Otherwise, we expect it to be false.
// (This is the only place we verify Environment.UserInteractive can return false)
byte expected = PlatformDetection.HasWindowsShell ? (byte)128 : (byte)129;
Assert.Equal(expected, _testService.GetByte());

@danmoseley
Copy link
Member

Assert.Equal() Failure\r\nExpected: 128\r\nActual: 129

This means that PlatformDetection.HasWindowsShell is true in the test process (ie., IsWindows && IsNotWindowsServerCore && IsNotWindowsNanoServer && IsNotWindowsIoTCore;) which is expected...

but Environment.UserInteractive is true in the test service, which is not

        protected override void OnCustomCommand(int command)
        {
            base.OnCustomCommand(command);

            if (Environment.UserInteractive) // see ServiceBaseTests.TestOnExecuteCustomCommand()
                command++;

The failure is across Windows 7, Server, and Windows 8.1 - so it's not some special Windows SKU that needs special treatment like Nano.

This would be the case if corelib did not have my change, but the tests did -- could easily happen in the old two-repo system, but hopefully not possible any more.

Well, it's disabled for now. I'll have a look later, if @Anipik doesn't see the problem as part of #1262

@danmoseley danmoseley self-assigned this Jan 15, 2020
@danmoseley
Copy link
Member

I did run the tests locally of course -- although it's possible somehow in all the failures caused by #1262 I missed this one was not passing.

I also did test that Envirohment.UserInteractive returned false in a test service I made by hand and ran on Windows 10, and true on a Nano container.

@vatsan-madhavan
Copy link
Member

Please take a look at dotnet/wpf#2663. WPF's OpenFileDialog is broken because Environment.UserInteractive is returning False all the time.

I don't think WinForms is broken though. I tried it and it seems to work fine.

@ericstj
Copy link
Member

ericstj commented Feb 27, 2020

Looking at the intial commit that added this fuctionality I think the logic is inverted. #1234 (comment)

I'll submit a fix.

@antonfirsov
Copy link
Member

antonfirsov commented Jan 25, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

8 participants