Output error.log from test.dart
Show stacktrace of dart test from the framework presubmit checks
read log file
Change-Id: I48cb7b07c6675e683f83e051e92dc80c3ec881f7
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/38980
Reviewed-by: Casey Hillers <chillers@google.com>
Commit-Queue: Jesús Guerrero <jsguerrero@google.com>
diff --git a/recipe_modules/logs_util/api.py b/recipe_modules/logs_util/api.py
index 3acb226..bb513d3 100644
--- a/recipe_modules/logs_util/api.py
+++ b/recipe_modules/logs_util/api.py
@@ -94,3 +94,12 @@
name='upload logs %s' % git_hash,
unauthenticated_url=True
)
+
+ def show_logs_stdout(self, file_path):
+ """Outputs to sdout the connect of file_path
+
+ :param file_path: str
+ :return:
+ """
+ if self.m.path.exists(file_path):
+ self.m.file.read_text('Read log file', file_path)
diff --git a/recipe_modules/logs_util/examples/full.expected/basic.json b/recipe_modules/logs_util/examples/full.expected/basic.json
index d9da2b2..3292259 100644
--- a/recipe_modules/logs_util/examples/full.expected/basic.json
+++ b/recipe_modules/logs_util/examples/full.expected/basic.json
@@ -138,6 +138,41 @@
"name": "store metrics (2)"
},
{
+ "cmd": [
+ "vpython3",
+ "-u",
+ "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+ "--json-output",
+ "/path/to/tmp/json",
+ "copy",
+ "{\"a\": \"b\"}",
+ "[CLEANUP]/flutter_logs_dir/errors.log"
+ ],
+ "infra_step": true,
+ "name": "write file",
+ "~followup_annotations": [
+ "@@@STEP_LOG_LINE@errors.log@{\"a\": \"b\"}@@@",
+ "@@@STEP_LOG_END@errors.log@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "vpython3",
+ "-u",
+ "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+ "--json-output",
+ "/path/to/tmp/json",
+ "copy",
+ "[CLEANUP]/flutter_logs_dir/errors.log",
+ "/path/to/tmp/"
+ ],
+ "infra_step": true,
+ "name": "Read log file",
+ "~followup_annotations": [
+ "@@@STEP_LOG_END@errors.log@@@"
+ ]
+ },
+ {
"name": "$result"
}
]
\ No newline at end of file
diff --git a/recipe_modules/logs_util/examples/full.py b/recipe_modules/logs_util/examples/full.py
index 1f57f4a..b44219c 100644
--- a/recipe_modules/logs_util/examples/full.py
+++ b/recipe_modules/logs_util/examples/full.py
@@ -8,6 +8,7 @@
DEPS = [
'flutter/logs_util',
'recipe_engine/path',
+ 'recipe_engine/file'
]
@@ -18,6 +19,9 @@
s = api.path['cleanup'].join('flutter_logs_dir')
api.logs_util.upload_test_metrics(s, 'taskname', 'hash')
api.logs_util.upload_test_metrics('/path/to/tmp/json', 'taskname2')
+ api.file.write_json('write file', s.join('errors.log'), {'a': 'b'})
+ api.logs_util.show_logs_stdout(s.join('errors.log'))
+ api.logs_util.show_logs_stdout('no_file')
def GenTests(api):
diff --git a/recipes/flutter/flutter_drone.py b/recipes/flutter/flutter_drone.py
index 64dbf61..aab1432 100644
--- a/recipes/flutter/flutter_drone.py
+++ b/recipes/flutter/flutter_drone.py
@@ -24,6 +24,7 @@
'recipe_engine/path',
'recipe_engine/properties',
'recipe_engine/step',
+ 'recipe_engine/file',
]
# Default timeouts for framework tests.
@@ -54,6 +55,7 @@
cmd_list,
timeout_secs=deps_timeout_secs
)
+ api.logs_util.show_logs_stdout(checkout_path.join('errors.log'))
api.logs_util.upload_test_metrics(
checkout_path.join('test_results.json'),
'%s_%s' % (api.properties.get('shard'), api.properties.get('subshard'))