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

Add smoke test suite #62

Merged
merged 3 commits into from Feb 20, 2022
Merged

Add smoke test suite #62

merged 3 commits into from Feb 20, 2022

Conversation

pabs3
Copy link
Contributor

@pabs3 pabs3 commented Feb 13, 2022

Uses mpv, mpv-mpris, playerctl, sound-theme-freedesktop, bash,
dbus-run-session, xvfb, xauth, jo, jq, socat and awk.

Initial tests include checking metadata, pausing a playing mpv, playing a
paused mpv, toggling mpv between playing and pausing, stopping a playing mpv.

Add enough parameters to make it flexible and useful for testing already
installed mpv mpris plugins, which will primarily be useful for distros.

Document the test requirements and parameters in the README.md file.

Should help prevent breakage and ensure mpv compatibility.

This has been adapted from the Debian autopkgtests that I wrote:

https://sources.debian.org/src/mpv-mpris/unstable/debian/tests/

test/env Outdated Show resolved Hide resolved
test/setup Outdated Show resolved Hide resolved
@olifre
Copy link
Contributor

olifre commented Feb 13, 2022

After changing the parts I commented on, I can confirm the tests run fine in case included in Gentoo package tests, too. Great work 👍 .

@pabs3 pabs3 force-pushed the add-tests branch 3 times, most recently from 58e614d to 6648411 Compare February 14, 2022 05:56
@pabs3
Copy link
Contributor Author

pabs3 commented Feb 14, 2022

Another review would be good, I've made significant improvements to the pull request, including making it check for errors on stderr for each of the tests and making the tests run in parallel (with GNU make output grouping).

test/Makefile Outdated Show resolved Hide resolved
@olifre
Copy link
Contributor

olifre commented Feb 14, 2022

@pabs3 That looks great! I currently get empty ipc.output.json in all cases for some reason (then of course leading to all tests failing), I will investigate this more in-depth later tonight.

Copy link
Contributor

@olifre olifre left a comment

Choose a reason for hiding this comment

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

This looks great, apart from the version strangeness with socat and the missing \ in one place and a small typo I did not find any issues 👍 .
Since I'm also only a contributor, of course it's up to @hoyon to perform a real review and merge. I think some small extension (in a later commit) could be to also run make test (after installing all dependencies) in the GitHub action workflow so the tests run after every commit / PR.

test/setup Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@pabs3 pabs3 force-pushed the add-tests branch 2 times, most recently from 5e8f72f to 0b99f23 Compare February 14, 2022 15:43
@pabs3
Copy link
Contributor Author

pabs3 commented Feb 14, 2022

Fixed a few more issues. I think it is ready for a final review before merging.

At this time I don't know enough about GitHub actions to integrate the tests with that, but that can happen at a later stage.

@hoyon
Copy link
Owner

hoyon commented Feb 14, 2022

Thanks so much for this @pabs3!!!

I haven't been able to review this properly yet but I've checked out the branch and run make test and get this error:

+ exec env MPV_MPRIS_TEST_NAME=./play XDG_RUNTIME_DIR=. TEMPDIR=. TMPDIR=. TEMP=. TMP=. dbus-run-session -- xvfb-run --auto-servernum --auth-file ././play.Xauthority ./play
xvfb-run: unrecognized option '--auth-file'
test play: stderr not empty!
test play: start of stderr ---------------------
xvfb-run: unrecognized option '--auth-file'
test play: end of stderr -----------------------
test play: stderr not empty!
test play: failed with exit code 1
make[1]: *** [Makefile:18: play] Error 1
make[1]: Leaving directory '/home/hoyon/code/mpv-mpris/test'
make: *** [Makefile:56: test] Error 2

Am I missing something? I'm using arch linux and man xvfb-run does mention the --auth-file flag.

At this time I don't know enough about GitHub actions to integrate the tests with that, but that can happen at a later stage.

I'd definitely want that. IMO there's not much value in a test suite if it's not being run automatically on every commit.

@olifre
Copy link
Contributor

olifre commented Feb 14, 2022

Am I missing something? I'm using arch linux and man xvfb-run does mention the --auth-file flag.

It seems the flag is listed on the manpage provided for version 21.1.3-2 in Arch here: https://man.archlinux.org/man/xvfb-run.1.en
Which version are you using?

@olifre
Copy link
Contributor

olifre commented Feb 14, 2022

Fixed a few more issues. I think it is ready for a final review before merging.

Just a quick reply: On Gentoo, the new code runs like a charm without any changes even in the testing sandbox used by Portage (Gentoo's package manager) 👍 .

@hoyon
Copy link
Owner

hoyon commented Feb 14, 2022

It seems the flag is listed on the manpage provided for version 21.1.3-2 in Arch here: man.archlinux.org/man/xvfb-run.1.en Which version are you using?

It seems like the arch linux xvfb-run script has a number of issues. I've managed to manually patch the script to get the tests to pass but will need to find some time to investigate deeper then report upstream.

@olifre
Copy link
Contributor

olifre commented Feb 14, 2022

At this time I don't know enough about GitHub actions to integrate the tests with that, but that can happen at a later stage.

I'd definitely want that. IMO there's not much value in a test suite if it's not being run automatically on every commit.

Here's a trivial commit adding this, that was easier than expected:
olifre@eba11c2

Feel free to pull it, add it here, or I can also open a PR after this one is merged 😉.

@pabs3
Copy link
Contributor Author

pabs3 commented Feb 15, 2022

@hoyon if I switch from --auth-file to -f, will that work on Arch Linux?

I added a few more fixes:

  • added the patch from @olifre and fixed it to install mpv too
  • moved --output-sync=target to MAKEFLAGS in test/Makefile
  • moved the contents of the tests targets in test/Makefile to a test/wrapper script, tons of shell in Makefiles looks ridiculously ugly to me
  • switched to a better jq command-line, recommended to me on their IRC channel
  • fixed a shellcheck warning in the wrapper script
  • added a GitHub check that the build process doesn't modify files, that .gitignore is correct and make clean is correct.
  • fixed the README to reference dbus instead of dbus-daemon, since that only appears in Debian bookworm and later, while just dbus is available in all releases and pulls in dbus-daemon in bullseye.

@pabs3 pabs3 force-pushed the add-tests branch 2 times, most recently from b21e607 to 8270b2b Compare February 15, 2022 02:37
@pabs3
Copy link
Contributor Author

pabs3 commented Feb 15, 2022 via email

Copy link
Owner

@hoyon hoyon left a comment

Choose a reason for hiding this comment

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

Apologies for the delay!

Some minor comments but thanks again for this!

test/setup Outdated Show resolved Hide resolved
test/env Outdated
TEMP="$MPV_MPRIS_TEST_TMP" \
TMP="$MPV_MPRIS_TEST_TMP" \
dbus-run-session -- \
xvfb-run --auto-servernum --auth-file "$MPV_MPRIS_TEST_XAUTH/$(basename "$1").Xauthority" \
Copy link
Owner

Choose a reason for hiding this comment

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

Replacing this with -f does indeed work in arch linux. I've reported the bug upstream.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, added a comment about it.

What is the bug link?

Copy link
Owner

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added to the patch. Looks like it is fixed now so maybe I can switch back to the long option though?

test/Makefile Show resolved Hide resolved
@pabs3 pabs3 force-pushed the add-tests branch 2 times, most recently from 2678374 to d805516 Compare February 20, 2022 02:35
@pabs3
Copy link
Contributor Author

pabs3 commented Feb 20, 2022

Updated to add an xvfb log too.

pabs3 and others added 3 commits February 20, 2022 11:29
Uses mpv, mpv-mpris, playerctl, sound-theme-freedesktop, bash,
dbus-run-session, xvfb, xauth, jo, jq, socat and awk.

Initial tests include checking metadata, pausing a playing mpv, playing a
paused mpv, toggling mpv between playing and pausing, stopping a playing mpv.

Add enough parameters to make it flexible and useful for testing already
installed mpv mpris plugins, which will primarily be useful for distros.

Document the test requirements and parameters in the README.md file.

Should help prevent breakage and ensure mpv compatibility.
Ensures that the build process does not modify any files,
that the .gitignore file covers all files and that
the clean process removes all files not in git.
Copy link
Owner

@hoyon hoyon left a comment

Choose a reason for hiding this comment

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

Tests all pass when running in parallel now!

Thanks again for this work. I'll merge it in now!

@hoyon hoyon merged commit 72945f9 into hoyon:master Feb 20, 2022
@pabs3
Copy link
Contributor Author

pabs3 commented Feb 20, 2022 via email

@pabs3 pabs3 deleted the add-tests branch February 20, 2022 23:56
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.

None yet

3 participants