GNOME Bugzilla – Bug 724796
Add some tests
Last modified: 2015-04-13 07:32:20 UTC
GNOME Software has some Dogtail tests, which do some simple UI actions, like searching, which would be good to also have tested in Logs: https://git.gnome.org/browse/gnome-software/tree/tests/basic.py
Created attachment 296413 [details] [review] take a now parameter when comparing time stamps Patch 1 of 2 makes the function easier to test.
Created attachment 296414 [details] [review] add test for time stamp comparison Patch 2 of 2 to add the test.
Comment on attachment 296413 [details] [review] take a now parameter when comparing time stamps Looks fine.
Comment on attachment 296414 [details] [review] add test for time stamp comparison Looks good! These unit tests are a good start, and UI tests can be handled properly in a separate bug.
Comment on attachment 296413 [details] [review] take a now parameter when comparing time stamps Pushed to master in commit 08b49bd3cd178198067da3cf67267cb92f7ddfb4
Comment on attachment 296414 [details] [review] add test for time stamp comparison Pushed to master in commit 10305a1ff7683c5eacdef8ce8d2d697b70fe2761
Created attachment 300386 [details] [review] Added dogtail test for sidebar item click.
Review of attachment 300386 [details] [review]: there are some extraneous files in this patch that should not be added to git: gnome-logs.pot tests_Test_gl_util-test-gl-util.Po Everything else looks good to me. ::: tests/basic.py @@ +7,3 @@ +# on the overview page, hit Enter, and verify that we end up on the +# search page. Hit Escape and verify that we go back to the overview +# page. You should update the description to explain what your test does. This is still describing the gnome-software test.
Created attachment 300388 [details] [review] Added dogtail test for sidebar item click. Updated the description and removed the extra files. Please review. Thanks
Review of attachment 300388 [details] [review]: Almost good to go; you're just missing glibtests.m4 now.
Created attachment 300389 [details] [review] Added dogtail test for sidebar item click. Added m4/glibtests.m4. Please review again, Thanks
Review of attachment 300389 [details] [review]: ::: tests/basic.py @@ +7,3 @@ +# on the overview page, hit Enter, and verify that we end up on the +# search page. Hit Escape and verify that we go back to the overview +# page. this is still the gnome-software description...
Created attachment 300390 [details] [review] Added dogtail test for sidebar item click. Sorry, I forgot to add it to git. Please review, Thanks
Review of attachment 300390 [details] [review]: looks good now
Review of attachment 300390 [details] [review]: Why do we need glib-tap.mk and glibtests.m4? As far as I can see, they are not used (beyond the use of test_scripts, which should probably just be using the Automake built-in test_SCRIPTS). ::: Makefile.am @@ +4,3 @@ --enable-appstream-util \ + --enable-tests \ + --disable-dogtail This should probably be enabled during distcheck, as it would seem reasonable to run the tests at that point. Where does the --disable-dogtail come from? I cannot see it in glibtests.m4. ::: configure.ac @@ +9,3 @@ AC_CONFIG_MACRO_DIR([m4]) +AM_INIT_AUTOMAKE([1.11 -Wall -Wno-portability check-news dist-xz no-define no-dist-gzip subdir-objects serial-tests]) Is it required to use serial-tests? ::: test-desktop-file-validate.sh @@ +1,2 @@ +#!/bin/sh -e +/usr/bin/desktop-file-validate ./data/org.gnome.Logs.desktop || exit 1 This will not work in a srcdir != builddir environment. In any case, this file is generated at build time, and should not be added to git. ::: tests/Makefile.am @@ +1,1 @@ +include $(top_srcdir)/glib-tap.mk This should be using non-recursive make, like the rest of gnome-logs (so all in the toplevel Makefile.am). ::: tests/basic.py @@ +29,3 @@ + + try: + shopping_button = app.child(name=u'Let\u2019s Go Shopping', retry=False) This is from gnome-software, so should not be here (and will fail every time, as the label does not exist in gnome-logs).
(In reply to David King from comment #16) >…using the Automake built-in test_SCRIPTS). Make that check_SCRIPTS.
Created attachment 300409 [details] [review] Added dogtail test for sidebar item click. Updated patch based on the reviews. Please review again, Thanks
Review of attachment 300409 [details] [review]: Much better! Now you need to add a configure.ac check for Python and dogtail, and this should be ready. You will also need to make the test script depend on the gnome-logs binary (something like "tests/basic.py: gnome-logs" in Makefile.am should be sufficient). If the test is to be run during "make check" (not just when gnome-logs is installed), remember that you will need to compile the gsettings schema to an appropriate location, and set XDG_DATA_DIRS (an environment variable).
Created attachment 300425 [details] [review] Added dogtail test for sidebar item click. Added "tests/basic.py: gnome-logs" in Makefile.am Check for Python and Dogtail in configure.ac
Review of attachment 300425 [details] [review]: Looking better now, thanks. Just a comment about the configure checks. ::: configure.ac @@ +94,3 @@ PKG_CHECK_MODULES([LOGS], [$GIO_REQUIRED $GTK_REQUIRED $SYSTEMD_JOURNAL_REQUIRED]) +PYTHON_REQUIRED=2.7 +DOGTAIL_REQUIRED This change does not do very much, as PYTHON_REQUIRED is just a variable, and DOGTAIL_REQUIRED is not a macro that I am aware of (but I do not have dogtail installed, so maybe it comes from that package?). For dogtail, maybe AC_PATH_PROG would be sufficient: https://www.gnu.org/software/autoconf/manual/autoconf.html#Generic-Programs For the Python check, you might want to look into the AM_PATH_PYTHON macro: https://www.gnu.org/software/automake/manual/html_node/Python.html Having said that, if dogtail is installed, you should be able to assume that it is usable, and as it depends on Python (and you are not installing Python scripts) you could probably just check for dogtail, and ignore checking for Python.
Created attachment 300449 [details] [review] Added dogtail test for sidebar item click. Added dogtail check.
Review of attachment 300449 [details] [review]: ::: configure.ac @@ +90,3 @@ + AC_PATH_PROG([DOGTAIL], [dogtail], [/usr/libexec/dogtail], + [$PATH$PATH_SEPARATOR/usr/libexec$PATH_SEPARATOR]dnl + [/usr/sbin$PATH_SEPARATOR/usr/etc$PATH_SEPARATOR/etc]) The check should be inside the checks for the testing utilities. I thought that dogtail was a separate utility, but apparently it is just a Python package. Sorry about that :-/ You probably do need to use AM_PATH_PYTHON, and then check that the dogtail module is available. itstool does this (but with the libxml2 module): https://gitorious.org/itstool/itstool/source/359be5c350fc3d869807f663cee2b028adf1f5d7:configure.ac You can probably copy that check, modify it for Dogtail and it should work.
Created attachment 300459 [details] [review] Added dogtail test for sidebar item click. Added check for python
Created attachment 300479 [details] [review] Added dogtail test for sidebar item click. Updated patch. Please review. Thanks
Review of attachment 300479 [details] [review]: Looks good to me. I cannot test the patch at the moment (not enough bandwidth to install dogtail), but I will merge it as soon as I can.
Review of attachment 300479 [details] [review]: I slightly modified the patch and pushed it to master as 81f44c881d5e40310c789790d3fe2f20756f11db. Thanks!
Closing this as fixed, as there are now some unit and behaviour tests. Any more tests can have a separate and more specific bug.