[OE-core] [PATCH] resulttool/merge: Enable merge results to one file
Richard Purdie
richard.purdie at linuxfoundation.org
Tue Mar 26 12:52:05 UTC 2019
On Tue, 2019-03-26 at 10:02 +0800, Yeoh Ee Peng wrote:
> QA team execute extra testing that create multiple test result files,
> where these test result files need to be merged into a single file
> under certain use case.
>
> Enable merge to allow merging results into a single test result file.
>
> Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh at intel.com>
> ---
> scripts/lib/resulttool/merge.py | 29 ++++++++++++-
> scripts/lib/resulttool/resultutils.py | 76 +++++++++++++++++++++++++----------
> 2 files changed, 82 insertions(+), 23 deletions(-)
>
> diff --git a/scripts/lib/resulttool/merge.py b/scripts/lib/resulttool/merge.py
> index 3e4b7a3..90b3cb3 100644
> --- a/scripts/lib/resulttool/merge.py
> +++ b/scripts/lib/resulttool/merge.py
> @@ -17,6 +17,26 @@ import json
> import resulttool.resultutils as resultutils
>
> def merge(args, logger):
> + if args.merge_to_one:
> + if os.path.isdir(args.target_results):
> + target_results = resultutils.load_results(args.target_results)
> + else:
> + target_results = resultutils.append_results({}, args.target_results)
Looking at load_resultsdata:
def load_resultsdata(source, configmap=store_map):
results = {}
if os.path.isfile(source):
append_resultsdata(results, source, configmap)
return results
The code above can therefore be simplified to:
target_results = resultutils.load_results(args.target_results)
?
> + if os.path.isdir(args.base_results):
> + base_results = resultutils.load_results(args.base_results)
> + results = resultutils.append_results(target_results, base_results)
> + else:
> + results = resultutils.append_results(target_results, args.base_results)
Again, I'm not sure you need to differentiate between a file and a
directory given the way the code works internally?
> +
> + target_file_dir = os.path.join(os.path.dirname(args.target_results), 'merged_results/testresults.json')
> + if os.path.isdir(args.target_results):
> + target_file_dir = os.path.join(args.target_results, 'merged_results/testresults.json')
> + if args.merge_to_one_dir:
> + target_file_dir = os.path.join(args.merge_to_one_dir, 'testresults.json')
> + resultutils.make_directory_and_write_json_file(target_file_dir, results)
> + logger.info('Merged results to %s' % target_file_dir)
> + return 0
Isn't this similar to calling load_resultsdata with the 'flatten'
mapping, i.e. resultutils.flatten_map?
That would match the code already in the merge command:
results = resultutils.load_resultsdata(args.base_results, configmap=resultutils.flatten_map)
if os.path.exists(args.target_results):
resultutils.append_resultsdata(results, args.target_results, configmap=resultutils.flatten_map)
resultutils.save_resultsdata(results, os.path.dirname(args.target_results), fn=os.path.basename(args.target_results))
i.e. if you call:
"resulttool merge XXXX merged_results/testresults.json"
it should merge the results from XXXX into the results file specified?
In other words, doesn't the tool already support this?
Cheers,
Richard
More information about the Openembedded-core
mailing list