Merge lp:~elopio/snapcraft/integration_coverage into lp:~snappy-dev/snapcraft/core

Proposed by Leo Arias
Status: Merged
Approved by: Leo Arias
Approved revision: 96
Merged at revision: 97
Proposed branch: lp:~elopio/snapcraft/integration_coverage
Merge into: lp:~snappy-dev/snapcraft/core
Diff against target: 187 lines (+73/-15)
3 files modified
bin/snapcraft-coverage (+44/-0)
integration-tests/units/jobs.pxu (+11/-11)
runtests.sh (+18/-4)
To merge this branch: bzr merge lp:~elopio/snapcraft/integration_coverage
Reviewer Review Type Date Requested Status
Michael Terry (community) Needs Information
Michael Vogt (community) Approve
Review via email: mp+265476@code.launchpad.net

Commit message

Added coverage report to the integration tests.

To post a comment you must log in.
95. By Leo Arias

Removed extra newline.

Revision history for this message
Leo Arias (elopio) wrote :

I tried way to many things to get this working. I'm not totally happy with the approach, but it works. If you can think of a better way to do this, please leave a comment.

Revision history for this message
Michael Vogt (mvo) wrote :

Nice approach, I like it!

review: Approve
Revision history for this message
Michael Terry (mterry) wrote :

I'm fine with the approach of a second, coverage-enabled binary. But don't we want to combine the unit tests and integration tests for the coverage report?

review: Needs Information
Revision history for this message
Michael Terry (mterry) wrote :

(that is, have one report, not two)

Revision history for this message
Leo Arias (elopio) wrote :

> I'm fine with the approach of a second, coverage-enabled binary. But don't we
> want to combine the unit tests and integration tests for the coverage report?

I've pushed a small change that combines the two reports.

I don't like this, but for now seems ok to me.

What I would prefer is to do test-driven development. So the unit test coverage should be close to 100%, and the unit coverage report will be just a guide of how well we are doing TDD.
On top of that, I would use the functional tests to cover the happy paths of the user-facing features. Plus some regressions tests or tests for important error conditions. Then the integration coverage report won't be close to 100%, and the simple table is not useful. What's useful is the HTML report that we can use to discover important user-facing features not covered.

There is no correct approach here, so we can discuss and feel free to disagree. If we decide to go the full TDD way, we can split the reports later and display the HTML nicely in the jenkins server.

thanks for the reviews!

96. By Leo Arias

Combine the two coverage reports.

Revision history for this message
Michael Terry (mterry) wrote :

Well, I guess I considered integration tests a part of TDD too. But maybe that's not the Correct way.

You're the testing expert. :) If you would rather see us drive unit tests to 100% separately from integration tests, that's fine and we can split them.

Revision history for this message
Leo Arias (elopio) wrote :

Here's your typical "expert" comment: there's no correct way :)
Lets play with this for now, and try to increase the overall coverage.

Revision history for this message
Michael Vogt (mvo) wrote :

I was assuming we would keep them separate as they are a different kind of testing. But its fine and easy enough to change later so no issue from my side.

Revision history for this message
Leo Arias (elopio) wrote :

approved too soon? sorry about that.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'bin/snapcraft-coverage'
--- bin/snapcraft-coverage 1970-01-01 00:00:00 +0000
+++ bin/snapcraft-coverage 2015-07-22 14:22:27 +0000
@@ -0,0 +1,44 @@
1#!/usr/bin/python3
2# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
3#
4# Copyright (C) 2015 Canonical Ltd
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 3 as
8# published by the Free Software Foundation.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18import os
19import sys
20
21import coverage
22
23# make running from bzr snapshot easy
24topdir = os.path.abspath(os.path.join(__file__, "..", ".."))
25if os.path.exists(os.path.join(topdir, 'setup.py')):
26 sys.path = [topdir] + sys.path
27
28# now import
29import snapcraft.main
30import snapcraft.dirs
31
32
33if __name__ == "__main__":
34 cov = coverage.coverage(
35 data_file=os.path.join(topdir, '.coverage'), data_suffix=True,
36 branch=True, source=['snapcraft'])
37 cov.start()
38 try:
39 snapcraft.dirs.setup_dirs()
40 snapcraft.main.main()
41 except:
42 cov.stop()
43 cov.save()
44 raise
045
=== modified file 'integration-tests/units/jobs.pxu'
--- integration-tests/units/jobs.pxu 2015-07-10 19:21:16 +0000
+++ integration-tests/units/jobs.pxu 2015-07-22 14:22:27 +0000
@@ -3,7 +3,7 @@
3estimated_duration: 0.13estimated_duration: 0.1
4command:4command:
5 set -x5 set -x
6 OUTPUT=$(snapcraft pull)6 OUTPUT=$(${SNAPCRAFT} pull)
7 test $? = 1 || exit 17 test $? = 1 || exit 1
8 echo $OUTPUT | grep "Could not find snapcraft\.yaml\."8 echo $OUTPUT | grep "Could not find snapcraft\.yaml\."
99
@@ -13,10 +13,10 @@
13command:13command:
14 set -ex14 set -ex
15 cp -rT $PLAINBOX_PROVIDER_DATA/local-source .15 cp -rT $PLAINBOX_PROVIDER_DATA/local-source .
16 snapcraft build16 ${SNAPCRAFT} build
17 test -e stamp-all17 test -e stamp-all
18 test "$(readlink parts/make-project/build)" = "$(pwd)"18 test "$(readlink parts/make-project/build)" = "$(pwd)"
19 snapcraft stage19 ${SNAPCRAFT} stage
20 test -e stamp-install20 test -e stamp-install
2121
22id: snapcraft/normal/local-plugin22id: snapcraft/normal/local-plugin
@@ -25,7 +25,7 @@
25command:25command:
26 set -ex26 set -ex
27 cp -rT $PLAINBOX_PROVIDER_DATA/local-plugin .27 cp -rT $PLAINBOX_PROVIDER_DATA/local-plugin .
28 snapcraft snap28 ${SNAPCRAFT} snap
29 test -e snap/build-stamp29 test -e snap/build-stamp
3030
31id: snapcraft/normal/simple-make31id: snapcraft/normal/simple-make
@@ -34,7 +34,7 @@
34command:34command:
35 set -ex35 set -ex
36 cp -rT $PLAINBOX_PROVIDER_DATA/simple-make .36 cp -rT $PLAINBOX_PROVIDER_DATA/simple-make .
37 snapcraft snap37 ${SNAPCRAFT} snap
38 test "$(./snap/bin/test)" = "Hello world"38 test "$(./snap/bin/test)" = "Hello world"
3939
40id: snapcraft/normal/simple-cmake40id: snapcraft/normal/simple-cmake
@@ -43,7 +43,7 @@
43command:43command:
44 set -ex44 set -ex
45 cp -rT $PLAINBOX_PROVIDER_DATA/simple-cmake .45 cp -rT $PLAINBOX_PROVIDER_DATA/simple-cmake .
46 snapcraft snap46 ${SNAPCRAFT} snap
47 test "$(./snap/bin/simple-cmake)" = "It's a CMake world"47 test "$(./snap/bin/simple-cmake)" = "It's a CMake world"
4848
49id: snapcraft/normal/conflicts49id: snapcraft/normal/conflicts
@@ -52,7 +52,7 @@
52command:52command:
53 set -x53 set -x
54 cp -rT $PLAINBOX_PROVIDER_DATA/conflicts .54 cp -rT $PLAINBOX_PROVIDER_DATA/conflicts .
55 OUTPUT=$(snapcraft stage)55 OUTPUT=$(${SNAPCRAFT} stage)
56 test $? = 1 || exit 156 test $? = 1 || exit 1
57 echo $OUTPUT | grep "Error: parts p1 and p2 have the following files in common: bin/test" # squished output by bash57 echo $OUTPUT | grep "Error: parts p1 and p2 have the following files in common: bin/test" # squished output by bash
5858
@@ -62,10 +62,10 @@
62command:62command:
63 set -ex63 set -ex
64 cp -rT $PLAINBOX_PROVIDER_DATA/dependencies .64 cp -rT $PLAINBOX_PROVIDER_DATA/dependencies .
65 snapcraft snap65 ${SNAPCRAFT} snap
66 test -x stage/bin/p366 test -x stage/bin/p3
67 test -x snap/bin/p367 test -x snap/bin/p3
68 test "$(snapcraft shell p3)" = 'p168 test "$(${SNAPCRAFT} shell p3)" = 'p1
69 p169 p1
70 p2'70 p2'
7171
@@ -76,7 +76,7 @@
76 set -x76 set -x
77 cp -rT $PLAINBOX_PROVIDER_DATA/dependencies .77 cp -rT $PLAINBOX_PROVIDER_DATA/dependencies .
78 sed -i "s/p1:/p1:\n after: [p3]/" snapcraft.yaml78 sed -i "s/p1:/p1:\n after: [p3]/" snapcraft.yaml
79 OUTPUT=$(snapcraft pull)79 OUTPUT=$(${SNAPCRAFT} pull)
80 test $? = 1 || exit 180 test $? = 1 || exit 1
81 echo $OUTPUT | grep -i "circular dependency"81 echo $OUTPUT | grep -i "circular dependency"
8282
@@ -87,5 +87,5 @@
87 set -x87 set -x
88 cp -rT $PLAINBOX_PROVIDER_DATA/dependencies .88 cp -rT $PLAINBOX_PROVIDER_DATA/dependencies .
89 sed -i '/after/d' snapcraft.yaml89 sed -i '/after/d' snapcraft.yaml
90 snapcraft snap90 ${SNAPCRAFT} snap
91 test $? = 1 || exit 191 test $? = 1 || exit 1
9292
=== modified file 'runtests.sh'
--- runtests.sh 2015-07-21 02:03:13 +0000
+++ runtests.sh 2015-07-22 14:22:27 +0000
@@ -28,11 +28,10 @@
28pyflakes3 $SRC_PATHS28pyflakes3 $SRC_PATHS
2929
30if which python3-coverage >/dev/null 2>&1; then30if which python3-coverage >/dev/null 2>&1; then
31 python3-coverage erase31 python3-coverage run --branch --source snapcraft -m unittest
32 python3-coverage run --branch --source snapcraft -m unittest 32 mv .coverage .coverage.unit
33 python3-coverage report
34else33else
35 python3 -m unittest 34 python3 -m unittest
36fi35fi
3736
38if [ -z "$SNAPCRAFT_TESTS_SKIP_PLAINBOX" ]; then37if [ -z "$SNAPCRAFT_TESTS_SKIP_PLAINBOX" ]; then
@@ -49,6 +48,14 @@
49 exit 148 exit 1
50 fi49 fi
5150
51 if which python3-coverage >/dev/null 2>&1; then
52 python3-coverage erase
53 export PROJECT_PATH=$(pwd)
54 export SNAPCRAFT=snapcraft-coverage
55 else
56 export SNAPCRAFT=snapcraft
57 fi
58
52 # Go to the plainbox provider of snapcraft tests59 # Go to the plainbox provider of snapcraft tests
53 cd integration-tests/60 cd integration-tests/
54 # Create a temporary directory so that we can run 'manage.py develop' and61 # Create a temporary directory so that we can run 'manage.py develop' and
@@ -77,6 +84,13 @@
77raise SystemExit(failed)84raise SystemExit(failed)
78__PYTHON__85__PYTHON__
79)86)
87
88fi
89
90if which python3-coverage >/dev/null 2>&1; then
91 python3-coverage combine
92 python3-coverage report
93 python3-coverage erase
80fi94fi
8195
82echo -e "\e[1;32mEverything passed\e[0m"96echo -e "\e[1;32mEverything passed\e[0m"

Subscribers

People subscribed via source and target branches

to all changes: