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

Commit5f831da

Browse files
committed
Made some updates to the regression script. Still to do: better reporting and testing on Windows.
1 parent973e29e commit5f831da

File tree

1 file changed

+105
-57
lines changed

1 file changed

+105
-57
lines changed

‎libs/network/tools/regression.py

Lines changed: 105 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -9,110 +9,158 @@
99

1010

1111
importos
12+
importsys
1213
importurllib2
13-
fromurlparseimporturlparse
14+
importurlparse
1415
importoptparse
15-
importtarfile
1616
importstring
17+
importsubprocess
1718

1819

19-
repo_root='http://github.com/mikhailberis/cpp-netlib/'
20-
stage='/tmp'
21-
branch='0.6-devel'
22-
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"
2326

2427

2528
defcheck_boost_installation():
2629
""" Gets information about the user's boost environment. """
2730

28-
env=os.getenv('BOOST_ROOT')
31+
env=os.getenv("BOOST_ROOT")
2932
assert(envisnotNone)
3033

3134
# get boost version from version.hpp
3235
version=None
33-
version_hpp=os.path.join(env,'boost','version.hpp')
34-
f=open(version_hpp)
36+
version_hpp=os.path.join(env,"boost","version.hpp")
37+
f=open(version_hpp,"r")
3538
forlineinf:
36-
ifline.startswith('#define BOOST_LIB_VERSION'):
39+
ifline.startswith("#define BOOST_LIB_VERSION"):
3740
begin=string.find(line,'"')
3841
end=string.rfind(line,'"')
3942
version=line[begin+1:end]
43+
break
44+
45+
classParams:pass
46+
params=Params()
47+
params.root=env
48+
params.version=version
49+
returnparams
50+
51+
52+
defbuild(bjam,user_config=None):
53+
""" """
4054

41-
assert(versionisnotNone)
55+
ifbjamisNone:
56+
bjam="bjam"
4257

43-
return {'root':env,
44-
'version':version }
58+
results=open("results.txt","w+")
59+
rc=subprocess.call(bjam,stdout=results,stderr=results)
4560

4661

47-
defdownload_tarball():
62+
defdownload_tarball(stage):
4863
""" Downloads the latest tarball from the mikhailberis fork. """
49-
50-
printrepo_root+'tarball/'+branch
51-
r=urllib2.urlopen(repo_root+'tarball/'+branch)
52-
filename=urlparse(r.geturl()).path.split('/')[-1]
64+
65+
r=urllib2.urlopen(repo_root+"tarball/"+branch)
66+
filename=urlparse.urlparse(r.geturl()).path.split("/")[-1]
5367
path=os.path.join(stage,filename)
54-
f=open(path,'w+')
68+
f=open(path,"w+")
5569
f.write(r.read())
5670
returnfilename
5771

5872
defunpack_tarball(stage,filename):
5973
""" Unpacks the tarball into a stage directory. """
6074

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+
6183
os.chdir(stage)
6284
f=tarfile.open(os.path.join(stage,filename))
6385
f.extractall()
64-
(root,ext)=os.path.splitext(filename)
65-
print(root)
6686
os.chdir(root)
6787

6888

69-
defdownload_zipball():
89+
defdownload_zipball(stage):
7090
""" Downloads the latest zipfile from the mikhailberis fork. """
7191

72-
r=urllib2.urlopen(repo_root+'/zipball/'+branch)
73-
filename=urlparse(r.geturl()).path.split('/')[-1]
92+
r=urllib2.urlopen(repo_root+"zipball/"+branch)
93+
filename=urlparse.urlparse(r.geturl()).path.split("/")[-1]
7494
path=os.path.join(stage,filename)
75-
f=open(path,'w+')
95+
f=open(path,"w+")
7696
f.write(r.read())
7797
returnfilename
7898

7999
defunpack_zipball(stage,filename):
80100
""" Unpacks the zip file into a stage directory. """
81101

82-
f=zipfile.ZipFile(os.path.join(stage,filename))
83-
f.extractall()
84-
102+
importzipfile
103+
importshutil
85104

86-
defbuild():
87-
""" Invokes bjam. Runs all unit tests. """
88-
89-
# Somehow we have to report any failures
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))
90109

110+
os.chdir(stage)
111+
f=zipfile.ZipFile(os.path.join(stage,filename))
112+
f.extractall()
113+
os.chdir(root)
91114

92-
if__name__=='__main__':
93115

94-
params=check_boost_installation()
95-
print(params)
116+
if__name__=="__main__":
117+
118+
opt=optparse.OptionParser(
119+
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.")
130+
opt.add_option("--branch",
131+
help="the Git branch to check.")
132+
opt.add_option("--bjam",
133+
help="The path to the bjam binary if it's not in the system path.")
134+
opt.add_option("--user-config",
135+
metavar="FILE",
136+
help="the user-config file to use.")
96137

97-
# try:
98-
# opt = optparse.OptionParser(
99-
# usage="%prog [options]")
100-
#
101-
# opt.add_option('--zip',
102-
# help='uses the zip')
103-
# opt.add_option('--tar',
104-
# help='uses the tar.gz')
105-
# opt.add_option('--stage',
106-
# help='the stage directory')
107-
# opt.add_option('--branch',
108-
# help='the branch to check.')
109-
#
110-
# opt.parse_args()
111-
#
112-
#
113-
# filename = download_tarball()
114-
# print(filename)
115-
# unpack_tarball(stage, filename)
116-
#
117-
# except urllib2.URLError, e:
118-
# print('%s' % e)
138+
(opts,args)=opt.parse_args()
139+
140+
if (opts.zipisNoneandopts.tarisNone)or \
141+
(opts.zipisnotNoneandopts.tarisnotNone):
142+
print("Please specify either zip or tar")
143+
sys.exit(-1)
144+
145+
ifopts.stageisNone:
146+
opts.stage="/tmp"
147+
print("stage: %s"%opts.stage)
148+
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)
154+
155+
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+
165+
exceptException,e:
166+
print(e)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp