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

Fix disabling notification timeout #3626

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

sclu1034
Copy link
Contributor

@sclu1034 sclu1034 commented May 31, 2022

When creating a notification with a timeout value of 0, no timer is
created. The same behaviour was intended when setting the timeout to 0
later, but it was never implemented.

Fixes #3625.

sclu1034 added 2 commits May 31, 2022 12:20
When creating a notification with a timeout value of `0`, no timer is
created. The same behaviour was intended when setting the timeout to `0`
later, but it was never implemented.

Fixes awesomeWM#3625.
The closure for the `die` method didn't need anything from
the `set_timeout`, so it makes no sense to re-create the method
every time the timeout is changed.

It's sufficient to make it a regular method.
@codecov
Copy link

codecov bot commented May 31, 2022

Codecov Report

Merging #3626 (140591f) into master (3a54221) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #3626   +/-   ##
=======================================
  Coverage   90.64%   90.65%           
=======================================
  Files         854      855    +1     
  Lines       54772    54790   +18     
=======================================
+ Hits        49650    49668   +18     
  Misses       5122     5122           
Flag Coverage Δ
gcov 90.65% <100.00%> (+<0.01%) ⬆️
luacov 93.45% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
lib/naughty/notification.lua 94.60% <100.00%> (+0.05%) ⬆️
tests/test-naughty-notification.lua 100.00% <100.00%> (ø)
themes/xresources/theme.lua 88.65% <0.00%> (-0.93%) ⬇️
lib/awful/widget/taglist.lua 88.73% <0.00%> (-0.06%) ⬇️
objects/client.c 83.34% <0.00%> (ø)
spawn.c 86.16% <0.00%> (+0.06%) ⬆️
lib/awful/widget/layoutlist.lua 91.19% <0.00%> (+0.62%) ⬆️

Elv13
Elv13 previously requested changes May 31, 2022
Copy link
Member

@Elv13 Elv13 left a comment

Choose a reason for hiding this comment

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

Thanks for this. Just a minor comment. Also adding a regression test might be relevant here. The notification module seems to have many of these papercut fixes over time, so the risk of regression is rather high. Maybe a new integration test module would make sense. The current test module is getting very large and complex.

lib/naughty/notification.lua Outdated Show resolved Hide resolved
Copy link
Member

@Aire-One Aire-One left a comment

Choose a reason for hiding this comment

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

Thank you for the extra test 😉

@actionless actionless dismissed Elv13’s stale review June 29, 2022 01:00

it's local now

Copy link
Member

@Elv13 Elv13 left a comment

Choose a reason for hiding this comment

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

Thanks for the update. Here's 1 little thing I would like addressed


-- Wait for the notification's timeout to pass.
table.insert(steps, function()
os.execute("sleep 2")
Copy link
Member

Choose a reason for hiding this comment

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

Instead of sleeping 2 full second, can it usleep for 0.3s, check, then return nil if the condition isn't met? I have been bitten by hardcoded blocking sleep in tests before

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really. Technically, the test is for "will this notification exist indefinitely". And "infinity has passed" is not really a condition I can check for. The closes I have is "we're still there after the previous timeout value", but I need to know that said timeout has passed for that.

I guess I could try to add up elapsed time, but I don't have enough experience with the test framework's weird "emulate async by repeatedly calling the same step" to know if that's any better of an idea than sleeping for multiple seconds.

Copy link
Member

Choose a reason for hiding this comment

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

Our test handle this internally. If something returns nil too many time, the test fails. This is transparent. Just check for the condition and return nil if it's not met, the framework contains the boilerplate and timeout/retry logic.

Copy link
Contributor Author

@sclu1034 sclu1034 Jun 30, 2022

Choose a reason for hiding this comment

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

As I said, I cannot "check for the condition". The condition is "infinity has passed and the notification is still visible".

The closest approximation is

  • I know that if .timeout = 0 wasn't applied correctly, the timeout would likely still be 1 second
  • I then wait for a value greater than that known timeout to rule out race conditions if we waited for the same value, and check if the notification has expired

So I'll rephrase my second paragraph above:
Would it be acceptable to sum up the wait time, relying on the implementation detail that a sleep timer of 0.3 seconds and the fact that a step is "re-tried" 10 times ends up working out so that the total wait time in this case happens to be below the point where the test framework would bail?

I could also access the notification's internal values to check timer == nil, but that wouldn't be an integration test.

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

Successfully merging this pull request may close these issues.

Naughty.timeout = 0 not working in request::display
5 participants