/[jscoverage]/trunk/js/config/check-sync-dirs.py
ViewVC logotype

Diff of /trunk/js/config/check-sync-dirs.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 459 by siliconforks, Tue Dec 9 03:37:47 2008 UTC revision 460 by siliconforks, Sat Sep 26 23:15:22 2009 UTC
# Line 22  Line 22 
22  import fnmatch  import fnmatch
23    
24  if len(sys.argv) != 3:  if len(sys.argv) != 3:
25      print >> sys.stderr, "Usage: %s COPY ORIGINAL" % sys.argv[0]      print >> sys.stderr, 'TEST-UNEXPECTED-FAIL | check-sync-dirs.py | Usage: %s COPY ORIGINAL' % sys.argv[0]
26      sys.exit(1)      sys.exit(1)
27    
28  copy = sys.argv[1]  copy = os.path.abspath(sys.argv[1])
29  original = sys.argv[2]  original = os.path.abspath(sys.argv[2])
30    
31  # Ignore detritus left lying around by editing tools.  # Ignore detritus left lying around by editing tools.
32  ignored_patterns = ['*~', '.#*', '#*#', '*.orig', '*.rej']  ignored_patterns = ['*~', '.#*', '#*#', '*.orig', '*.rej']
# Line 38  Line 38 
38  def read_exceptions(filename):  def read_exceptions(filename):
39      if (os.path.exists(filename)):      if (os.path.exists(filename)):
40          f = file(filename)          f = file(filename)
41          exceptions={}          exceptions = {}
42          for line in f:          for line in f:
43              line = line.strip()              line = line.strip()
44              if line != '' and line[0] != '#':              if line != '' and line[0] != '#':
# Line 61  Line 61 
61  # file that differs, apply REPORT to COPY, ORIGINAL, and the file's  # file that differs, apply REPORT to COPY, ORIGINAL, and the file's
62  # relative path.  COPY and ORIGINAL should be absolute.  Ignore files  # relative path.  COPY and ORIGINAL should be absolute.  Ignore files
63  # that match patterns given in the list IGNORE.  # that match patterns given in the list IGNORE.
64  def check(copy, original, ignore, report):  def check(copy, original, ignore):
65      os.chdir(copy)      os.chdir(copy)
66      for (dirpath, dirnames, filenames) in os.walk('.'):      for (dirpath, dirnames, filenames) in os.walk('.'):
67          exceptions = read_exceptions(join(dirpath, 'check-sync-exceptions'))          exceptions = read_exceptions(join(dirpath, 'check-sync-exceptions'))
68          for filename in filenames:          for filename in filenames:
69              if filename in exceptions:              if (filename in exceptions) or fnmatch_any(filename, ignore):
                 continue  
             if fnmatch_any(filename, ignore):  
70                  continue                  continue
71              relative_name = join(dirpath, filename)              relative_name = join(dirpath, filename)
72              original_name = join(original, relative_name)              original_name = join(original, relative_name)
# Line 77  Line 75 
75                  continue                  continue
76              report(copy, original, relative_name)              report(copy, original, relative_name)
77    
   
78  differences_found = False  differences_found = False
79    
80  # Print an error message for DIFFERING, which was found to differ  # Print an error message for DIFFERING, which was found to differ
# Line 85  Line 82 
82  def report(copy, original, differing):  def report(copy, original, differing):
83      global differences_found      global differences_found
84      if not differences_found:      if not differences_found:
85          print >> sys.stderr, "TEST-FAIL | build file copies are not in sync"          print >> sys.stderr, 'TEST-UNEXPECTED-FAIL | check-sync-dirs.py | build file copies are not in sync\n' \
86          print >> sys.stderr, "file(s) found in:               %s" % (copy)                               'TEST-INFO | check-sync-dirs.py | file(s) found in:               %s\n' \
87          print >> sys.stderr, ("differ from their originals in: %s"                               'TEST-INFO | check-sync-dirs.py | differ from their originals in: %s' \
88                                % (original))                               % (copy, original)
89      print >> sys.stderr, "file differs: %s" % (differing)      print >> sys.stderr, 'TEST-INFO | check-sync-dirs.py | differing file:                 %s' % differing
90      differences_found = True      differences_found = True
91    
92  check(os.path.abspath(copy),  check(copy, original, ignored_patterns)
       os.path.abspath(original),  
       ignored_patterns,  
       report)  
93    
94  if differences_found:  if differences_found:
95      msg=('''In general, the files in '%s' should always be exact copies of      msg = '''In general, the files in '%s' should always be exact copies of
96  originals in '%s'.  A change made to one should also be made to the  originals in '%s'.  A change made to one should also be made to the
97  other.  See 'check-sync-dirs.py' for more details.'''  other.  See 'check-sync-dirs.py' for more details.''' \
98           % (copy, original))           % (copy, original)
99      print >> sys.stderr, textwrap.fill(msg, 75)      print >> sys.stderr, textwrap.fill(msg, 75)
100      sys.exit(1)      sys.exit(1)
101    
102    print >> sys.stderr, 'TEST-PASS | check-sync-dirs.py | %s <= %s' % (copy, original)
103  sys.exit(0)  sys.exit(0)

Legend:
Removed from v.459  
changed lines
  Added in v.460

  ViewVC Help
Powered by ViewVC 1.1.24