Files
Joel Brobecker 19bafbec4e Make some testcase's output more predictable to avoid spurious errors
These testcases are testing the git-hooks behavior when using
a commit-extra-checker hook. This hook works by receiving info
about the commit to check via stdin, as a dictionary in JSON format.

To help the testcase verify the data being passed via its stdin,
the hook currently prints the contents of stdin verbatim.
Unfortunately, this makes an unwarranted assumption about
the order of the elements in that string representation,
causing spurious differences when trying to run this testcase
with Python 3.x.

This commit enhances the scripts used by these testcases to
output the contents of the data in a way which is always
the same, regardless of the order it was passed in.

TN: U530-006
Change-Id: Ia8b16611bb29b7601f14949ee5554c906b947853
2021-07-17 15:30:57 -07:00

18 lines
466 B
Python
Executable File

#! /usr/bin/env python
import sys
import json
cli_args = sys.argv[1:]
stdin_data = sys.stdin.read()
print("DEBUG: commit-extra-checker.py {}".format(" ".join(cli_args)))
print("-----[ stdin ]-----")
checker_data = json.loads(stdin_data)
for k in sorted(checker_data.keys()):
print(" . {}: {}".format(k, checker_data[k]))
print("---[ end stdin ]---")
if "(bad-commit)" in stdin_data:
print("Error: Invalid bla bla bla. Rejecting Update.")
sys.exit(1)