summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordcheng <dcheng@chromium.org>2015-05-14 12:44:11 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-14 19:44:21 +0000
commit5171d85366fe1bd7c1de43e866adc3c3e50bc419 (patch)
tree24b30b163406f5660ad0ce99a285a4b903cd5f6f
parent9bb374b668ecdc057bed01c658833939b07c48e3 (diff)
downloadchromium_src-5171d85366fe1bd7c1de43e866adc3c3e50bc419.zip
chromium_src-5171d85366fe1bd7c1de43e866adc3c3e50bc419.tar.gz
chromium_src-5171d85366fe1bd7c1de43e866adc3c3e50bc419.tar.bz2
Remove test result whitespace stripping from blink_gc_plugin test script
To make things easier for future developers, the test script now parses the options using argparse and provides a --reset-results flag to easily update the baselines. BUG=none Review URL: https://codereview.chromium.org/1132293003 Cr-Commit-Position: refs/heads/master@{#329904}
-rw-r--r--tools/clang/blink_gc_plugin/tests/cycle_ptrs.txt1
-rw-r--r--tools/clang/blink_gc_plugin/tests/cycle_sub.txt1
-rw-r--r--tools/clang/blink_gc_plugin/tests/cycle_super.txt1
-rw-r--r--tools/clang/blink_gc_plugin/tests/cycle_super_neg.txt1
-rw-r--r--tools/clang/blink_gc_plugin/tests/register_weak_members_template.txt1
-rwxr-xr-xtools/clang/blink_gc_plugin/tests/test.py41
-rw-r--r--tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl.txt1
-rw-r--r--tools/clang/blink_gc_plugin/tests/traceimpl.txt1
-rw-r--r--tools/clang/blink_gc_plugin/tests/traceimpl_derived_from_templated_base.txt1
-rw-r--r--tools/clang/blink_gc_plugin/tests/traceimpl_omitted_trace.txt1
-rw-r--r--tools/clang/blink_gc_plugin/tests/traceimpl_overloaded.txt1
11 files changed, 27 insertions, 24 deletions
diff --git a/tools/clang/blink_gc_plugin/tests/cycle_ptrs.txt b/tools/clang/blink_gc_plugin/tests/cycle_ptrs.txt
index 7ad6c48..4d242a6 100644
--- a/tools/clang/blink_gc_plugin/tests/cycle_ptrs.txt
+++ b/tools/clang/blink_gc_plugin/tests/cycle_ptrs.txt
@@ -5,3 +5,4 @@ Found a potentially leaking cycle starting from a GC root:
./cycle_ptrs.h:34:5: blink::B (m_c) => blink::C
./cycle_ptrs.h:39:5: blink::C (m_d) => blink::D
./cycle_ptrs.h:44:5: blink::D (m_es) => blink::E
+
diff --git a/tools/clang/blink_gc_plugin/tests/cycle_sub.txt b/tools/clang/blink_gc_plugin/tests/cycle_sub.txt
index 9c015c8..b37907d 100644
--- a/tools/clang/blink_gc_plugin/tests/cycle_sub.txt
+++ b/tools/clang/blink_gc_plugin/tests/cycle_sub.txt
@@ -3,3 +3,4 @@ Found a potentially leaking cycle starting from a GC root:
./cycle_sub.h:31:5: blink::C (m_a) => blink::A
./cycle_sub.h:22:11: blink::A (<subclass>) => blink::B
./cycle_sub.h:26:5: blink::B (m_c) => blink::C
+
diff --git a/tools/clang/blink_gc_plugin/tests/cycle_super.txt b/tools/clang/blink_gc_plugin/tests/cycle_super.txt
index 374074b..89b3675 100644
--- a/tools/clang/blink_gc_plugin/tests/cycle_super.txt
+++ b/tools/clang/blink_gc_plugin/tests/cycle_super.txt
@@ -2,3 +2,4 @@
Found a potentially leaking cycle starting from a GC root:
./cycle_super.h:36:5: blink::D (m_c) => blink::C
./cycle_super.h:21:5: blink::C (blink::B <: blink::A <: m_d) => blink::D
+
diff --git a/tools/clang/blink_gc_plugin/tests/cycle_super_neg.txt b/tools/clang/blink_gc_plugin/tests/cycle_super_neg.txt
deleted file mode 100644
index 8b13789..0000000
--- a/tools/clang/blink_gc_plugin/tests/cycle_super_neg.txt
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/tools/clang/blink_gc_plugin/tests/register_weak_members_template.txt b/tools/clang/blink_gc_plugin/tests/register_weak_members_template.txt
deleted file mode 100644
index 8b13789..0000000
--- a/tools/clang/blink_gc_plugin/tests/register_weak_members_template.txt
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/tools/clang/blink_gc_plugin/tests/test.py b/tools/clang/blink_gc_plugin/tests/test.py
index acb7e74..5ade032 100755
--- a/tools/clang/blink_gc_plugin/tests/test.py
+++ b/tools/clang/blink_gc_plugin/tests/test.py
@@ -4,18 +4,20 @@
# found in the LICENSE file.
+import argparse
import glob
import os
import subprocess
import sys
-def run_test(test_base_name, cmd):
+def run_test(test_base_name, cmd, reset_results):
"""Run a test case.
Args:
test_base_name: The name for the test C++ source file without the extension.
cmd: The actual command to run for the test.
+ reset_results: True if the results should be overwritten in place.
Returns:
None on pass, or a str with the description of the failure.
@@ -47,31 +49,31 @@ def run_test(test_base_name, cmd):
# from a previous run.
os.remove('%s.graph.json' % test_base_name)
- # TODO(dcheng): Remove the rstrip() and just rebaseline the tests to match.
- actual = actual.rstrip()
-
# On Windows, clang emits CRLF as the end of line marker. Normalize it to LF
# to match posix systems.
actual = actual.replace('\r\n', '\n')
+ result_file = '%s.txt%s' % (
+ test_base_name, '' if reset_results else '.actual')
try:
- expected = open('%s.txt' % test_base_name).read().rstrip()
+ expected = open('%s.txt' % test_base_name).read()
except IOError:
- open('%s.txt.actual' % test_base_name, 'w').write(actual)
+ open(result_file, 'w').write(actual)
return 'no expected file found'
if expected != actual:
- open('%s.txt.actual' % test_base_name, 'w').write(actual)
+ open(result_file, 'w').write(actual)
return 'expected and actual differed'
-def run_tests(clang_path, plugin_path):
+def run_tests(clang_path, plugin_path, reset_results):
"""Runs the tests.
Args:
clang_path: The path to the clang binary to be tested.
plugin_path: An optional path to the plugin to test. This may be None, if
plugin is built directly into clang, like on Windows.
+ reset_results: True if the results should be overwritten in place.
Returns:
(passing, failing): Two lists containing the base names of the passing and
@@ -101,7 +103,7 @@ def run_tests(clang_path, plugin_path):
pass
cmd.append(test)
- failure_message = run_test(test_base_name, cmd)
+ failure_message = run_test(test_base_name, cmd, reset_results)
if failure_message:
print 'failed: %s' % failure_message
failing.append(test_base_name)
@@ -113,18 +115,23 @@ def run_tests(clang_path, plugin_path):
def main():
- if len(sys.argv) < 2:
- print 'Usage: <path to clang>[ <path to plugin>]'
- return -1
+ parser = argparse.ArgumentParser()
+ parser.add_argument(
+ '--reset-results', action='store_true',
+ help='If specified, overwrites the expected results in place.')
+ parser.add_argument('clang_path', help='The path to the clang binary.')
+ parser.add_argument('plugin_path', nargs='?',
+ help='The path to the plugin library, if any.')
+ args = parser.parse_args()
os.chdir(os.path.dirname(os.path.realpath(__file__)))
- clang_path = sys.argv[1]
- plugin_path = sys.argv[2] if len(sys.argv) > 2 else None
- print 'Using clang %s...' % clang_path
- print 'Using plugin %s...' % plugin_path
+ print 'Using clang %s...' % args.clang_path
+ print 'Using plugin %s...' % args.plugin_path
- passing, failing = run_tests(clang_path, plugin_path)
+ passing, failing = run_tests(args.clang_path,
+ args.plugin_path,
+ args.reset_results)
print 'Ran %d tests: %d succeeded, %d failed' % (
len(passing) + len(failing), len(passing), len(failing))
for test in failing:
diff --git a/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl.txt b/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl.txt
deleted file mode 100644
index 8b13789..0000000
--- a/tools/clang/blink_gc_plugin/tests/trace_after_dispatch_impl.txt
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/tools/clang/blink_gc_plugin/tests/traceimpl.txt b/tools/clang/blink_gc_plugin/tests/traceimpl.txt
deleted file mode 100644
index 8b13789..0000000
--- a/tools/clang/blink_gc_plugin/tests/traceimpl.txt
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/tools/clang/blink_gc_plugin/tests/traceimpl_derived_from_templated_base.txt b/tools/clang/blink_gc_plugin/tests/traceimpl_derived_from_templated_base.txt
deleted file mode 100644
index 8b13789..0000000
--- a/tools/clang/blink_gc_plugin/tests/traceimpl_derived_from_templated_base.txt
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/tools/clang/blink_gc_plugin/tests/traceimpl_omitted_trace.txt b/tools/clang/blink_gc_plugin/tests/traceimpl_omitted_trace.txt
deleted file mode 100644
index 8b13789..0000000
--- a/tools/clang/blink_gc_plugin/tests/traceimpl_omitted_trace.txt
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded.txt b/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded.txt
deleted file mode 100644
index 8b13789..0000000
--- a/tools/clang/blink_gc_plugin/tests/traceimpl_overloaded.txt
+++ /dev/null
@@ -1 +0,0 @@
-