comparison tests/conftest.py @ 411:e7b865f8f335

bake: Enable multiprocess baking. Baking is now done by running a worker per CPU, and sending jobs to them. This changes several things across the codebase: * Ability to not cache things related to pages other than the 'main' page (i.e. the page at the bottom of the execution stack). * Decouple the baking process from the bake records, so only the main process keeps track (and modifies) the bake record. * Remove the need for 'batch page getters' and loading a page directly from the page factories. There are various smaller changes too included here, including support for scope performance timers that are saved with the bake record and can be printed out to the console. Yes I got carried away. For testing, the in-memory 'mock' file-system doesn't work anymore, since we're spawning processes, so this is replaced by a 'tmpfs' file-system which is saved in temporary files on disk and deleted after tests have run.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 12 Jun 2015 17:09:19 -0700
parents a0724af26c12
children 2aa879d63133
comparison
equal deleted inserted replaced
410:d1a472464e57 411:e7b865f8f335
146 out_dir = fs.path('kitchen/_counter') 146 out_dir = fs.path('kitchen/_counter')
147 app = fs.getApp() 147 app = fs.getApp()
148 baker = Baker(app, out_dir) 148 baker = Baker(app, out_dir)
149 record = baker.bake() 149 record = baker.bake()
150 150
151 if not record.success: 151 if not record.success:
152 errors = [] 152 errors = []
153 for e in record.entries: 153 for e in record.entries:
154 errors += e.getAllErrors() 154 errors += e.getAllErrors()
155 raise BakeError(errors) 155 raise BakeError(errors)
156 156
157 if expected_output_files: 157 if expected_output_files:
158 actual = fs.getStructure('kitchen/_counter') 158 actual = fs.getStructure('kitchen/_counter')
159 error = _compare_dicts(expected_output_files, actual) 159 error = _compare_dicts(expected_output_files, actual)
160 if error: 160 if error:
161 raise ExpectedBakeOutputError(error) 161 raise ExpectedBakeOutputError(error)
162 162
163 if expected_partial_files: 163 if expected_partial_files:
164 keys = list(sorted(expected_partial_files.keys())) 164 keys = list(sorted(expected_partial_files.keys()))
165 for key in keys: 165 for key in keys:
166 try: 166 try:
167 actual = fs.getFileEntry('kitchen/_counter/' + 167 actual = fs.getFileEntry('kitchen/_counter/' +
168 key.lstrip('/')) 168 key.lstrip('/'))
169 except Exception as e: 169 except Exception as e:
170 raise ExpectedBakeOutputError([ 170 raise ExpectedBakeOutputError([
171 "Can't access output file %s: %s" % (key, e)]) 171 "Can't access output file %s: %s" % (key, e)])
172 172
173 expected = expected_partial_files[key] 173 expected = expected_partial_files[key]
174 # HACK because for some reason PyYAML adds a new line for those 174 # HACK because for some reason PyYAML adds a new line for
175 # and I have no idea why. 175 # those and I have no idea why.
176 actual = actual.rstrip('\n') 176 actual = actual.rstrip('\n')
177 expected = expected.rstrip('\n') 177 expected = expected.rstrip('\n')
178 cmpres = _compare_str(expected, actual, key) 178 cmpres = _compare_str(expected, actual, key)
179 if cmpres: 179 if cmpres:
180 raise ExpectedBakeOutputError(cmpres) 180 raise ExpectedBakeOutputError(cmpres)
181 181
182 def reportinfo(self): 182 def reportinfo(self):
183 return self.fspath, 0, "bake: %s" % self.name 183 return self.fspath, 0, "bake: %s" % self.name
184 184
185 def repr_failure(self, excinfo): 185 def repr_failure(self, excinfo):