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

Improve the test runner: Allow "direct" tests (instead of only steps-based tests) #2711

Merged
merged 2 commits into from
Mar 3, 2019

Conversation

psychon
Copy link
Member

@psychon psychon commented Feb 28, 2019

No description provided.

@codecov
Copy link

codecov bot commented Feb 28, 2019

Codecov Report

Merging #2711 into master will decrease coverage by <.01%.
The diff coverage is 62%.

@@            Coverage Diff             @@
##           master    #2711      +/-   ##
==========================================
- Coverage   86.23%   86.23%   -0.01%     
==========================================
  Files         529      529              
  Lines       36401    36388      -13     
==========================================
- Hits        31390    31378      -12     
+ Misses       5011     5010       -1
Flag Coverage Δ
#gcov 75.65% <ø> (ø) ⬆️
#luacov 89.03% <62%> (-0.01%) ⬇️
Impacted Files Coverage Δ
tests/_runner.lua 75.58% <53.33%> (+3.63%) ⬆️
tests/test-gravity.lua 78.26% <75%> (-11.74%) ⬇️

tests/_runner.lua Outdated Show resolved Hide resolved
tests/_runner.lua Outdated Show resolved Hide resolved
tests/_runner.lua Outdated Show resolved Hide resolved
tests/_runner.lua Outdated Show resolved Hide resolved
tests/_runner.lua Outdated Show resolved Hide resolved
tests/_runner.lua Outdated Show resolved Hide resolved

--- This function is called to indicate that a test does not use the run_steps()
-- facility, but instead runs something else directly.
function runner.run_direct()
Copy link
Member

Choose a reason for hiding this comment

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

s/run_direct/is_running/ maybe?
The current name indicated that it would do something, although with the example in test-gravity it is called only after the test - and it seems like the runner.run_direct() call is not necessary there after all?!
It could also just set runner.is_running instead maybe.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, no. test-gravity.lua starts an external process and afterwards it calls run_direct(). However, at this time, the test is not yet done. Only when the external process finishes some time later is done() actually called. So, it's still asynchronous.

The idea why I call run_direct() at the end is because it "disarms" a timer in _runner.lua that would otherwise complain that the test was not started correctly and quit awesome. So, if starting the external process would fail, awesome would quit relatively quickly instead of waiting for the 180 seconds timeout.

Right now I don't see a nice way to make this more explicit... well, run_direct could get a function as its argument which it just runs, but that might also be weird...

Ideas?

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the detailed explanation, as always.

It is fine by me.

The current _runner.lua expects a table containing steps to be passed
in. However, not all tests look like this. This commits adds an API to
the runner that allows tests to run however they like. They just have to
call run_direct() initially and call done() when they are finished.

Signed-off-by: Uli Schlachter <[email protected]>
This commit makes test-gravity.lua use the new infrastructure that was
added in the previous commit: Instead of pretending to be a steps-based
test, this is now a direct test. This gets rid of all the useless
wait_a_bit steps that exist purely to satisfy the steps-based test
runner.

This commit makes test-gravity.lua about one third shorter. Also, the
test might run a tiny bit faster, since there is no more timer that
regularly checks if the test is done, but instead it finishes
immediately when the external process finishes.

Signed-off-by: Uli Schlachter <[email protected]>

--- This function is called to indicate that a test does not use the run_steps()
-- facility, but instead runs something else directly.
function runner.run_direct()
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the detailed explanation, as always.

It is fine by me.

@blueyed blueyed merged commit a802d0c into awesomeWM:master Mar 3, 2019
@psychon psychon deleted the improve_test_runner branch March 3, 2019 11:38
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.

3 participants