[gcc_toolchain] Ignore git failure in "useless changes" test
If the git command doesn't work, don't fail the build.
It just means the "useless change" logic can't short-circuit the build.
Change-Id: I658479461515a99a974593854c1fc01b574b611d
diff --git a/README.recipes.md b/README.recipes.md
index 7a6092e..4219e99 100644
--- a/README.recipes.md
+++ b/README.recipes.md
@@ -998,7 +998,7 @@
— **def [DoCheckout](/recipes/gcc_toolchain.py#49)(api, url, checkout_dir, revision, last_revision, useless_file):**
-— **def [RunSteps](/recipes/gcc_toolchain.py#60)(api, binutils_revision, gcc_revision):**
+— **def [RunSteps](/recipes/gcc_toolchain.py#66)(api, binutils_revision, gcc_revision):**
### *recipes* / [gerrit:examples/full](/recipe_modules/gerrit/examples/full.py)
[DEPS](/recipe_modules/gerrit/examples/full.py#5): [gerrit](#recipe_modules-gerrit), [recipe\_engine/json][recipe_engine/recipe_modules/json], [recipe\_engine/properties][recipe_engine/recipe_modules/properties]
diff --git a/recipes/gcc_toolchain.expected/linux_gcc_test_fail.json b/recipes/gcc_toolchain.expected/linux_gcc_test_fail.json
index 9ee9082..1b9d885 100644
--- a/recipes/gcc_toolchain.expected/linux_gcc_test_fail.json
+++ b/recipes/gcc_toolchain.expected/linux_gcc_test_fail.json
@@ -451,9 +451,9 @@
"name": "check for changes other than gcc/DATESTAMP",
"stdout": "/path/to/tmp/",
"~followup_annotations": [
- "@@@STEP_LOG_LINE@raw_io.output[changed files]@gcc/DATESTAMP@@@",
- "@@@STEP_LOG_LINE@raw_io.output[changed files]@others@@@",
- "@@@STEP_LOG_END@raw_io.output[changed files]@@@"
+ "step returned non-zero exit code: 1",
+ "@@@STEP_LOG_END@raw_io.output[changed files]@@@",
+ "@@@STEP_EXCEPTION@@@"
]
},
{
diff --git a/recipes/gcc_toolchain.expected/mac_gcc_test_fail.json b/recipes/gcc_toolchain.expected/mac_gcc_test_fail.json
index 0908960..adc5cc2 100644
--- a/recipes/gcc_toolchain.expected/mac_gcc_test_fail.json
+++ b/recipes/gcc_toolchain.expected/mac_gcc_test_fail.json
@@ -459,9 +459,9 @@
"name": "check for changes other than gcc/DATESTAMP",
"stdout": "/path/to/tmp/",
"~followup_annotations": [
- "@@@STEP_LOG_LINE@raw_io.output[changed files]@gcc/DATESTAMP@@@",
- "@@@STEP_LOG_LINE@raw_io.output[changed files]@others@@@",
- "@@@STEP_LOG_END@raw_io.output[changed files]@@@"
+ "step returned non-zero exit code: 1",
+ "@@@STEP_LOG_END@raw_io.output[changed files]@@@",
+ "@@@STEP_EXCEPTION@@@"
]
},
{
diff --git a/recipes/gcc_toolchain.py b/recipes/gcc_toolchain.py
index 60a142c..c9badd0 100644
--- a/recipes/gcc_toolchain.py
+++ b/recipes/gcc_toolchain.py
@@ -49,10 +49,16 @@
def DoCheckout(api, url, checkout_dir, revision, last_revision, useless_file):
api.git.checkout(url, checkout_dir, revision)
with api.context(cwd=checkout_dir):
- step = api.git('diff', '--name-only', '%s..%s' % (last_revision, revision),
- name='check for changes other than %s' % useless_file,
- stdout=api.raw_io.output(name='changed files',
- add_output_log=True))
+ try:
+ step = api.git(
+ 'diff', '--name-only', '%s..%s' % (last_revision, revision),
+ name='check for changes other than %s' % useless_file,
+ stdout=api.raw_io.output(name='changed files', add_output_log=True))
+ except StepFailure as error:
+ # If the old revision is no longer in the repo or something like that,
+ # git can fail. But that shouldn't make the build fail, it should just
+ # not trigger the "useless change" short-circuit.
+ return False
changed_files = set(step.stdout.splitlines()) - set([useless_file])
return changed_files == set()
@@ -349,7 +355,7 @@
api.raw_io.stream_output('bfd/version.h\nothers\n',
name='changed files')) +
api.step_data('check for changes other than gcc/DATESTAMP',
- api.raw_io.stream_output('gcc/DATESTAMP\nothers\n',
+ api.raw_io.stream_output('', retcode=1,
name='changed files')) +
api.step_data('test aarch64 gcc', retcode=1))
yield (api.test(platform + '_useless') +