def test_write_file(self): scheduler = self.mk_scheduler_in_example_fs(()) request = ExecuteProcessRequest.create_with_empty_snapshot( ("/bin/bash", "-c", "echo -n 'European Burmese' > roland"), dict(), ("roland",) ) execute_process_result = self.execute_expecting_one_result(scheduler, ExecuteProcessResult, request).value self.assertEquals( execute_process_result.output_directory_digest, DirectoryDigest( fingerprint=str("63949aa823baf765eff07b946050d76ec0033144c785a94d3ebd82baa931cd16"), serialized_bytes_length=80, ) ) files_content_result = self.execute_expecting_one_result( scheduler, FilesContent, execute_process_result.output_directory_digest ).value self.assertEquals( (files_content_result.dependencies), (FileContent("roland", "European Burmese"),) )
def _default_args_execute_process_request(self, argv=tuple(), env=None): env = env or dict() return ExecuteProcessRequest.create_with_empty_snapshot( argv=argv, env=env, output_files=(), )
def test_write_file(self): scheduler = self.mk_scheduler_in_example_fs(()) request = ExecuteProcessRequest.create_with_empty_snapshot( ("/bin/bash", "-c", "echo -n 'European Burmese' > roland"), dict(), ("roland", )) execute_process_result = self.execute_expecting_one_result( scheduler, ExecuteProcessResult, request).value self.assertEquals( execute_process_result.output_directory_digest, DirectoryDigest( fingerprint=str( "63949aa823baf765eff07b946050d76ec0033144c785a94d3ebd82baa931cd16" ), serialized_bytes_length=80, )) files_content_result = self.execute_expecting_one_result( scheduler, FilesContent, execute_process_result.output_directory_digest).value self.assertEquals((files_content_result.dependencies), (FileContent("roland", "European Burmese"), ))
def test_create_from_snapshot_with_env(self): req = ExecuteProcessRequest.create_with_empty_snapshot( argv=('foo', ), description="Some process", env={'VAR': 'VAL'}, ) self.assertEqual(req.env, ('VAR', 'VAL'))
def test_write_file(self): request = ExecuteProcessRequest.create_with_empty_snapshot( argv=("/bin/bash", "-c", "echo -n 'European Burmese' > roland"), description="echo roland", output_files=("roland", )) execute_process_result = self.scheduler.product_request( ExecuteProcessResult, [request], )[0] self.assertEqual( execute_process_result.output_directory_digest, DirectoryDigest( fingerprint=text_type( "63949aa823baf765eff07b946050d76ec0033144c785a94d3ebd82baa931cd16" ), serialized_bytes_length=80, )) files_content_result = self.scheduler.product_request( FilesContent, [execute_process_result.output_directory_digest], )[0] self.assertEqual(files_content_result.dependencies, (FileContent("roland", "European Burmese"), ))
def test_non_fallible_failing_command_raises(self): request = ExecuteProcessRequest.create_with_empty_snapshot( argv=("/bin/bash", "-c", "exit 1"), description='one-cat', ) with self.assertRaises(ExecutionError) as cm: self.scheduler.product_request(ExecuteProcessResult, [request]) self.assertIn("process 'one-cat' failed with exit code 1.", str(cm.exception))
def test_fallible_failing_command_returns_exited_result(self): request = ExecuteProcessRequest.create_with_empty_snapshot( argv=("/bin/bash", "-c", "exit 1"), description='one-cat', ) result = self.scheduler.product_request(FallibleExecuteProcessResult, [request])[0] self.assertEquals(result.exit_code, 1)
def test_fallible_failing_command_returns_exited_result(self): scheduler = self.mk_scheduler_in_example_fs(()) request = ExecuteProcessRequest.create_with_empty_snapshot( argv=("/bin/bash", "-c", "exit 1"), description='one-cat', ) result = self.execute_expecting_one_result( scheduler, FallibleExecuteProcessResult, request).value self.assertEquals(result.exit_code, 1)
def test_non_fallible_failing_command_raises(self): scheduler = self.mk_scheduler_in_example_fs(()) request = ExecuteProcessRequest.create_with_empty_snapshot( argv=("/bin/bash", "-c", "exit 1"), description='one-cat', ) with self.assertRaises(ProcessExecutionFailure) as cm: self.execute_raising_throw(scheduler, ExecuteProcessResult, request) self.assertIn("process 'one-cat' failed with exit code 1.", str(cm.exception))
def test_exercise_python_side_of_timeout_implementation(self): # Local execution currently doesn't support timeouts, # but this allows us to ensure that all of the setup # on the python side does not blow up. request = ExecuteProcessRequest.create_with_empty_snapshot( argv=("/bin/bash", "-c", "/bin/sleep 1; echo -n 'European Burmese'"), timeout_seconds=0.1, description='sleepy-cat', ) self.scheduler.product_request(ExecuteProcessResult, [request])[0]
def test_exercise_python_side_of_timeout_implementation(self): # Local execution currently doesn't support timeouts, # but this allows us to ensure that all of the setup # on the python side does not blow up. scheduler = self.mk_scheduler_in_example_fs(()) request = ExecuteProcessRequest.create_with_empty_snapshot( argv=("/bin/bash", "-c", "/bin/sleep 1; echo -n 'European Burmese'"), timeout_seconds=0.1, description='sleepy-cat', ) self.execute_expecting_one_result(scheduler, ExecuteProcessResult, request).value
def test_exercise_python_side_of_timeout_implementation(self): # Local execution currently doesn't support timeouts, # but this allows us to ensure that all of the setup # on the python side does not blow up. scheduler = self.mk_scheduler_in_example_fs(()) request = ExecuteProcessRequest.create_with_empty_snapshot( ("/bin/bash", "-c", "/bin/sleep 1; echo -n 'European Burmese'"), dict(), tuple(), timeout_seconds=0.1, description='sleepy-cat', ) self.execute_expecting_one_result(scheduler, ExecuteProcessResult, request).value
def process_request_from_javac_version(javac_version_exe_req): yield ExecuteProcessRequest.create_with_empty_snapshot( argv=javac_version_exe_req.gen_argv(), env=dict(), output_files=())
def process_request_from_javac_version(javac_version_exe_req): yield ExecuteProcessRequest.create_with_empty_snapshot( argv=javac_version_exe_req.gen_argv(), description=javac_version_exe_req.description, )
def _default_args_execute_process_request(self, argv=tuple(), env=tuple()): return ExecuteProcessRequest.create_with_empty_snapshot( argv=argv, env=env, )