bug 664197 - fix manifestparser tests on Windows
authorTed Mielczarek <ted.mielczarek@gmail.com>
Tue, 28 Jun 2011 15:19:03 -0400
changeset 71966 e831c1712cf6c930c97b4c4d808605d14a595749
parent 71965 9ece40393310d866fb3ea07a37a7e3b44578eac5
child 71967 5974e4cb3fc29826bbe275caf5fa1bdf3b4cd968
push idunknown
push userunknown
push dateunknown
bugs664197
milestone7.0a1
bug 664197 - fix manifestparser tests on Windows
build/manifestparser.py
--- a/build/manifestparser.py
+++ b/build/manifestparser.py
@@ -50,17 +50,17 @@ Mozilla universal manifest parser
 
 import os
 import re
 import shutil
 import sys
 from fnmatch import fnmatch
 from optparse import OptionParser
 
-version = '0.5.1' # package version
+version = '0.5.2' # package version
 try:
     from setuptools import setup
 except ImportError:
     setup = None
 
 # we need relpath, but it is introduced in python 2.6
 # http://docs.python.org/library/os.path.html
 try:
@@ -304,16 +304,23 @@ def parse(text, **values):
     return ExpressionParser(text, values).parse()
 
 def normalize_path(path):
     """normalize a relative path"""
     if sys.platform.startswith('win'):
         return path.replace('/', os.path.sep)
     return path
 
+def denormalize_path(path):
+    """denormalize a relative path"""
+    if sys.platform.startswith('win'):
+        return path.replace(os.path.sep, '/')
+    return path
+    
+
 def read_ini(fp, variables=None, default='DEFAULT',
              comments=';#', separators=('=', ':'),
              strict=True):
     """
     read an .ini file and return a list of [(section, values)]
     - fp : file pointer or path to read
     - variables : default set of variables
     - default : name of the section for the default section
@@ -609,17 +616,17 @@ class ManifestParser(object):
                 print >> fp, '%s = %s' % (key, value)
             print >> fp
 
         for test in tests:
             test = test.copy() # don't overwrite
 
             path = test['name']
             if not os.path.isabs(path):
-                path = relpath(test['path'], self.rootdir)
+                path = denormalize_path(relpath(test['path'], self.rootdir))
             print >> fp, '[%s]' % path
           
             # reserved keywords:
             reserved = ['path', 'name', 'here', 'manifest']
             for key in sorted(test.keys()):
                 if key in reserved:
                     continue
                 if key in global_kwargs:
@@ -799,17 +806,17 @@ def convert(directories, pattern=None, i
         for dirpath, dirnames, filenames in os.walk(directory):
 
             # filter out directory names
             dirnames = [ i for i in dirnames if i not in ignore ]
             dirnames.sort()
 
             # reference only the subdirectory
             _dirpath = dirpath
-            dirpath = dirpath.split(directory, 1)[-1].strip('/')
+            dirpath = dirpath.split(directory, 1)[-1].strip(os.path.sep)
 
             if dirpath.split(os.path.sep)[0] in ignore:
                 continue
 
             # filter by glob
             if pattern:
                 filenames = [filename for filename in filenames
                              if fnmatch(filename, pattern)]
@@ -821,17 +828,17 @@ def convert(directories, pattern=None, i
                 manifest = file(os.path.join(_dirpath, write), 'w')
                 for dirname in dirnames:
                     print >> manifest, '[include:%s]' % os.path.join(dirname, write)
                 for filename in filenames:
                     print >> manifest, '[%s]' % filename
                 manifest.close()
 
             # add to the list
-            retval.extend([os.path.join(dirpath, filename)
+            retval.extend([denormalize_path(os.path.join(dirpath, filename))
                            for filename in filenames])
 
     if write:
         return # the manifests have already been written!
   
     retval.sort()
     retval = ['[%s]' % filename for filename in retval]
     return '\n'.join(retval)