Skip to content

Commit 4613fec

Browse files
committed
Chronos: Add svn support for run_tests.sh integrity check
Signed-off-by: Arthur Chan <[email protected]>
1 parent a09cb73 commit 4613fec

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

infra/chronos/integrity_validator_run_tests.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,9 @@ def _capture_source_control():
237237
if len(project_dirs) == 1:
238238
# Check if there is a .git directory
239239
if os.path.isdir(os.path.join('/src/', project_dirs[0], '.git')):
240-
return os.path.join('/src/', project_dirs[0])
240+
return ('git', os.path.join('/src/', project_dirs[0]))
241+
elif os.path.isdir(os.path.join('/src/', project_dirs[0], '.svn')):
242+
return ('svn', os.path.join('/src/', project_dirs[0]))
241243
else:
242244
print('Wrong number of directories found under /src/')
243245
print(project_dirs)
@@ -248,8 +250,10 @@ def _capture_source_control():
248250
project_name = os.getenv('PROJECT_NAME', 'unknown_project')
249251
if project_name in project_dirs:
250252
if os.path.isdir(os.path.join('/src/', project_name, '.git')):
251-
return os.path.join('/src/', project_name)
252-
return None
253+
return ('git', os.path.join('/src/', project_name))
254+
elif os.path.isdir(os.path.join('/src/', project_name, '.svn')):
255+
return ('svn', os.path.join('/src/', project_name))
256+
return None, None
253257

254258

255259
def diff_patch_analysis(stage: str) -> int:
@@ -266,30 +270,30 @@ def diff_patch_analysis(stage: str) -> int:
266270
)
267271
if stage == 'before':
268272
print('Diff patch analysis before stage.')
269-
project_dir = _capture_source_control()
270-
if not project_dir:
273+
type, project_dir = _capture_source_control()
274+
if not type:
271275
print('Uknown version control system.')
272276
return -1
273277

274-
print('Git repo found: %s' % project_dir)
278+
print('%s repo found: %s' % (type, project_dir))
275279
try:
276-
subprocess.check_call('cd %s && git diff ./ >> /tmp/chronos-before.diff' %
277-
project_dir,
280+
subprocess.check_call('cd %s && %s diff ./ >> /tmp/chronos-before.diff' %
281+
(project_dir, type),
278282
shell=True)
279283
except subprocess.CalledProcessError:
280284
pass
281285
return 0
282286

283287
elif stage == 'after':
284288
print('Diff patch analysis after stage.')
285-
project_dir = _capture_source_control()
286-
if not project_dir:
289+
type, project_dir = _capture_source_control()
290+
if not type:
287291
print('Uknown version control system.')
288292
return -1
289293

290-
print('Git repo found: %s' % project_dir)
291-
subprocess.check_call('cd %s && git diff ./ >> /tmp/chronos-after.diff' %
292-
project_dir,
294+
print('%s repo found: %s' % (type, project_dir))
295+
subprocess.check_call('cd %s && %s diff ./ >> /tmp/chronos-after.diff' %
296+
(project_dir, type),
293297
shell=True)
294298

295299
try:

0 commit comments

Comments
 (0)