Merge lp:~roadmr/checkbox/setup_and_suites_tests into lp:checkbox

Proposed by Daniel Manrique
Status: Merged
Merged at revision: 1694
Proposed branch: lp:~roadmr/checkbox/setup_and_suites_tests
Merge into: lp:checkbox
Diff against target: 133 lines (+77/-1)
5 files modified
checkbox/tests/setup_files.py (+63/-0)
debian/changelog (+5/-1)
jobs/local.txt.in (+7/-0)
po/POTFILES.in (+1/-0)
setup.cfg (+1/-0)
To merge this branch: bzr merge lp:~roadmr/checkbox/setup_and_suites_tests
Reviewer Review Type Date Requested Status
Brendan Donegan (community) Approve
Daniel Manrique (community) Needs Resubmitting
Review via email: mp+125357@code.launchpad.net

Description of the change

I added some tests that validate:

- All job files in jobs/ are also declared in setup.cfg (so they are included when building a package) and po/POTFILES.in (so they are considered when generating translations).
- All job files are listed in jobs/local.txt.in (so no job files are "left behind" and end up suiteless and lonely).

I get the feeling the tests are a bit brittle because they have a few hardcoded paths and make a few assumptions about which files should and should not be verified (the local.txt test arbitrarily removes a couple of files), so if you can think of a way to improve this it would be welcome. The hardcoded paths are not so much of a problem for checkbox, as this is mainly meant to be run at build time, but may be a problem for e.g. checkbox-oem.

To post a comment you must log in.
Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

Should this have [FEATURE] as it's not a bug? Also I see an unused import of 'os' in the test source file which you may want to remove.

review: Needs Information
1683. By Daniel Manrique

Removed stray 'import os'

1684. By Daniel Manrique

  po/POTFILES.in and included in jobs/local.txt.in. (LP: #1052986)
  (LP: #1052986)

Revision history for this message
Daniel Manrique (roadmr) wrote :

Thanks, nice catches! I added the bug number that this code fixes (there's a bug for that!). I also removed the stray import os call.

review: Needs Resubmitting
Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

Let's merge this and worry about how to make all of the tests refer to job files in oem-qa-checkbox later

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'checkbox/tests/setup_files.py'
2--- checkbox/tests/setup_files.py 1970-01-01 00:00:00 +0000
3+++ checkbox/tests/setup_files.py 2012-09-21 14:45:25 +0000
4@@ -0,0 +1,63 @@
5+# -*- coding: utf-8 -*-
6+#
7+# This file is part of Checkbox.
8+#
9+# Copyright 2012 Canonical Ltd.
10+#
11+# Checkbox is free software: you can redistribute it and/or modify
12+# it under the terms of the GNU General Public License as published by
13+# the Free Software Foundation, either version 3 of the License, or
14+# (at your option) any later version.
15+#
16+# Checkbox is distributed in the hope that it will be useful,
17+# but WITHOUT ANY WARRANTY; without even the implied warranty of
18+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+# GNU General Public License for more details.
20+#
21+# You should have received a copy of the GNU General Public License
22+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
23+#
24+import configparser
25+import glob
26+import re
27+import unittest
28+
29+class SetupFiles(unittest.TestCase):
30+
31+ def test_job_files_in_setup_cfg(self):
32+ #setup_cfg is a python config file
33+ config = configparser.ConfigParser()
34+ config.read('setup.cfg')
35+ #config.get returns a string, so we have to eval it and then get the second
36+ #element of the first element. The values are declared as an array of nested
37+ #tuples.
38+ rfc822deb_from_config = sorted(eval(config.get('build_i18n',
39+ 'rfc822deb_files'))[0][1])
40+ existing_files = sorted(glob.glob('jobs/*.in'))
41+ self.assertEqual(rfc822deb_from_config, existing_files)
42+
43+ def test_job_files_in_potfiles(self):
44+ potfile_lines = [line.strip() for line in open('po/POTFILES.in','r')]
45+ potfile_jobfiles = [file for file in potfile_lines if "rfc822deb" in file]
46+ potfile_jobfiles = [line.split(']')[1].strip()
47+ for line in potfile_jobfiles if ']' in line]
48+
49+ potfile_jobfiles = sorted(potfile_jobfiles)
50+ existing_files = sorted(glob.glob('jobs/*.in'))
51+ self.assertEqual(potfile_jobfiles, existing_files)
52+
53+ def test_job_files_in_local_txt(self):
54+ local_lines = [line.strip() for line in open('jobs/local.txt.in','r')]
55+ local_jobfiles = [file for file in local_lines if "$CHECKBOX_SHARE/jobs" in file]
56+ local_jobfiles = [re.search('\$CHECKBOX_SHARE\/(?P<job_file>jobs\/(.+)\.txt)\?.*',
57+ file).group('job_file')+".in" for file in local_jobfiles]
58+
59+ local_jobfiles = sorted(local_jobfiles)
60+ existing_files = sorted(glob.glob('jobs/*.in'))
61+ #We need to remove local.txt.in from existing_files since it doesn't contain
62+ #itself, also removing resource.txt.in which does not need
63+ #to be included in a suite.
64+ existing_files.remove("jobs/local.txt.in")
65+ existing_files.remove("jobs/resource.txt.in")
66+ self.assertEqual(local_jobfiles, existing_files)
67+
68
69=== modified file 'debian/changelog'
70--- debian/changelog 2012-09-21 13:33:06 +0000
71+++ debian/changelog 2012-09-21 14:45:25 +0000
72@@ -50,6 +50,10 @@
73 * scripts/audio_test: made the default mode verbose, it now sends all
74 output to stderr (but still exits a proper return value). Jobs using it
75 are updated to remove the now-unneeded -v parameter.
76+ * Added tests to ensure all job files are declared in setup.cfg,
77+ po/POTFILES.in and included in jobs/local.txt.in. (LP: #1052986)
78+ * setup.cfg, po/POTFILES.in, jobs/local.txt.in: Fixed so the tests pass.
79+ (LP: #1052986)
80
81 [Alberto Milone]
82 * [FEATURE] scripts/window_test, jobs/graphics.txt.in: Added script
83@@ -141,7 +145,7 @@
84 the 'device' argument (bus type) and require at least one value
85 * [FEATURE] scripts/removable_storage_watcher: add support for debugging
86
87- -- Jeff Lane <jeff@ubuntu.com> Wed, 19 Sep 2012 14:20:15 -0400
88+ -- Daniel Manrique <roadmr@ubuntu.com> Wed, 19 Sep 2012 16:26:56 -0400
89
90 checkbox (0.14.5) quantal; urgency=low
91
92
93=== modified file 'jobs/local.txt.in'
94--- jobs/local.txt.in 2012-08-28 13:35:03 +0000
95+++ jobs/local.txt.in 2012-09-21 14:45:25 +0000
96@@ -187,6 +187,13 @@
97 shopt -s extglob
98 cat $CHECKBOX_SHARE/jobs/panel_clock_test.txt?(.in)
99
100+name: __panel_reboot__
101+plugin: local
102+_description: Panel Reboot Verification tests
103+command:
104+ shopt -s extglob
105+ cat $CHECKBOX_SHARE/jobs/panel_reboot.txt?(.in)
106+
107 name: __pcmcia-pcix__
108 plugin: local
109 _description: PCMCIA/ExpressCard tests
110
111=== modified file 'po/POTFILES.in'
112--- po/POTFILES.in 2012-09-19 18:17:45 +0000
113+++ po/POTFILES.in 2012-09-21 14:45:25 +0000
114@@ -31,6 +31,7 @@
115 [type: gettext/rfc822deb] jobs/panel_reboot.txt.in
116 [type: gettext/rfc822deb] jobs/pcmcia-pcix.txt.in
117 [type: gettext/rfc822deb] jobs/peripheral.txt.in
118+[type: gettext/rfc822deb] jobs/piglit.txt.in
119 [type: gettext/rfc822deb] jobs/power-management.txt.in
120 [type: gettext/rfc822deb] jobs/rendercheck.txt.in
121 [type: gettext/rfc822deb] jobs/resource.txt.in
122
123=== modified file 'setup.cfg'
124--- setup.cfg 2012-09-19 18:17:45 +0000
125+++ setup.cfg 2012-09-21 14:45:25 +0000
126@@ -37,6 +37,7 @@
127 "jobs/panel_reboot.txt.in",
128 "jobs/pcmcia-pcix.txt.in",
129 "jobs/peripheral.txt.in",
130+ "jobs/piglit.txt.in",
131 "jobs/power-management.txt.in",
132 "jobs/rendercheck.txt.in",
133 "jobs/resource.txt.in",

Subscribers

People subscribed via source and target branches