From 681f6b59d26c7c9470bc681b0ca0b43c3d0835db Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Wed, 20 Jul 2016 11:23:20 -0700 Subject: [PATCH] versioner: improve the test script. Make it actually run under python3, and add checking for unexpected success. Change-Id: I9aac0e8cc1526fd63db21e57554f3aa5a9b4091d --- tools/versioner/run_tests.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/versioner/run_tests.py b/tools/versioner/run_tests.py index 18b2aa9a3..9bac3e2e6 100755 --- a/tools/versioner/run_tests.py +++ b/tools/versioner/run_tests.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python2 import os import subprocess @@ -13,6 +13,7 @@ prefix_fail = bold + "[" + red + "FAIL" + reset + bold + "]" + reset def indent(text, spaces=4): + text = text.decode("utf-8") prefix = " " return "\n".join([prefix + line for line in text.split("\n")]) @@ -24,9 +25,17 @@ def run_test(test_name, path): (output, _) = process.communicate() if os.path.exists("expected_fail"): - with open("expected_fail") as f: + with open("expected_fail", "rb") as f: expected_output = f.read() - if not output.endswith(expected_output): + if process.returncode == 0: + print("{} {}: unexpected success:".format(prefix_fail, test_name)) + print("") + print(" Expected:") + print(indent(expected_output)) + print(" Actual:") + print(indent(output)) + return False + elif not output.endswith(expected_output): print("{} {}: expected output mismatch".format( prefix_fail, test_name)) print("")