diff mbox

[committed] Fix validate_failures.py in standalone testing

Message ID 20130206202236.GA20130@google.com
State New
Headers show

Commit Message

Diego Novillo Feb. 6, 2013, 8:22 p.m. UTC
When using validate_failures.py with --manifest and --results, we
don't need a GCC build directory.  This is useful when using the
validator outside of the build tree.  We were insisting on finding
a valid build tree regardless of those options.

Tested on x86_64.  Committed to trunk.

	* testsuite-management/validate_failures.py: Update
	Copyright years.
	Request contributions not to use Python features newer
	than 2.4.
	(GetBuildData): If this is not a build directory,
	emit an error only if --results or --manifest are missing.
diff mbox

Patch

diff --git a/contrib/testsuite-management/validate_failures.py b/contrib/testsuite-management/validate_failures.py
index 5c80ca3..76f9aab 100755
--- a/contrib/testsuite-management/validate_failures.py
+++ b/contrib/testsuite-management/validate_failures.py
@@ -2,10 +2,14 @@ 
 
 # Script to compare testsuite failures against a list of known-to-fail
 # tests.
+#
+# NOTE: This script is used in installations that are running Python 2.4.
+#       Please stick to syntax features available in 2.4 and earlier
+#       versions.
 
 # Contributed by Diego Novillo <dnovillo@google.com>
 #
-# Copyright (C) 2011, 2012 Free Software Foundation, Inc.
+# Copyright (C) 2011-2013 Free Software Foundation, Inc.
 #
 # This file is part of GCC.
 #
@@ -78,7 +82,7 @@  _MANIFEST_PATH_PATTERN = '%s/%s/%s.xfail'
 _OPTIONS = None
 
 def Error(msg):
-  print >>sys.stderr, '\nerror: %s' % msg
+  print >>sys.stderr, 'error: %s' % msg
   sys.exit(1)
 
 
@@ -358,15 +362,24 @@  def GetManifestPath(srcdir, target, user_provided_must_exist):
       Error('Manifest does not exist: %s' % manifest_path)
     return manifest_path
   else:
+    assert srdir and target
     return _MANIFEST_PATH_PATTERN % (srcdir, _MANIFEST_SUBDIR, target)
 
 
 def GetBuildData():
-  target = GetMakefileValue('%s/Makefile' % _OPTIONS.build_dir, 'target_alias=')
   srcdir = GetMakefileValue('%s/Makefile' % _OPTIONS.build_dir, 'srcdir =')
+  target = GetMakefileValue('%s/Makefile' % _OPTIONS.build_dir, 'target_alias=')
   if not ValidBuildDirectory(_OPTIONS.build_dir, target):
-    Error('%s is not a valid GCC top level build directory.' %
-          _OPTIONS.build_dir)
+    # If we have been given a set of results to use, we may
+    # not be inside a valid GCC build directory.  In that case,
+    # the user must provide both a manifest file and a set
+    # of results to check against it.
+    if not _OPTIONS.results or not _OPTIONS.manifest:
+      Error('%s is not a valid GCC top level build directory. '
+            'You must use --manifest and --results to do the validation.' %
+            _OPTIONS.build_dir)
+    else:
+      return None, None
   print 'Source directory: %s' % srcdir
   print 'Build target:     %s' % target
   return srcdir, target
@@ -410,7 +423,7 @@  def PerformComparison(expected, actual, ignore_missing_failures):
 
 
 def CheckExpectedResults():
-  (srcdir, target) = GetBuildData()
+  srcdir, target = GetBuildData()
   manifest_path = GetManifestPath(srcdir, target, True)
   print 'Manifest:         %s' % manifest_path
   manifest = GetManifest(manifest_path)
@@ -485,7 +498,8 @@  def Main(argv):
   parser.add_option('--manifest', action='store', type='string',
                     dest='manifest', default=None,
                     help='Name of the manifest file to use (default = '
-                    'taken from contrib/testsuite-managment/<target_alias>.xfail)')
+                    'taken from '
+                    'contrib/testsuite-managment/<target_alias>.xfail)')
   parser.add_option('--produce_manifest', action='store_true',
                     dest='produce_manifest', default=False,
                     help='Produce the manifest for the current '