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

Proposed by Leo Arias
Status: Merged
Approved by: Sergio Schvezov
Approved revision: 183
Merged at revision: 181
Proposed branch: lp:~elopio/snapcraft/fix1497371-clean_clean
Merge into: lp:~snappy-dev/snapcraft/core
Diff against target: 68 lines (+10/-4)
3 files modified
integration-tests/units/jobs.pxu (+3/-1)
snapcraft/cmds.py (+2/-1)
snapcraft/tests/test_cmds.py (+5/-2)
To merge this branch: bzr merge lp:~elopio/snapcraft/fix1497371-clean_clean
Reviewer Review Type Date Requested Status
Sergio Schvezov Approve
Review via email: mp+271684@code.launchpad.net

Commit message

On clean, check the contents of the parts dir only if it exists.

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

80 column

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

Nice catch!

How about a test that runs clean twice? :-)

183. By Leo Arias

Added a second call to clean in integration tests.

Revision history for this message
Sergio Schvezov (sergiusens) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'integration-tests/units/jobs.pxu'
2--- integration-tests/units/jobs.pxu 2015-09-18 13:42:57 +0000
3+++ integration-tests/units/jobs.pxu 2015-09-18 17:21:03 +0000
4@@ -119,6 +119,9 @@
5 test ! -d ./stage
6 test ! -d ./parts
7 test ! -d ./snap
8+ # Clean a second time doesn't fail.
9+ # Regression test for https://bugs.launchpad.net/snapcraft/+bug/1497371
10+ ${SNAPCRAFT} clean
11
12 id: snapcraft/normal/simple-cmake
13 plugin: shell
14@@ -325,4 +328,3 @@
15 ${SNAPCRAFT} pull
16 test -f parts/python2/install/usr/lib/python2.7/argparse.py
17 test -f parts/python3/install/usr/lib/python3.4/argparse.py
18-
19
20=== modified file 'snapcraft/cmds.py'
21--- snapcraft/cmds.py 2015-09-17 18:02:05 +0000
22+++ snapcraft/cmds.py 2015-09-18 17:21:03 +0000
23@@ -237,7 +237,8 @@
24 shutil.rmtree(part.partdir)
25
26 # parts dir does not contain only generated code.
27- if not os.listdir(common.get_partsdir()):
28+ if (os.path.exists(common.get_partsdir()) and
29+ not os.listdir(common.get_partsdir())):
30 os.rmdir(common.get_partsdir())
31
32 logger.info('Cleaning up staging area')
33
34=== modified file 'snapcraft/tests/test_cmds.py'
35--- snapcraft/tests/test_cmds.py 2015-09-17 18:02:05 +0000
36+++ snapcraft/tests/test_cmds.py 2015-09-18 17:21:03 +0000
37@@ -134,6 +134,8 @@
38 mock.call().__bool__(),
39 mock.call('partdir3'),
40 mock.call().__bool__(),
41+ mock.call(common.get_partsdir()),
42+ mock.call().__bool__(),
43 mock.call(common.get_stagedir()),
44 mock.call().__bool__(),
45 mock.call(common.get_snapdir()),
46@@ -152,6 +154,7 @@
47
48 def test_everything_is_clean(self):
49 self.mock_exists.return_value = False
50+ self.mock_listdir.side_effect = FileNotFoundError()
51
52 cmds.clean({})
53
54@@ -159,12 +162,12 @@
55 mock.call('partdir1'),
56 mock.call('partdir2'),
57 mock.call('partdir3'),
58+ mock.call(common.get_partsdir()),
59 mock.call(common.get_stagedir()),
60 mock.call(common.get_snapdir()),
61 ])
62
63- self.mock_rmdir.assert_called_once_with(common.get_partsdir())
64-
65+ self.assertFalse(self.mock_rmdir.called)
66 self.assertFalse(self.mock_rmtree.called)
67
68 def test_no_parts_defined(self):

Subscribers

People subscribed via source and target branches

to all changes: