@@ -140,13 +140,12 @@ def _contains_nonempty_table(self, s: str) -> bool:
140140 run_length = 0
141141 return False
142142
143- def passes_stdout (self , actual_stdout : bytes ) -> bool :
144- actual_stdout_str : str = actual_stdout .decode (sys .getdefaultencoding ())
143+ def passes_stdout (self , actual_stdout : str ) -> bool :
145144 if self ._node .has_annotation (self ._STDOUT_TABLE_CONTAINS_DATA ):
146- return self ._contains_nonempty_table (actual_stdout_str )
145+ return self ._contains_nonempty_table (actual_stdout )
147146 return True
148147
149- def passes_stderr (self , actual_stderr : bytes ) -> bool :
148+ def passes_stderr (self , actual_stderr : str ) -> bool :
150149 return True
151150
152151 def __str__ (self ):
@@ -239,6 +238,14 @@ def orchestrate(self, file_path: str) -> WorkloadDTO:
239238 raise KeyError (f'Maximum invocation blocks exceeded: { self ._max_invocations_blocks } ' )
240239 return WorkloadDTO (setup_str , in_session_commands , teardown_str , expectations )
241240
241+ class WalkthroughResult :
242+
243+
244+ def __init__ (self , stdout_str :str , stderr_str :str , rc :int ) -> None :
245+ self .stdout :str = stdout_str
246+ self .stderr :str = stderr_str
247+ self .rc = rc
248+
242249class SimpleE2E (object ):
243250
244251 def __init__ (self , workload : WorkloadDTO ):
@@ -258,23 +265,23 @@ def run(self) -> Tuple[bytes, bytes]:
258265 pr .stdin .write (f"{ cmd } \n " .encode (sys .getdefaultencoding ()))
259266 pr .stdin .flush ()
260267 stdoout_bytes , stderr_bytes = pr .communicate ()
261- return (stdoout_bytes , stderr_bytes , )
268+ return WalkthroughResult (stdoout_bytes . decode ( sys . getdefaultencoding ()) , stderr_bytes . decode ( sys . getdefaultencoding ()), pr . returncode )
262269
263- if __name__ == '__main__' :
270+ def main () :
264271 md_parser = MdParser ()
265272 orchestrator : MdOrchestrator = MdOrchestrator (md_parser )
266273 workload_dto : WorkloadDTO = orchestrator .orchestrate (os .path .join (_REPOSITORY_ROOT_PATH , 'docs' , 'walkthroughs' , 'get-google-vms.md' ))
267274 print (f'Workload DTO: { workload_dto } ' )
268275 # print(json.dumps(parsed_file, indent=2))
269276 e2e : SimpleE2E = SimpleE2E (workload_dto )
270- stdout_bytes , stderr_bytes = e2e .run ()
271- print (stdout_bytes . decode ( sys . getdefaultencoding ()) )
272- print (stderr_bytes . decode ( sys . getdefaultencoding ()) )
277+ result : WalkthroughResult = e2e .run ()
278+ print (result . stdout )
279+ print (result . stderr )
273280 for expectation in workload_dto .get_expectations ():
274281 print (f'Expectation: { expectation } ' )
275- print (f'Passes stdout: { expectation .passes_stdout (stdout_bytes )} ' )
276- print (f'Passes stderr: { expectation .passes_stderr (stderr_bytes )} ' )
282+ print (f'Passes stdout: { expectation .passes_stdout (result . stdout )} ' )
283+ print (f'Passes stderr: { expectation .passes_stderr (result . stderr )} ' )
277284 print ('---' )
278285
279-
280-
286+ if __name__ == '__main__' :
287+ main ()
0 commit comments