Skip to content

Conversation

@raffaeler
Copy link
Contributor

@raffaeler raffaeler commented Aug 23, 2023

This PR aim to fix the holding button test which randomly fails on Mac.
Since the holding state is measured with a System.Threading.Timer, it probably failed because the Timer thread was not scheduled before the assert made on the main (test) thread.

This change does the following:

  • Parameterize the TestButton to use shorter debounce and holding times
  • Measure the actual time elapsed when the holding event happens (if ever)
Microsoft Reviewers: Open in CodeFlow

@ghost ghost added the area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio label Aug 23, 2023
@raffaeler
Copy link
Contributor Author

FWIW Here is the failure log before these changes:
image

The core error was an assert failure on the boolean holding state:

[xUnit.net 00:00:05.76]     Iot.Device.Button.Tests.ButtonTests.If_Button_Is_Held_Holding_Event_Fires [FAIL]
  Failed Iot.Device.Button.Tests.ButtonTests.If_Button_Is_Held_Holding_Event_Fires [2 s]
  Error Message:
   holding
Expected: True
Actual:   False
  Stack Trace:
     at Iot.Device.Button.Tests.ButtonTests.If_Button_Is_Held_Holding_Event_Fires() in /Users/runner/work/1/s/src/devices/Button/tests/ButtonTests.cs:line 81

Copy link
Member

@Ellerbach Ellerbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for fixing it!

@raffaeler
Copy link
Contributor Author

There may be other tests having the same issue.
But IMHO is better to see how this goes and then I'll proceed with the others.

@krwq krwq merged commit 29d6347 into dotnet:main Aug 24, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants