Merge lp:~gz/workspace-runner/sorted_walk_results into lp:workspace-runner

Proposed by Martin Packman on 2016-07-11
Status: Merged
Approved by: Martin Packman on 2016-07-11
Approved revision: 26
Merged at revision: 26
Proposed branch: lp:~gz/workspace-runner/sorted_walk_results
Merge into: lp:workspace-runner
Diff against target: 17 lines (+6/-1)
1 file modified
workspace_runner/tests/__init__.py (+6/-1)
To merge this branch: bzr merge lp:~gz/workspace-runner/sorted_walk_results
Reviewer Review Type Date Requested Status
Aaron Bentley (community) 2016-07-11 Approve on 2016-07-11
Review via email: mp+299721@code.launchpad.net

Commit message

Fix test failures by applying stable ordering to os.walk results

Description of the change

Currently make test complains out of order walk results from the FakePrimitives test class.

<https://docs.python.org/2/library/os.html#os.walk>

Note os.walk does not promis ordering, but does let you manipulate dirnames in place with topdown=True to apply an order you desire. So, this branch just does that.

FAIL: test_s3_upload (workspace_runner.tests.__init__.TestRunFromConfig)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "workspace_runner/tests/__init__.py", line 441, in test_s3_upload
    'upload.json', 'upload_artifacts.py'])
AssertionError: Lists differ: [('/tmp/tmp6gFog4', ['.wsr'], ... != [('/tmp/tmp6gFog4', ['.wsr'], ...

First differing element 1:
('/tmp/tmp6gFog4/.wsr', [], ['upload_artifacts.py', 'upload.json'])
('/tmp/tmp6gFog4/.wsr', [], ['upload.json', 'upload_artifacts.py'])

  [('/tmp/tmp6gFog4', ['.wsr'], []),
- ('/tmp/tmp6gFog4/.wsr', [], ['upload_artifacts.py', 'upload.json'])]
? ---------------

+ ('/tmp/tmp6gFog4/.wsr', [], ['upload.json', 'upload_artifacts.py'])]
? +++++++++++++++

To post a comment you must log in.
Aaron Bentley (abentley) wrote :

Thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'workspace_runner/tests/__init__.py'
2--- workspace_runner/tests/__init__.py 2015-10-09 18:32:02 +0000
3+++ workspace_runner/tests/__init__.py 2016-07-11 18:11:39 +0000
4@@ -72,7 +72,12 @@
5 return mkdtemp()
6
7 def destroy(self):
8- self.walk_results = list(os.walk(self.workspace))
9+ self.walk_results = []
10+ for root, dirs, files in os.walk(self.workspace):
11+ # Ensure walk happens in lexical order and results stored likewise.
12+ dirs.sort()
13+ files.sort()
14+ self.walk_results.append((root, dirs, files))
15 rmtree(self.workspace)
16
17 def run(self, args, out_file):

Subscribers

People subscribed via source and target branches