xref: /aosp_15_r20/external/cronet/testing/merge_scripts/noop_merge.py (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1#!/usr/bin/env python
2# Copyright 2017 The Chromium Authors
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6from __future__ import print_function
7
8import argparse
9import json
10import shutil
11import sys
12
13import merge_api
14
15
16def noop_merge(output_json, jsons_to_merge):
17  """Use the first supplied JSON as the output JSON.
18
19  Primarily intended for unsharded tasks.
20
21  Args:
22    output_json: A path to a JSON file to which the results should be written.
23    jsons_to_merge: A list of paths to JSON files.
24  """
25  if len(jsons_to_merge) > 1:
26    print('Multiple JSONs provided: %s' % (','.join(jsons_to_merge)),
27        file=sys.stderr)
28    return 1
29  if jsons_to_merge:
30    shutil.copyfile(jsons_to_merge[0], output_json)
31  else:
32    with open(output_json, 'w') as f:
33      json.dump({}, f)
34  return 0
35
36
37def main(raw_args):
38  parser = merge_api.ArgumentParser()
39  args = parser.parse_args(raw_args)
40
41  return noop_merge(args.output_json, args.jsons_to_merge)
42
43
44if __name__ == '__main__':
45  sys.exit(main(sys.argv[1:]))
46