libabigail/tests/update-test-output.py

71 lines
1.8 KiB
Python
Raw Normal View History

#!/bin/python
Add missing SPDX headers to source files not specifying any license Default to the project's defautl - LGPLv3+ - for those. * Makefile.am: Add a LGPL-3.0-or-later SPDX header prefixed with '##' so that that the header doesn't get emitted in the resulting Makefile.in file. Note that the license of Makefile.in files is "FSF All Permissible License", which virtually compatible with anything. * bash-completion/Makefile.am: Likewise. * doc/Makefile.am: Likewise * doc/manuals/Makefile.am: Likewise * include/Makefile.am: Likewise * src/Makefile.am: Likewise * tests/Makefile.am: Likewise * tests/data/Makefile.am: Likewise * tools/Makefile.am: Likewise * .clang-format: Add a LGPL-3.0-or-later SPDX header. * bash-completion/abicompat: Likewise. * bash-completion/abidiff: Likewise. * bash-completion/abidw: Likewise. * bash-completion/abilint: Likewise. * bash-completion/abinilint: Likewise. * bash-completion/abipkgdiff: Likewise. * bash-completion/abisym: Likewise. * bash-completion/fedabipkgdiff: Likewise. * configure.ac: Likewise. * default.abignore: Likewise. * doc/api/libabigail.doxy: Likewise. * doc/website/libabigail-website.doxy: Likewise. * include/abg-version.h.in: Likewise. * scripts/dot_to_png.sh: Likewise. * scripts/dot_to_svg.sh: Likewise. * scripts/make-verbose.sh: Likewise. * scripts/svg_to_plain_svg.sh: Likewise. * scripts/svg_to_png_and_pdf.sh: Likewise. * tests/runtestcanonicalizetypes.sh.in: Likewise. * tests/runtestdefaultsupprs.py.in: Likewise. * tests/runtestdefaultsupprspy3.sh.in: Likewise. * tests/runtestfedabipkgdiffpy3.sh.in: Likewise. * tests/update-test-output.py: Likewise. * update-copyright.sh: Likewise. Signed-off-by: Benjamin De Kosnik <bkoz@gnu.org> Signed-off-by: Ben Woodard <woodard@redhat.com> Signed-off-by: Chenxiong Qi <cqi@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> Signed-off-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Jan Engelhardt <jengelh@inai.de> Signed-off-by: Jessica Yu <jeyu@kernel.org> Signed-off-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Mark Wielaard <mark@klomp.org> Signed-off-by: Matthias Klose <doko@ubuntu.com> Signed-off-by: Matthias Maennich <maennich@google.com> Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com> Signed-off-by: Roland McGrath <roland@hack.frob.com> Signed-off-by: Sinny Kumari <ksinny@gmail.com> Signed-off-by: Slava Barinov <v.barinov@samsung.com>
2020-05-29 13:50:16 +00:00
# SPDX-License-Identifier: LGPL-3.0-or-later
# This program generates the copy commands you should use to update
# the reference data for tests <build-dir>/tests/runtest* that emit an
# output that is compared against a reference output.
#
# It takes in argument the diff result emitted by
# <build-dir>/tests/runtest*, and emits on standard output a series of
# 'cp <src> <dest>' commands to execute to update reference data of
# the test.
import fileinput
import re
import sys
import getopt
def display_usage():
sys.stderr.write("usage: prog-name [options] <file-name|-->\n");
sys.stderr.write(" options:\n");
sys.stderr.write(" -h display this help\n");
sys.stderr.write(" argument:\n");
sys.stderr.write(" <file-name> the file to read from\n");
sys.stderr.write(" if no argument, then reads from stdin\n");
sys.exit(2)
def main():
input_file = None
try:
opts, args = getopt.getopt(sys.argv[1:], "hi", ["help"])
except getopt.GetoptError as err:
print(str(err))
display_usage()
for opt, arg in opts:
if opt in ("-h", "--help"):
display_usage()
else:
# unknown option.
display_usage()
if input_file == None and len(args) and args[0] != None:
input_file = open(args[0], 'r')
elif input_file == None:
input_file = sys.stdin
if input_file != None:
process(input_file)
else:
display_usage()
def process(input_file):
source = ""
dest = ""
for line in input_file:
m = re.match(r'^--- (.*?)\t', line)
if m:
dest = m.group(1)
else:
m = re.match(r'^\+\+\+ (.*?)\t', line)
if m:
source = m.group(1)
sys.stdout.write("cp " + source + " " + dest + "\n");
if __name__ == "__main__":
main()