Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit06b9daf

Browse files
committed
Updated regression script.
1 parent5f831da commit06b9daf

File tree

1 file changed

+165
-107
lines changed

1 file changed

+165
-107
lines changed

‎libs/network/tools/regression.py

Lines changed: 165 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
# http://www.boost.org/LICENSE_1_0.txt)
55
#
66
# This script downloads either a tarball or zipfile of the latest version of the
7-
# main repo.
7+
# main repo, unpacks it, runs bjam (including all unit tests) and creates a file
8+
# that contains all the information needed to evaluate any regression failures.
9+
#
10+
# 1. Create a directory where you want to run the test
11+
# 2. Download this script
12+
# 3. Run this script: python regression.py [options]
13+
# 4. E-mail the `cpp_netlib_regression.txt` file to the developers
814
#
915

1016

@@ -17,150 +23,202 @@
1723
importsubprocess
1824

1925

20-
#
21-
# Some constants
22-
#
23-
repo_root="http://github.com/mikhailberis/cpp-netlib/"
24-
branch="0.6-devel"
25-
boost_minimum_version="1_40"
2626

27+
classRegressionTester:
28+
""" """
29+
30+
def__init__(self):
31+
""" """
2732

28-
defcheck_boost_installation():
29-
""" Gets information about the user's boost environment. """
33+
self._repo_root="http://github.com/mikhailberis/cpp-netlib/"
34+
self._boost_minimum_version="1_40"
3035

31-
env=os.getenv("BOOST_ROOT")
32-
assert(envisnotNone)
36+
defcheck_boost_installation(self):
37+
""" Gets information about the user's boost environment. """
3338

34-
# get boost version from version.hpp
35-
version=None
36-
version_hpp=os.path.join(env,"boost","version.hpp")
37-
f=open(version_hpp,"r")
38-
forlineinf:
39-
ifline.startswith("#define BOOST_LIB_VERSION"):
40-
begin=string.find(line,'"')
41-
end=string.rfind(line,'"')
42-
version=line[begin+1:end]
43-
break
39+
env=os.getenv("BOOST_ROOT")
40+
assert(envisnotNone)
4441

45-
classParams:pass
46-
params=Params()
47-
params.root=env
48-
params.version=version
49-
returnparams
42+
# get boost version from version.hpp
43+
version=None
44+
version_hpp=os.path.join(env,"boost","version.hpp")
45+
f=open(version_hpp,"r")
46+
forlineinf:
47+
ifline.startswith("#define BOOST_LIB_VERSION"):
48+
begin=string.find(line,'"')
49+
end=string.rfind(line,'"')
50+
version=line[begin+1:end]
51+
break
5052

53+
classParams:pass
54+
params=Params()
55+
params.root=env
56+
params.version=version
57+
returnparams
5158

52-
defbuild(bjam,user_config=None):
53-
""" """
59+
defdownload(self,branch):
60+
""" """
5461

55-
ifbjamisNone:
56-
bjam="bjam"
62+
raiseNotImplementedError
5763

58-
results=open("results.txt","w+")
59-
rc=subprocess.call(bjam,stdout=results,stderr=results)
64+
defget_commit(self,filename):
65+
""" """
66+
67+
(root,ext)=os.path.splitext(filename)
68+
(root,ext)=os.path.splitext(root)
69+
returnroot.split("-")[-1]
6070

71+
defunpack(self,filename):
72+
""" """
73+
74+
raiseNotImplementedError
6175

62-
defdownload_tarball(stage):
63-
""" Downloads the latest tarball from the mikhailberis fork. """
76+
defbuild(self,results,bjam):
77+
""" """
78+
79+
rc=subprocess.call(bjam,stdout=results,stderr=results)
80+
81+
defrun(self,runner,branch,bjam=None,user_config=None):
82+
""" """
83+
84+
boost_params=self.check_boost_installation()
85+
assert(boost_params.versionisnotNone)
86+
assert(boost_params.version>self._boost_minimum_version)
87+
88+
results="cpp_netlib_regression.txt"
89+
results_file=open(results,"w+")
90+
91+
filename=self.download(branch)
92+
commit=self.get_commit(filename)
93+
94+
self.unpack(filename)
95+
96+
ifbjamisNone:
97+
bjam="bjam"
6498

65-
r=urllib2.urlopen(repo_root+"tarball/"+branch)
66-
filename=urlparse.urlparse(r.geturl()).path.split("/")[-1]
67-
path=os.path.join(stage,filename)
68-
f=open(path,"w+")
69-
f.write(r.read())
70-
returnfilename
71-
72-
defunpack_tarball(stage,filename):
73-
""" Unpacks the tarball into a stage directory. """
74-
75-
importtarfile
76-
importshutil
77-
78-
(root,ext)=os.path.splitext(filename)
79-
(root,ext)=os.path.splitext(root)
80-
ifos.path.exists(os.path.join(stage,root)):
81-
shutil.rmtree(os.path.join(stage,root))
82-
83-
os.chdir(stage)
84-
f=tarfile.open(os.path.join(stage,filename))
85-
f.extractall()
86-
os.chdir(root)
99+
ifuser_configisnotNone:
100+
bjam="%s --user-config=%s"% (bjam,user_config)
101+
102+
self.build(results_file,bjam)
103+
104+
results_file.write("\n\n")
105+
results_file.write("runner: %s\n"%runner)
106+
results_file.write("git_branch: %s\n"%branch)
107+
results_file.write("boost_root: %s\n"%boost_params.root)
108+
results_file.write("boost_version: %s\n"%boost_params.version)
109+
results_file.write("commit: %s\n"%commit)
110+
111+
returnresults
112+
113+
114+
classRegressionTesterWithTar(RegressionTester):
115+
""" """
116+
117+
def__init__(self):
118+
RegressionTester.__init__(self)
119+
120+
defdownload(self,branch):
121+
""" Downloads the latest tarball from the mikhailberis fork. """
87122

123+
r=urllib2.urlopen(self._repo_root+"tarball/"+branch)
124+
filename=urlparse.urlparse(r.geturl()).path.split("/")[-1]
125+
f=open(filename,"w+")
126+
f.write(r.read())
127+
returnfilename
128+
129+
defunpack(self,filename):
130+
""" Unpacks the tarball into a stage directory. """
131+
132+
importtarfile
133+
importshutil
134+
135+
(root,ext)=os.path.splitext(filename)
136+
(root,ext)=os.path.splitext(root)
137+
ifos.path.exists(root):
138+
shutil.rmtree(root)
139+
140+
f=tarfile.open(filename)
141+
f.extractall()
142+
os.chdir(root)
143+
88144

89-
defdownload_zipball(stage):
90-
""" Downloads the latest zipfile from the mikhailberis fork. """
145+
classRegressionTesterWithZip(RegressionTester):
146+
""" """
147+
148+
def__init__(self):
149+
RegressionTester.__init__(self)
150+
151+
defdownload(self,branch):
152+
""" Downloads the latest zipfile from the mikhailberis fork. """
91153

92-
r=urllib2.urlopen(repo_root+"zipball/"+branch)
93-
filename=urlparse.urlparse(r.geturl()).path.split("/")[-1]
94-
path=os.path.join(stage,filename)
95-
f=open(path,"w+")
96-
f.write(r.read())
97-
returnfilename
154+
r=urllib2.urlopen(self._repo_root+"zipball/"+branch)
155+
filename=urlparse.urlparse(r.geturl()).path.split("/")[-1]
156+
f=open(filename,"w+")
157+
f.write(r.read())
158+
returnfilename
98159

99-
defunpack_zipball(stage,filename):
100-
""" Unpacks the zip file into a stage directory. """
160+
defunpack(self,filename):
161+
""" Unpacks the zip file into a stage directory. """
101162

102-
importzipfile
103-
importshutil
163+
importzipfile
164+
importshutil
104165

105-
(root,ext)=os.path.splitext(filename)
106-
(root,ext)=os.path.splitext(root)
107-
ifos.path.exists(os.path.join(stage,root)):
108-
shutil.rmtree(os.path.join(stage,root))
166+
(root,ext)=os.path.splitext(filename)
167+
(root,ext)=os.path.splitext(root)
168+
ifos.path.exists(root):
169+
shutil.rmtree(root)
109170

110-
os.chdir(stage)
111-
f=zipfile.ZipFile(os.path.join(stage,filename))
112-
f.extractall()
113-
os.chdir(root)
171+
f=zipfile.ZipFile(filename)
172+
f.extractall()
173+
os.chdir(root)
114174

115175

116176
if__name__=="__main__":
117177

118178
opt=optparse.OptionParser(
119179
usage="%prog [options]")
120-
121-
opt.add_option("--zip",
122-
action="store_false",
123-
help="Downloads the zip file.")
124-
opt.add_option("--tar",
125-
action="store_false",
126-
help="Downloads the tar.gz file.")
127-
opt.add_option("--stage",
128-
metavar="DIR",
129-
help="the stage directory.")
180+
181+
opt.add_option("--runner",
182+
metavar="RUNNER",
183+
help="A real name to identify the test runner.")
184+
opt.add_option("--package",
185+
metavar="ZIP/TAR",
186+
help="Specify 'zip' to download the zip file, or 'tar' to "
187+
"download the tarball.")
130188
opt.add_option("--branch",
131189
help="the Git branch to check.")
132190
opt.add_option("--bjam",
133-
help="The path to the bjam binary if it's not in the system path.")
191+
help="The path to the bjam binary if it's not in the system "
192+
"path.")
134193
opt.add_option("--user-config",
135194
metavar="FILE",
136195
help="the user-config file to use.")
137196

138197
(opts,args)=opt.parse_args()
139198

140-
if (opts.zipisNoneandopts.tarisNone)or \
141-
(opts.zipisnotNoneandopts.tarisnotNone):
142-
print("Please specify either zip or tar")
199+
ifopt.runnerisNone:
200+
opt.print_help()
143201
sys.exit(-1)
144202

145-
ifopts.stageisNone:
146-
opts.stage="/tmp"
147-
print("stage: %s"%opts.stage)
203+
ifopts.branchisNone:
204+
opt.print_help()
205+
sys.exit(-1)
148206

149-
boost_params=check_boost_installation()
150-
assert(boost_params.versionisnotNone)
151-
assert(boost_params.version>boost_minimum_version)
152-
print("boost_root: %s"%boost_params.root)
153-
print("boost_version: %s"%boost_params.version)
207+
ifopts.packagenotin ["zip","tar"]:
208+
opt.print_help()
209+
sys.exit(-1)
210+
211+
ifopts.package=="zip":
212+
tester=RegressionTesterWithZip()
213+
elifopts.package=="tar":
214+
tester=RegressionTesterWithTar()
154215

155216
try:
156-
ifopts.zipisnotNone:
157-
filename=download_zipball(opts.stage)
158-
unpack_zipball(opts.stage,filename)
159-
elifopts.tarisnotNone:
160-
filename=download_tarball(opts.stage)
161-
unpack_tarball(opts.stage,filename)
162-
163-
build(opts.bjam,opts.user_config)
164-
217+
results=tester.run(opts.runner,
218+
opts.branch,
219+
bjam=opts.bjam,
220+
user_config=opts.user_config)
221+
print("The regression results are found in `%s`."%results)
222+
print("Please e-mail this to the project administrators at `cpp.netlib@gmail.com`")
165223
exceptException,e:
166224
print(e)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp