diff options
author | JF Bastien <jfb@chromium.org> | 2016-01-06 13:57:59 -0800 |
---|---|---|
committer | JF Bastien <jfb@chromium.org> | 2016-01-06 13:57:59 -0800 |
commit | 004bb9433e8e6143968530f9f0f60102aa5f7715 (patch) | |
tree | 8346c1cb8e9c205625da25a8b6348d8712965e8a /update.py | |
parent | 200a93c606b72b9694b69e2ec0bafe43153ddcf5 (diff) | |
download | binaryen-004bb9433e8e6143968530f9f0f60102aa5f7715.tar.gz binaryen-004bb9433e8e6143968530f9f0f60102aa5f7715.tar.bz2 binaryen-004bb9433e8e6143968530f9f0f60102aa5f7715.zip |
Commit the torture .s files
update.py used to just download them in a folder that .gitignore hid. They'll now be checked in instead, under test/, and lkgr will identify which version of LLVM built them.
Diffstat (limited to 'update.py')
-rwxr-xr-x | update.py | 52 |
1 files changed, 38 insertions, 14 deletions
@@ -14,7 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +import glob import os +import shutil import subprocess import sys import tempfile @@ -22,23 +24,44 @@ import urllib2 STORAGE_BASE = 'https://storage.googleapis.com/wasm-llvm/builds/git/' +BASE_DIR = 'test' +LKGR_PATH = os.path.join(BASE_DIR, 'lkgr') +TORTURE_TAR = 'wasm-torture-s-%s.tbz2' +TORTURE_FOLDER = os.path.join(BASE_DIR, 'torture-s') -def update_torture(): - if not os.path.isdir('buildbot'): - os.mkdir('buildbot') - lkgr_path = os.path.join('buildbot', 'lkgr') - with open(lkgr_path, 'w+') as f: +def download_last_known_good_revision(): + with open(LKGR_PATH, 'w+') as f: lkgr = urllib2.urlopen(STORAGE_BASE + 'lkgr').read().strip() f.write(lkgr) - torture = 'wasm-torture-s-%s.tbz2' % lkgr - torture_path = os.path.join('buildbot', torture) - if not os.path.isfile(torture_path): - with open(torture_path, 'w+') as f: - f.write(urllib2.urlopen(STORAGE_BASE + torture).read()) - with tempfile.TemporaryFile(mode='w') as untar: - subprocess.check_call(['tar', '-xvf', torture], cwd='buildbot', - stdout=untar) + return lkgr + + +def download_tar_at_lkgr(tar_pattern, lkgr): + tar_path = os.path.join(BASE_DIR, tar_pattern) + lkgr_tar_path = tar_path % lkgr + if not os.path.isfile(lkgr_tar_path): + with open(lkgr_tar_path, 'w+') as f: + f.write(urllib2.urlopen(STORAGE_BASE + tar_pattern % lkgr).read()) + # Remove any previous tarfiles. + for older_tar in glob.glob(tar_path): + if older_tar != lkgr_tar_path: + os.path.remove(older_tar) + return lkgr_tar_path + + +def untar(tarfile, outfolder): + if os.path.exists(outfolder): + shutil.rmtree(outfolder) + with tempfile.TemporaryFile(mode='w+') as f: + try: + base = os.path.basename(tarfile) + subprocess.check_call(['tar', '-xvf', base], cwd=BASE_DIR, stdout=f) + except: + f.seek(0) + sys.stderr.write(f.read()) + raise + assert os.path.isdir(outfolder), 'Expected to untar into %s' % outfolder def main(): @@ -47,7 +70,8 @@ def main(): subprocess.check_call(['git', 'submodule', 'update', '--quiet']) subprocess.check_call(['git', 'submodule', 'foreach', 'git', 'pull', 'origin', 'master', '--quiet']) - update_torture() + lkgr = download_last_known_good_revision() + untar(download_tar_at_lkgr(TORTURE_TAR, lkgr), TORTURE_FOLDER) if __name__ == '__main__': |