20
20
import random
21
21
import sys
22
22
23
+ import click
23
24
import pystache
24
25
import shutil
25
26
import yaml
@@ -56,7 +57,7 @@ async def _parse_artifact_versions():
56
57
proc = await asyncio .subprocess .create_subprocess_exec ('./gradlew' , 'assembleAllForSmokeTests' )
57
58
await proc .wait ()
58
59
59
- with open ('build/m2repository/changed-artifacts.json' , 'r' ) as json_file :
60
+ with open ('build/m2repository/changed-artifacts.json' ) as json_file :
60
61
artifacts = json .load (json_file )
61
62
return dict (_artifact_key_version (x ) for x in artifacts ['headGit' ])
62
63
@@ -67,7 +68,7 @@ def _artifact_key_version(artifact):
67
68
68
69
69
70
async def _parse_config_yaml ():
70
- with open ('macrobenchmark/config.yaml' , 'r' ) as yaml_file :
71
+ with open ('macrobenchmark/config.yaml' ) as yaml_file :
71
72
return yaml .safe_load (yaml_file )
72
73
73
74
@@ -167,7 +168,8 @@ async def _upload_apks_to_ftl(self):
167
168
await self ._exec_subprocess (executable , args )
168
169
169
170
async def _exec_subprocess (self , executable , args ):
170
- self .logger .info (f'Executing command: "{ " " .join ([executable , * args ])} "...' )
171
+ command = " " .join ([executable , * args ])
172
+ self .logger .info (f'Executing command: "{ command } "...' )
171
173
172
174
proc = await asyncio .subprocess .create_subprocess_exec (
173
175
executable ,
@@ -180,6 +182,14 @@ async def _exec_subprocess(self, executable, args):
180
182
self ._stream_output (executable , proc .stderr )
181
183
)
182
184
185
+ await proc .communicate ()
186
+ if proc .returncode == 0 :
187
+ self .logger .info (f'"{ command } " finished.' )
188
+ else :
189
+ message = f'"{ command } " exited with return code { proc .returncode } .'
190
+ self .logger .error (message )
191
+ raise click .ClickException (message )
192
+
183
193
async def _stream_output (self , executable , stream : asyncio .StreamReader ):
184
194
async for line in stream :
185
195
self .logger .info (f'[{ executable } ] { line .decode ("utf-8" ).strip ()} ' )
0 commit comments