forked from w3c/csswg-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-css21.py
executable file
·97 lines (83 loc) · 2.95 KB
/
build-css21.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/python
# CSS 2.1 Test Suite Build Script
# Initial code by fantasai, joint copyright 2010 W3C and Microsoft
# Licensed under BSD 3-Clause: <http://www.w3.org/Consortium/Legal/2008/03-bsd-license>
import os.path
skipDirs = ('support')
reftestPath = 'reftest.list'
rawDirs = {'other-formats':'other'}
import sys
import shutil
from os.path import join, exists, basename
from w3ctestlib.Suite import TestSuite
from w3ctestlib.Indexer import Indexer
from w3ctestlib.Utils import listdirs, listfiles, basepath
def debugHook(type, value, tb):
if hasattr(sys, 'ps1') or not sys.stderr.isatty():
# we are in interactive mode or we don't have a tty-like
# device, so we call the default hook
sys.__excepthook__(type, value, tb)
else:
import traceback, pdb
# we are NOT in interactive mode, print the exception...
traceback.print_exception(type, value, tb)
print
# ...then start the debugger in post-mortem mode.
pdb.pm()
# run from css test suite repo root
sourcePath = '.'
suiteName = 'css2.1'
distPath = join('dist', suiteName)
buildPath = 'build'
print "Building CSS2.1 Test Suite from repository %s into %s" % \
(os.path.abspath(sourcePath), os.path.abspath(distPath))
unreviewed = sys.argv[1:]
print "Requested unreviewed source directories."
# Set up
suite = TestSuite(suiteName, 'CSS2.1 Test Suite', 'http://www.w3.org/TR/CSS21/')
# Add approved tests
root = join('approved', 'css2.1', 'src')
dirs = listdirs(root)
for dir in dirs:
if dir in skipDirs or rawDirs.has_key(dir): continue
testroot = join(root, dir)
suite.addTestsByExt(testroot, '.xht')
if exists(join(testroot, reftestPath)):
suite.addReftests(testroot, reftestPath)
suite.addTestsByExt(root, '.xht')
if exists(join(root, reftestPath)):
suite.addReftests(root, reftestPath)
for src, dst in rawDirs.items():
if exists(join(root,src)):
suite.addRaw(join(root,src), dst)
# Add unreviewed tests
for path in unreviewed:
if path.endswith('.list'):
print "Adding unreviewed reftests from %s" % path
suite.addReftests(basepath(path), basename(path))
else:
def grep(file):
if not file.endswith('.xht'):
return False
for line in open(join(path, file)):
if line.find(suite.specroot) != -1:
return True
return False
files = listfiles(path)
files = filter(grep, files)
print "Adding %d unreviewed selftests from %s" % (len(files), path)
suite.addTestsByList(path, files)
# Build
#sys.excepthook = debugHook
data = join('approved', 'css2.1', 'data')
indexer = Indexer(suite, join(data, 'sections.dat'), True, templatePathList=[data],
extraData={ 'devel' : False, 'official' : True })
print "Building"
shutil.rmtree(buildPath, True)
os.makedirs(buildPath)
suite.buildInto(buildPath, indexer)
print "Moving output to " + distPath
shutil.rmtree(distPath, True)
os.makedirs(distPath) # ensure parent directories exist
shutil.rmtree(distPath)
os.rename(buildPath, distPath)