After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 724796 - Add some tests
Add some tests
Status: RESOLVED FIXED
Product: gnome-logs
Classification: Other
Component: general
git master
Other All
: Normal normal
: ---
Assigned To: gnome-logs maintainer(s)
gnome-logs maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2014-02-20 12:38 UTC by David King
Modified: 2015-04-13 07:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
take a now parameter when comparing time stamps (5.65 KB, patch)
2015-02-09 22:43 UTC, Kat
committed Details | Review
add test for time stamp comparison (3.65 KB, patch)
2015-02-09 22:44 UTC, Kat
committed Details | Review
Added dogtail test for sidebar item click. (121.12 KB, patch)
2015-03-26 19:03 UTC, Rashi Aswani
none Details | Review
Added dogtail test for sidebar item click. (31.48 KB, patch)
2015-03-26 19:39 UTC, Rashi Aswani
reviewed Details | Review
Added dogtail test for sidebar item click. (33.01 KB, patch)
2015-03-26 19:47 UTC, Rashi Aswani
reviewed Details | Review
Added dogtail test for sidebar item click. (32.81 KB, patch)
2015-03-26 19:56 UTC, Rashi Aswani
needs-work Details | Review
Added dogtail test for sidebar item click. (3.55 KB, patch)
2015-03-27 00:15 UTC, Rashi Aswani
none Details | Review
Added dogtail test for sidebar item click. (4.33 KB, patch)
2015-03-27 10:14 UTC, Rashi Aswani
none Details | Review
Added dogtail test for sidebar item click. (4.49 KB, patch)
2015-03-27 13:44 UTC, Rashi Aswani
none Details | Review
Added dogtail test for sidebar item click. (4.64 KB, patch)
2015-03-27 14:45 UTC, Rashi Aswani
none Details | Review
Added dogtail test for sidebar item click. (5.29 KB, patch)
2015-03-27 17:30 UTC, Rashi Aswani
committed Details | Review

Description David King 2014-02-20 12:38:25 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
Comment 1 Kat 2015-02-09 22:43:25 UTC
Created attachment 296413 [details] [review]
take a now parameter when comparing time stamps

Patch 1 of 2 makes the function easier to test.
Comment 2 Kat 2015-02-09 22:44:06 UTC
Created attachment 296414 [details] [review]
add test for time stamp comparison

Patch 2 of 2 to add the test.
Comment 3 David King 2015-02-09 22:50:53 UTC
Comment on attachment 296413 [details] [review]
take a now parameter when comparing time stamps

Looks fine.
Comment 4 David King 2015-02-09 22:52:23 UTC
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 5 Kat 2015-02-09 23:54:54 UTC
Comment on attachment 296413 [details] [review]
take a now parameter when comparing time stamps

Pushed to master in commit 08b49bd3cd178198067da3cf67267cb92f7ddfb4
Comment 6 Kat 2015-02-09 23:55:14 UTC
Comment on attachment 296414 [details] [review]
add test for time stamp comparison

Pushed to master in commit 10305a1ff7683c5eacdef8ce8d2d697b70fe2761
Comment 7 Rashi Aswani 2015-03-26 19:03:53 UTC
Created attachment 300386 [details] [review]
Added dogtail test for sidebar item click.
Comment 8 Matthias Clasen 2015-03-26 19:10:42 UTC
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.
Comment 9 Rashi Aswani 2015-03-26 19:39:30 UTC
Created attachment 300388 [details] [review]
Added dogtail test for sidebar item click.

Updated the description and removed the extra files.
Please review.
Thanks
Comment 10 Matthias Clasen 2015-03-26 19:42:00 UTC
Review of attachment 300388 [details] [review]:

Almost good to go; you're just missing glibtests.m4 now.
Comment 11 Matthias Clasen 2015-03-26 19:42:16 UTC
Review of attachment 300388 [details] [review]:

Almost good to go; you're just missing glibtests.m4 now.
Comment 12 Rashi Aswani 2015-03-26 19:47:59 UTC
Created attachment 300389 [details] [review]
Added dogtail test for sidebar item click.

Added m4/glibtests.m4.
Please review again,
Thanks
Comment 13 Matthias Clasen 2015-03-26 19:52:27 UTC
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...
Comment 14 Rashi Aswani 2015-03-26 19:56:50 UTC
Created attachment 300390 [details] [review]
Added dogtail test for sidebar item click.

Sorry, I forgot to add it to git.
Please review,
Thanks
Comment 15 Matthias Clasen 2015-03-26 20:02:27 UTC
Review of attachment 300390 [details] [review]:

looks good now
Comment 16 David King 2015-03-26 21:23:28 UTC
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).
Comment 17 David King 2015-03-26 21:26:18 UTC
(In reply to David King from comment #16)
>…using the Automake built-in test_SCRIPTS).

Make that check_SCRIPTS.
Comment 18 Rashi Aswani 2015-03-27 00:15:58 UTC
Created attachment 300409 [details] [review]
Added dogtail test for sidebar item click.

Updated patch based on the reviews.
Please review again,
Thanks
Comment 19 David King 2015-03-27 07:12:17 UTC
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).
Comment 20 Rashi Aswani 2015-03-27 10:14:09 UTC
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
Comment 21 David King 2015-03-27 12:53:30 UTC
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.
Comment 22 Rashi Aswani 2015-03-27 13:44:51 UTC
Created attachment 300449 [details] [review]
Added dogtail test for sidebar item click.

Added dogtail check.
Comment 23 David King 2015-03-27 14:02:16 UTC
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.
Comment 24 Rashi Aswani 2015-03-27 14:45:29 UTC
Created attachment 300459 [details] [review]
Added dogtail test for sidebar item click.

Added check for python
Comment 25 Rashi Aswani 2015-03-27 17:30:52 UTC
Created attachment 300479 [details] [review]
Added dogtail test for sidebar item click.

Updated patch.
Please review.
Thanks
Comment 26 David King 2015-03-27 17:46:23 UTC
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.
Comment 27 David King 2015-04-13 07:31:36 UTC
Review of attachment 300479 [details] [review]:

I slightly modified the patch and pushed it to master as 81f44c881d5e40310c789790d3fe2f20756f11db. Thanks!
Comment 28 David King 2015-04-13 07:32:20 UTC
Closing this as fixed, as there are now some unit and behaviour tests. Any more tests can have a separate and more specific bug.