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
=== modified file 'integration-tests/units/jobs.pxu'
--- integration-tests/units/jobs.pxu 2015-09-18 13:42:57 +0000
+++ integration-tests/units/jobs.pxu 2015-09-18 17:21:03 +0000
@@ -119,6 +119,9 @@
119 test ! -d ./stage119 test ! -d ./stage
120 test ! -d ./parts120 test ! -d ./parts
121 test ! -d ./snap121 test ! -d ./snap
122 # Clean a second time doesn't fail.
123 # Regression test for https://bugs.launchpad.net/snapcraft/+bug/1497371
124 ${SNAPCRAFT} clean
122125
123id: snapcraft/normal/simple-cmake126id: snapcraft/normal/simple-cmake
124plugin: shell127plugin: shell
@@ -325,4 +328,3 @@
325 ${SNAPCRAFT} pull328 ${SNAPCRAFT} pull
326 test -f parts/python2/install/usr/lib/python2.7/argparse.py329 test -f parts/python2/install/usr/lib/python2.7/argparse.py
327 test -f parts/python3/install/usr/lib/python3.4/argparse.py330 test -f parts/python3/install/usr/lib/python3.4/argparse.py
328
329331
=== modified file 'snapcraft/cmds.py'
--- snapcraft/cmds.py 2015-09-17 18:02:05 +0000
+++ snapcraft/cmds.py 2015-09-18 17:21:03 +0000
@@ -237,7 +237,8 @@
237 shutil.rmtree(part.partdir)237 shutil.rmtree(part.partdir)
238238
239 # parts dir does not contain only generated code.239 # parts dir does not contain only generated code.
240 if not os.listdir(common.get_partsdir()):240 if (os.path.exists(common.get_partsdir()) and
241 not os.listdir(common.get_partsdir())):
241 os.rmdir(common.get_partsdir())242 os.rmdir(common.get_partsdir())
242243
243 logger.info('Cleaning up staging area')244 logger.info('Cleaning up staging area')
244245
=== modified file 'snapcraft/tests/test_cmds.py'
--- snapcraft/tests/test_cmds.py 2015-09-17 18:02:05 +0000
+++ snapcraft/tests/test_cmds.py 2015-09-18 17:21:03 +0000
@@ -134,6 +134,8 @@
134 mock.call().__bool__(),134 mock.call().__bool__(),
135 mock.call('partdir3'),135 mock.call('partdir3'),
136 mock.call().__bool__(),136 mock.call().__bool__(),
137 mock.call(common.get_partsdir()),
138 mock.call().__bool__(),
137 mock.call(common.get_stagedir()),139 mock.call(common.get_stagedir()),
138 mock.call().__bool__(),140 mock.call().__bool__(),
139 mock.call(common.get_snapdir()),141 mock.call(common.get_snapdir()),
@@ -152,6 +154,7 @@
152154
153 def test_everything_is_clean(self):155 def test_everything_is_clean(self):
154 self.mock_exists.return_value = False156 self.mock_exists.return_value = False
157 self.mock_listdir.side_effect = FileNotFoundError()
155158
156 cmds.clean({})159 cmds.clean({})
157160
@@ -159,12 +162,12 @@
159 mock.call('partdir1'),162 mock.call('partdir1'),
160 mock.call('partdir2'),163 mock.call('partdir2'),
161 mock.call('partdir3'),164 mock.call('partdir3'),
165 mock.call(common.get_partsdir()),
162 mock.call(common.get_stagedir()),166 mock.call(common.get_stagedir()),
163 mock.call(common.get_snapdir()),167 mock.call(common.get_snapdir()),
164 ])168 ])
165169
166 self.mock_rmdir.assert_called_once_with(common.get_partsdir())170 self.assertFalse(self.mock_rmdir.called)
167
168 self.assertFalse(self.mock_rmtree.called)171 self.assertFalse(self.mock_rmtree.called)
169172
170 def test_no_parts_defined(self):173 def test_no_parts_defined(self):

Subscribers

People subscribed via source and target branches

to all changes: