提交 6aaa6a50 编写于 作者: V Vadim Pisarevsky

Merge pull request #3887 from MSOpenTech:update_py_script

......@@ -850,12 +850,51 @@ def getRunArgs(args):
path = npath
return run_args
if hostos == "nt":
def moveTests(instance, destination):
src = os.path.dirname(instance.tests_dir)
# new binaries path
newBinPath = os.path.join(destination, "bin")
try:
# copy binaries and CMakeCache.txt to the specified destination
shutil.copytree(src, newBinPath)
shutil.copy(os.path.join(instance.path, "CMakeCache.txt"), os.path.join(destination, "CMakeCache.txt"))
except Exception, e:
print "Copying error occurred:", str(e)
exit(e.errno)
# pattern of CMakeCache.txt string to be replaced
replacePattern = re.compile("EXECUTABLE_OUTPUT_PATH:PATH=(.+)")
with open(os.path.join(destination, "CMakeCache.txt"), "r") as cachefile:
try:
cachedata = cachefile.read()
if hostos == 'nt':
# fix path slashes on nt systems
newBinPath = re.sub(r"\\", r"/", newBinPath)
# replace old binaries path in CMakeCache.txt
cachedata = re.sub(re.search(replacePattern, cachedata).group(1), newBinPath, cachedata)
except Exception, e:
print "Reading error occurred:", str(e)
exit(e.errno)
with open(os.path.join(destination, "CMakeCache.txt"), "w") as cachefile:
try:
cachefile.write(cachedata)
except Exception, e:
print "Writing error occurred:", str(e)
exit(e.errno)
exit()
if __name__ == "__main__":
test_args = [a for a in sys.argv if a.startswith("--perf_") or a.startswith("--gtest_")]
argv = [a for a in sys.argv if not(a.startswith("--perf_") or a.startswith("--gtest_"))]
parser = OptionParser()
parser = OptionParser(usage="run.py [options] [build_path]", description="Note: build_path is required if running not from CMake build directory")
parser.add_option("-t", "--tests", dest="tests", help="comma-separated list of modules to test", metavar="SUITS", default="")
if hostos == "nt":
parser.add_option("-m", "--move_tests", dest="move", help="location to move current tests build", metavar="PATH", default="")
parser.add_option("-w", "--cwd", dest="cwd", help="working directory for tests", metavar="PATH", default=".")
parser.add_option("-a", "--accuracy", dest="accuracy", help="look for accuracy tests instead of performance tests", action="store_true", default=False)
parser.add_option("-l", "--longname", dest="useLongNames", action="store_true", help="generate log files with long names", default=False)
......@@ -880,6 +919,7 @@ if __name__ == "__main__":
if len(run_args) == 0:
print >> sys.stderr, "Usage:", os.path.basename(sys.argv[0]), "[options] [build_path]"
print >> sys.stderr, "Please specify build_path or run script from CMake build directory"
exit(1)
options.android_env = {}
......@@ -906,6 +946,10 @@ if __name__ == "__main__":
test_list = []
for path in run_args:
suite = TestSuite(options, path)
if hostos == "nt":
if(options.move):
moveTests(suite, options.move)
#print vars(suite),"\n"
if options.list:
test_list.extend(suite.tests)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册