Patchwork [RFA,5/8] validate_failures.py: make options a global

login
register
mail settings
Submitter Doug Evans
Date Nov. 24, 2012, 10:52 p.m.
Message ID <yjt2y5hq62ck.fsf@ruffy2.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/201484/
State New
Headers show

Comments

Doug Evans - Nov. 24, 2012, 10:52 p.m.
Hi.
This fifth patch makes options a global variable.
As validate_failures.py becomes more complex, passing it around everywhere
becomes cumbersome with no real gain.

Ok to check in?

2012-11-24  Doug Evans  <dje@google.com>

	* testsuite-management/validate_failures.py: Make options a global variable.
Diego Novillo - Nov. 25, 2012, 3:42 p.m.
On Sat, Nov 24, 2012 at 5:52 PM, Doug Evans <dje@google.com> wrote:
> Hi.
> This fifth patch makes options a global variable.
> As validate_failures.py becomes more complex, passing it around everywhere
> becomes cumbersome with no real gain.
>
> Ok to check in?
>
> 2012-11-24  Doug Evans  <dje@google.com>
>
>         * testsuite-management/validate_failures.py: Make options a global variable.

I agree with the intent, but perhaps make it _OPTIONS?  OK with that change.


Diego.

Patch

--- validate_failures.py.manifest-path	2012-11-24 13:32:47.131550661 -0800
+++ validate_failures.py	2012-11-24 13:40:47.016143990 -0800
@@ -60,6 +60,9 @@  _VALID_TEST_RESULTS = [ 'FAIL', 'UNRESOL
 # target triple used during the build.
 _MANIFEST_PATH_PATTERN = '%s/contrib/testsuite-management/%s.xfail'
 
+# The options passed to the program.
+options = None
+
 def Error(msg):
   print >>sys.stderr, '\nerror: %s' % msg
   sys.exit(1)
@@ -273,7 +276,7 @@  def CompareResults(manifest, actual):
   return actual_vs_manifest, manifest_vs_actual
 
 
-def GetBuildData(options):
+def GetBuildData():
   target = GetMakefileValue('%s/Makefile' % options.build_dir, 'target_alias=')
   srcdir = GetMakefileValue('%s/Makefile' % options.build_dir, 'srcdir =')
   if not ValidBuildDirectory(options.build_dir, target):
@@ -321,9 +324,9 @@  def PerformComparison(expected, actual, 
   return tests_ok
 
 
-def CheckExpectedResults(options):
+def CheckExpectedResults():
   if not options.manifest:
-    (srcdir, target, valid_build) = GetBuildData(options)
+    (srcdir, target, valid_build) = GetBuildData()
     if not valid_build:
       return False
     manifest_path = _MANIFEST_PATH_PATTERN % (srcdir, target)
@@ -344,8 +347,8 @@  def CheckExpectedResults(options):
   return PerformComparison(manifest, actual, options.ignore_missing_failures)
 
 
-def ProduceManifest(options):
-  (srcdir, target, valid_build) = GetBuildData(options)
+def ProduceManifest():
+  (srcdir, target, valid_build) = GetBuildData()
   if not valid_build:
     return False
 
@@ -365,8 +368,8 @@  def ProduceManifest(options):
   return True
 
 
-def CompareBuilds(options):
-  (srcdir, target, valid_build) = GetBuildData(options)
+def CompareBuilds():
+  (srcdir, target, valid_build) = GetBuildData()
   if not valid_build:
     return False
 
@@ -422,14 +425,15 @@  def Main(argv):
                     '.sum files collected from the build directory).')
   parser.add_option('--verbosity', action='store', dest='verbosity',
                     type='int', default=0, help='Verbosity level (default = 0)')
+  global options
   (options, _) = parser.parse_args(argv[1:])
 
   if options.produce_manifest:
-    retval = ProduceManifest(options)
+    retval = ProduceManifest()
   elif options.clean_build:
-    retval = CompareBuilds(options)
+    retval = CompareBuilds()
   else:
-    retval = CheckExpectedResults(options)
+    retval = CheckExpectedResults()
 
   if retval:
     return 0