avoid update --self (since it overwrites config.py and update.py)
This commit is contained in:
parent
bf2015bd5b
commit
115f3475a6
48
test/test.py
48
test/test.py
@ -1,12 +1,48 @@
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import shutil
|
import shutil
|
||||||
|
import sys
|
||||||
|
|
||||||
HERE = os.path.abspath(os.path.dirname(__file__))
|
HERE = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
# we do not use the nicer sys.version_info.major
|
||||||
|
# for compatibility with Python < 2.7
|
||||||
|
if sys.version_info[0] > 2:
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
|
class URLopener(urllib.request.FancyURLopener):
|
||||||
|
def http_error_default(self, url, fp, errcode, errmsg, headers):
|
||||||
|
sys.stderr.write("ERROR: could not fetch %s\n" % url)
|
||||||
|
sys.exit(-1)
|
||||||
|
else:
|
||||||
|
import urllib
|
||||||
|
|
||||||
|
class URLopener(urllib.FancyURLopener):
|
||||||
|
def http_error_default(self, url, fp, errcode, errmsg, headers):
|
||||||
|
sys.stderr.write("ERROR: could not fetch %s\n" % url)
|
||||||
|
sys.exit(-1)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def fetch_url(src, dst):
|
||||||
|
"""
|
||||||
|
Fetch file from URL src and save it to dst.
|
||||||
|
"""
|
||||||
|
dirname = os.path.dirname(dst)
|
||||||
|
if dirname != '':
|
||||||
|
if not os.path.isdir(dirname):
|
||||||
|
os.makedirs(dirname)
|
||||||
|
|
||||||
|
opener = URLopener()
|
||||||
|
opener.retrieve(src, dst)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def exe(command):
|
def exe(command):
|
||||||
stdout, stderr = subprocess.Popen(command.split(),
|
stdout, stderr = subprocess.Popen(command.split(),
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
@ -19,7 +55,11 @@ def exe(command):
|
|||||||
def test_cxx():
|
def test_cxx():
|
||||||
os.chdir(os.path.join(HERE, 'cxx', 'cmake'))
|
os.chdir(os.path.join(HERE, 'cxx', 'cmake'))
|
||||||
shutil.copy(os.path.join('..', '..', '..', 'update.py'), 'update.py')
|
shutil.copy(os.path.join('..', '..', '..', 'update.py'), 'update.py')
|
||||||
stdout, stderr = exe('python update.py --self')
|
if not os.path.exists('lib'):
|
||||||
|
os.makedirs('lib')
|
||||||
|
shutil.copy(os.path.join('..', '..', '..', 'lib', 'config.py'), 'lib')
|
||||||
|
fetch_url(src='https://github.com/docopt/docopt/raw/master/docopt.py',
|
||||||
|
dst='lib/docopt.py')
|
||||||
stdout, stderr = exe('python update.py ..')
|
stdout, stderr = exe('python update.py ..')
|
||||||
os.chdir(os.path.join(HERE, 'cxx'))
|
os.chdir(os.path.join(HERE, 'cxx'))
|
||||||
stdout, stderr = exe('python setup.py --cxx=g++')
|
stdout, stderr = exe('python setup.py --cxx=g++')
|
||||||
@ -34,7 +74,11 @@ def test_cxx():
|
|||||||
def test_fc():
|
def test_fc():
|
||||||
os.chdir(os.path.join(HERE, 'fc', 'cmake'))
|
os.chdir(os.path.join(HERE, 'fc', 'cmake'))
|
||||||
shutil.copy(os.path.join('..', '..', '..', 'update.py'), 'update.py')
|
shutil.copy(os.path.join('..', '..', '..', 'update.py'), 'update.py')
|
||||||
stdout, stderr = exe('python update.py --self')
|
if not os.path.exists('lib'):
|
||||||
|
os.makedirs('lib')
|
||||||
|
shutil.copy(os.path.join('..', '..', '..', 'lib', 'config.py'), 'lib')
|
||||||
|
fetch_url(src='https://github.com/docopt/docopt/raw/master/docopt.py',
|
||||||
|
dst='lib/docopt.py')
|
||||||
stdout, stderr = exe('python update.py ..')
|
stdout, stderr = exe('python update.py ..')
|
||||||
os.chdir(os.path.join(HERE, 'fc'))
|
os.chdir(os.path.join(HERE, 'fc'))
|
||||||
stdout, stderr = exe('python setup.py --fc=gfortran')
|
stdout, stderr = exe('python setup.py --fc=gfortran')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user