зеркало из https://github.com/mozilla/pjs.git
Bug 680246 - add missing files from import - r=khuey
This commit is contained in:
Родитель
5f06bea7d1
Коммит
78fed191e3
|
@ -0,0 +1,37 @@
|
|||
# -*- makefile -*-
|
||||
# vim:set ts=8 sw=8 sts=8 noet:
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
|
||||
###########################################################################
|
||||
# AUTO_DEPS - A list of deps/targets drived from other macros.
|
||||
# *_DEPS - Make dependencies derived from a given macro.
|
||||
###########################################################################
|
||||
|
||||
|
||||
###########################################################################
|
||||
# Threadsafe directory creation
|
||||
# GENERATED_DIRS - Automated creation of these directories.
|
||||
###########################################################################
|
||||
mkdir_deps =$(foreach dir,$($(1)),$(dir)/.mkdir.done)
|
||||
|
||||
ifneq (,$(GENERATED_DIRS))
|
||||
tmpauto :=$(call mkdir_deps,GENERATED_DIRS)
|
||||
GENERATED_DIRS_DEPS +=$(tmpauto)
|
||||
GARBAGE_DIRS +=$(tmpauto)
|
||||
endif
|
||||
|
||||
%/.mkdir.done:
|
||||
$(subst $(SPACE)-p,$(null),$(MKDIR)) -p $(dir $@)
|
||||
@$(TOUCH) $@
|
||||
|
||||
#################################################################
|
||||
# One ring/dep to rule them all:
|
||||
# config/rules.mk::all target is available by default
|
||||
# Add $(AUTO_DEPS) as an explicit target dependency when needed.
|
||||
#################################################################
|
||||
AUTO_DEPS +=$(GENERATED_DIRS_DEPS)
|
||||
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,44 @@
|
|||
# -*- makefile -*-
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
|
||||
PYTHON ?= python
|
||||
PYTEST = $(PYTHON) -E
|
||||
|
||||
# python -B not supported by older interpreters
|
||||
export PYTHONDONTWRITEBYTECODE=1
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
# INCLUDED_CONFIG_MK = 1
|
||||
include $(topsrcdir)/config/config.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
autotgt_tests = .deps/autotargets.mk.ts
|
||||
|
||||
tgts =\
|
||||
.deps/.mkdir.done\
|
||||
$(autotgt_tests)
|
||||
$(NULL)
|
||||
|
||||
|
||||
##------------------_##
|
||||
##---] TARGETS [---##
|
||||
##------------------_##
|
||||
all::
|
||||
|
||||
check:: $(tgts)
|
||||
|
||||
# Only run unit test when autotargets.mk is modified
|
||||
$(autotgt_tests): $(topsrcdir)/config/makefiles/autotargets.mk
|
||||
echo "MAKECMD=$(MAKE)"
|
||||
MAKECMD=$(MAKE) $(PYTEST) $(srcdir)/check_mkdir.tpy
|
||||
@$(TOUCH) $@
|
||||
|
|
@ -0,0 +1,271 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from subprocess import call
|
||||
from shutil import rmtree
|
||||
|
||||
import logging
|
||||
import unittest
|
||||
|
||||
|
||||
def banner():
|
||||
"""
|
||||
Display interpreter and system info for the test env
|
||||
"""
|
||||
print '*' * 75
|
||||
cmd = os.path.basename(__file__)
|
||||
print "%s: python version is %s" % (cmd, sys.version)
|
||||
print '*' * 75
|
||||
|
||||
|
||||
def myopts(vals):
|
||||
"""
|
||||
Storage for extra command line args passed.
|
||||
|
||||
Returns:
|
||||
hash - argparse::Namespace object values
|
||||
"""
|
||||
|
||||
if not hasattr(myopts, 'vals'):
|
||||
if 'argparse' in sys.modules:
|
||||
tmp = { } # key existance enables unittest module debug
|
||||
else:
|
||||
tmp = { 'debug': False, 'verbose': False }
|
||||
|
||||
for k in dir(vals):
|
||||
if k[0:1] == '_':
|
||||
continue
|
||||
tmp[k] = getattr(vals, k)
|
||||
myopts.vals = tmp
|
||||
|
||||
return myopts.vals
|
||||
|
||||
|
||||
def path2posix(src):
|
||||
"""
|
||||
Normalize directory path syntax
|
||||
|
||||
Keyword arguments:
|
||||
src - path to normalize
|
||||
|
||||
Returns:
|
||||
scalar - a file path with drive separators and windows slashes removed
|
||||
|
||||
Todo:
|
||||
move to {build,config,tools,toolkit}/python for use in a library
|
||||
"""
|
||||
|
||||
## (drive, tail) = os.path.splitdrive(src)
|
||||
## Support path testing on all platforms
|
||||
drive = ''
|
||||
winpath = src.find(':')
|
||||
if -1 != winpath and 10 > winpath:
|
||||
(drive, tail) = src.split(':', 2)
|
||||
|
||||
if drive:
|
||||
todo = [ '', drive.rstrip(':').lstrip('/').lstrip('\\') ]
|
||||
todo.extend( tail.lstrip('/').lstrip('\\').split('\\') ) # c:\a => [a]
|
||||
else: # os.name == 'posix'
|
||||
todo = src.split('\\')
|
||||
|
||||
dst = '/'.join(todo)
|
||||
return dst
|
||||
|
||||
|
||||
def checkMkdir(work, debug=False):
|
||||
"""
|
||||
Verify arg permutations for directory mutex creation.
|
||||
|
||||
Keyword arguments:
|
||||
None
|
||||
|
||||
Returns:
|
||||
Exception on error
|
||||
|
||||
Note:
|
||||
Exception() rather than self.assertTrue() is used in this test
|
||||
function to enable scatch cleanup on test exit/failure conditions.
|
||||
Not guaranteed by python closures on early exit.
|
||||
"""
|
||||
|
||||
logging.debug("Testing: checkMkdir")
|
||||
|
||||
if False:
|
||||
path = os.path.abspath(__file__).split(os.sep)
|
||||
else:
|
||||
path = path2posix(os.path.abspath(__file__)).split('/')
|
||||
|
||||
root = os.path.join(os.sep, *path[:-5])
|
||||
src = os.path.join(os.sep, *path[:-1])
|
||||
|
||||
rootP = path2posix(root)
|
||||
srcP = path2posix(src)
|
||||
workP = path2posix(work)
|
||||
|
||||
# C:\foo -vs- /c/foo
|
||||
# [0] command paths use /c/foo
|
||||
# [1] os.path.exists() on mingw() requires C:\
|
||||
paths = [
|
||||
[ # function generated
|
||||
"%s/mkdir_bycall" % (workP),
|
||||
"%s/mkdir_bycall" % (work),
|
||||
],
|
||||
[ # explicit dependency
|
||||
"%s/mkdir_bydep" % (workP),
|
||||
"%s/mkdir_bydep" % (work),
|
||||
],
|
||||
[ # by GENERATED_DIRS macro
|
||||
"%s/mkdir_bygen" % (workP),
|
||||
"%s/mkdir_bygen" % (work),
|
||||
]
|
||||
]
|
||||
|
||||
## Use make from the parent "make check" call when available
|
||||
cmd = { 'make': 'make' }
|
||||
shell0 = os.environ.get('MAKECMD')
|
||||
if shell0:
|
||||
shell = os.path.splitext(shell0)[0] # strip: .exe, .py
|
||||
if -1 != shell.find('make'):
|
||||
print "MAKE COMMAND FOUND: %s" % (shell0)
|
||||
cmd['make'] = path2posix(shell0)
|
||||
|
||||
args = []
|
||||
args.append('%s' % (cmd['make']))
|
||||
args.append('-C %s' % (workP))
|
||||
args.append("-f %s/testor.tmpl" % (srcP))
|
||||
args.append('topsrcdir=%s' % (rootP))
|
||||
args.append('deps_mkdir_bycall=%s' % paths[0][0])
|
||||
args.append('deps_mkdir_bydep=%s' % paths[1][0])
|
||||
args.append('deps_mkdir_bygen=%s' % paths[2][0])
|
||||
args.append('checkup') # target
|
||||
|
||||
# Call will fail on mingw with output redirected ?!?
|
||||
if debug:
|
||||
pass
|
||||
if False: # if not debug:
|
||||
args.append('>/dev/null')
|
||||
|
||||
cmd = '%s' % (' '.join(args))
|
||||
logging.debug("Running: %s" % (cmd))
|
||||
rc = call(cmd, shell=True)
|
||||
if rc:
|
||||
raise Exception("make failed ($?=%s): cmd=%s" % (rc, cmd))
|
||||
|
||||
for i in paths:
|
||||
logging.debug("Did testing mkdir(%s) succeed?" % (i[1]))
|
||||
if not os.path.exists(i[1]):
|
||||
raise Exception("Test path %s does not exist" % (i[1]))
|
||||
|
||||
|
||||
def parseargs():
|
||||
"""
|
||||
Support additional command line arguments for testing
|
||||
|
||||
Returns:
|
||||
hash - arguments of interested parsed from the command line
|
||||
"""
|
||||
|
||||
opts = None
|
||||
try:
|
||||
import argparse2
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--debug',
|
||||
action="store_true",
|
||||
default=False,
|
||||
help='Enable debug mode')
|
||||
# Cannot overload verbose, Verbose: False enables debugging
|
||||
parser.add_argument('--verbose',
|
||||
action="store_true",
|
||||
default=False,
|
||||
help='Enable verbose mode')
|
||||
parser.add_argument('unittest_args',
|
||||
nargs='*'
|
||||
# help='Slurp/pass remaining args to unittest'
|
||||
)
|
||||
opts = parser.parse_args()
|
||||
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
return opts
|
||||
|
||||
|
||||
class TestMakeLogic(unittest.TestCase):
|
||||
"""
|
||||
Test suite used to validate makefile library rules and macros
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
opts = myopts(None) # NameSpace object not hash
|
||||
self.debug = opts['debug']
|
||||
self.verbose = opts['verbose']
|
||||
|
||||
if self.debug:
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
if self.verbose:
|
||||
print
|
||||
print "ENVIRONMENT DUMP:"
|
||||
print '=' * 75
|
||||
for k,v in os.environ.items():
|
||||
print "env{%s} => %s" % (k, v)
|
||||
print
|
||||
|
||||
|
||||
def test_path2posix(self):
|
||||
|
||||
todo = {
|
||||
'/dev/null' : '/dev/null',
|
||||
'A:\\a\\b\\c' : '/A/a/b/c',
|
||||
'B:/x/y' : '/B/x/y',
|
||||
'C:/x\\y/z' : '/C/x/y/z',
|
||||
'//FOO/bar/tans': '//FOO/bar/tans',
|
||||
'//X\\a/b\\c/d' : '//X/a/b/c/d',
|
||||
'\\c:mozilla\\sandbox': '/c/mozilla/sandbox',
|
||||
}
|
||||
|
||||
for val,exp in todo.items():
|
||||
found = path2posix(val)
|
||||
tst = "posix2path(%s): %s != %s)" % (val, exp, found)
|
||||
self.assertEqual(exp, found, "%s: invalid path detected" % (tst))
|
||||
|
||||
|
||||
def test_mkdir(self):
|
||||
"""
|
||||
Verify directory creation rules and macros
|
||||
"""
|
||||
|
||||
failed = True
|
||||
|
||||
# Exception handling is used to cleanup scratch space on error
|
||||
try:
|
||||
work = tempfile.mkdtemp()
|
||||
checkMkdir(work, self.debug)
|
||||
failed = False
|
||||
finally:
|
||||
if os.path.exists(work):
|
||||
rmtree(work)
|
||||
|
||||
self.assertFalse(failed, "Unit test failure detected")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
banner()
|
||||
opts = parseargs()
|
||||
myopts(opts)
|
||||
|
||||
if opts:
|
||||
if hasattr(opts, 'unittest_args'):
|
||||
sys.argv[1:] = opts.unittest_args
|
||||
else:
|
||||
sys.argv[1:] = []
|
||||
|
||||
unittest.main()
|
|
@ -0,0 +1,62 @@
|
|||
# -*- makefile -*-
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
|
||||
###########################################################################
|
||||
## Intent: Standalone unit tests for makefile rules and target logic
|
||||
###########################################################################
|
||||
|
||||
deps =$(NULL)
|
||||
tgts =$(NULL)
|
||||
|
||||
ifdef VERBOSE
|
||||
tgts += show
|
||||
endif
|
||||
|
||||
# Define macros
|
||||
include $(topsrcdir)/config/makefiles/autotargets.mk
|
||||
|
||||
##########################
|
||||
## Verify threadsafe mkdir
|
||||
##########################
|
||||
ifdef deps_mkdir_bycall
|
||||
deps += $(call mkdir_deps,deps_mkdir_bycall)
|
||||
tgts += check_mkdir
|
||||
endif
|
||||
ifdef deps_mkdir_bydep
|
||||
deps += $(foreach dir,$(deps_mkdir_bydep),$(dir)/.mkdir.done)
|
||||
tgts += check_mkdir
|
||||
endif
|
||||
ifdef deps_mkdir_bygen
|
||||
GENERATED_DIRS += $(deps_mkdir_bygen)
|
||||
tgts += check_mkdir
|
||||
endif
|
||||
|
||||
###########################
|
||||
## Minimal environment load
|
||||
###########################
|
||||
MKDIR ?= mkdir -p
|
||||
TOUCH ?= touch
|
||||
|
||||
INCLUDED_CONFIG_MK = 1
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
##-------------------##
|
||||
##---] TARGETS [---##
|
||||
##-------------------##
|
||||
all::
|
||||
|
||||
# Quarks:
|
||||
# o Use of 'all' would trigger export target processing
|
||||
checkup: $(tgts)
|
||||
|
||||
# AUTO_DEPS - verify GENERATED_DIRS
|
||||
check_mkdir: $(deps) $(AUTO_DEPS)
|
||||
|
||||
show:
|
||||
@echo "tgts=[$(tgts)]"
|
||||
@echo "deps=[$(deps)]"
|
||||
find $(dir $(deps)) -print
|
|
@ -0,0 +1,37 @@
|
|||
# -*- makefile -*-
|
||||
# vim:set ts=8 sw=8 sts=8 noet:
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
|
||||
###########################################################################
|
||||
# AUTO_DEPS - A list of deps/targets drived from other macros.
|
||||
# *_DEPS - Make dependencies derived from a given macro.
|
||||
###########################################################################
|
||||
|
||||
|
||||
###########################################################################
|
||||
# Threadsafe directory creation
|
||||
# GENERATED_DIRS - Automated creation of these directories.
|
||||
###########################################################################
|
||||
mkdir_deps =$(foreach dir,$($(1)),$(dir)/.mkdir.done)
|
||||
|
||||
ifneq (,$(GENERATED_DIRS))
|
||||
tmpauto :=$(call mkdir_deps,GENERATED_DIRS)
|
||||
GENERATED_DIRS_DEPS +=$(tmpauto)
|
||||
GARBAGE_DIRS +=$(tmpauto)
|
||||
endif
|
||||
|
||||
%/.mkdir.done:
|
||||
$(subst $(SPACE)-p,$(null),$(MKDIR)) -p $(dir $@)
|
||||
@$(TOUCH) $@
|
||||
|
||||
#################################################################
|
||||
# One ring/dep to rule them all:
|
||||
# config/rules.mk::all target is available by default
|
||||
# Add $(AUTO_DEPS) as an explicit target dependency when needed.
|
||||
#################################################################
|
||||
AUTO_DEPS +=$(GENERATED_DIRS_DEPS)
|
||||
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче