Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

bug 729344 - remove extract() until it works properly. r=jhammel

  • Loading branch information...
commit cb0e9297f37f4adf7d1687044be1132b2c579e24 1 parent 346f627
@escapewindow escapewindow authored
Showing with 0 additions and 171 deletions.
  1. +0 −105 examples/test_browser.py
  2. +0 −66 mozharness/base/script.py
View
105 examples/test_browser.py
@@ -1,105 +0,0 @@
-#!/usr/bin/env python
-"""test_browser.py
-
-clobber, download/extract, and then run a dummy runtests.py command (via echo)
-
-TODO: we need to add dmg support to OSMixin.extract() to be able to handle real life unit tests.
-"""
-
-import os
-import sys
-
-sys.path.insert(1, os.path.dirname(sys.path[0]))
-
-from mozharness.base.errors import PythonErrorList
-from mozharness.base.log import DEBUG, INFO, WARNING, ERROR, CRITICAL, FATAL, IGNORE
-from mozharness.base.script import BaseScript
-
-# TestBrowserExample {{{1
-class TestBrowserExample(BaseScript):
- config_options = [[
- ["--browser-url"],
- {"action": "store",
- "dest": "browser_url",
- "default": "http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/8.0b6-candidates/build1/linux-i686/en-US/firefox-8.0b6.tar.bz2",
- "help": "Specify the browser url"
- }
- ],[
- ["--test-url"],
- {"action": "store",
- "dest": "test_url",
- "default": "http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/8.0b6-candidates/build1/linux-i686/en-US/firefox-8.0b6.tests.zip",
- "help": "Specify the test zip url"
- }
- ]]
-
- def __init__(self, require_config_file=False):
- super(TestBrowserExample, self).__init__(
- config_options=self.config_options,
- all_actions=['clobber',
- 'download-and-extract',
- 'run-tests',
- ],
- # Since the default_actions are the same as all_actions, they
- # don't need to be defined. Defining anyway for clarity/ease of
- # editing.
- default_actions=['clobber',
- 'download-and-extract',
- 'run-tests',
- ],
- require_config_file=require_config_file,
- )
-
- def clobber(self):
- dirs = self.query_abs_dirs()
- self.rmtree(dirs['abs_work_dir'])
-
- def download_and_extract(self):
- c = self.config
- dirs = self.query_abs_dirs()
- self.mkdir_p(dirs['abs_work_dir'])
- file_name = os.path.join(dirs['abs_work_dir'],
- self.get_filename_from_url(c['browser_url']))
- # download browser_url or die
- self.download_file(c['browser_url'], file_name=file_name,
- error_level=FATAL)
- self.extract(file_name)
-
- file_name = os.path.join(dirs['abs_work_dir'],
- self.get_filename_from_url(c['test_url']))
- # download test_url or die
- self.download_file(c['test_url'], file_name=file_name,
- error_level=FATAL)
- self.extract(file_name)
-
- def preflight_run_tests(self):
- """ If this, or any other preflight_ACTION method, is defined,
- it will run before the action. postflight_ACTION methods will run
- after the action.
-
- You could doublecheck that all the tests and browser are there
- and you have enough diskspace or w/e other checks you want to put
- in.
- """
- pass
-
- def run_tests(self):
- dirs = self.query_abs_dirs()
- args = ["--generate", "--args", "--from", "--config"]
- test_error_list = [
- {'substr': r'''TEST-UNEXPECTED-FAIL''', 'level': ERROR,},
- {'substr': r'''TEST-UNEXPECTED-PASS''', 'level': ERROR,},
- {'substr': r'''TEST-EXPECTED-FAIL''', 'level': INFO,},
- {'substr': r'''TEST-UNEXPECTED-WARNING''', 'level': WARNING,},
- ] + PythonErrorList
-
- cmd = ["echo", "runtests.py"] + args
- status = self.run_command(cmd, error_list=test_error_list,
- cwd=os.path.join(dirs['abs_work_dir'],
- 'mochitest'))
- self.add_summary("%s exited with status %s." % (cmd, str(status)))
-
-# __main__ {{{1
-if __name__ == '__main__':
- test_browser_example = TestBrowserExample()
- test_browser_example.run()
View
66 mozharness/base/script.py
@@ -185,72 +185,6 @@ def download_file(self, url, file_name=None, parent_dir=None,
return
return file_name
- def extract(self, path, extdir=None, delete=False,
- error_level=ERROR, exit_code=-1):
- """
- Takes in a tar or zip file and extracts it to extdir
- - If extdir is not specified, extracts to os.path.dirname(path)
- - If delete is set to True, deletes the bundle at path
- - Returns the list of top level files that were extracted
-
- TODO: dmg
- """
- # determine directory to extract to
- if extdir is None:
- extdir = os.path.dirname(path)
- elif not os.path.isdir(extdir):
- if os.path.isfile(extdir):
- self.log("%s is a file!" % extdir, level=error_level,
- exit_code=exit_code)
- self.mkdir_p(extdir)
- self.info("Extracting %s to %s" % (os.path.abspath(path),
- os.path.abspath(extdir)))
- try:
- if zipfile.is_zipfile(path):
- bundle = zipfile.ZipFile(path)
- namelist = bundle.namelist()
- if hasattr(bundle, 'extractall'):
- bundle.extractall(path=extdir)
- # zipfile.extractall doesn't exist in Python 2.5
- else:
- for name in namelist:
- filename = os.path.realpath(os.path.join(extdir, name))
- if name.endswith("/"):
- os.makedirs(filename)
- else:
- path = os.path.dirname(filename)
- if not os.path.isdir(path):
- os.makedirs(path)
- dest = open(filename, "wb")
- dest.write(bundle.read(name))
- elif tarfile.is_tarfile(path):
- bundle = tarfile.open(path)
- namelist = bundle.getnames()
- bundle.extractall(path=extdir)
- else:
- # unknown filetype
- self.warning("Unsupported file type: %s" % path)
- bundle.close()
- except (zipfile.BadZipfile, zipfile.LargeZipFile,
- tarfile.ReadError, tarfile.CompressionError):
- cla = sys.exc_info()[0]
- self.log("%s, Error extracting: %s" % (cla.__name__,
- os.path.abspath(path)),
- level=error_level, exit_code=exit_code)
- return
- if delete:
- self.rmtree(path)
-
- # namelist returns paths with forward slashes even in windows
- top_level_files = [os.path.join(extdir, name) for name in namelist
- if len(name.rstrip('/').split('/')) == 1]
- # namelist doesn't include folders, append these to the list
- for name in namelist:
- root = os.path.join(extdir, name[:name.find('/')])
- if root not in top_level_files:
- top_level_files.append(root)
- return top_level_files
-
def move(self, src, dest, log_level=INFO, error_level=ERROR,
exit_code=-1):
self.log("Moving %s to %s" % (src, dest), level=log_level)
Please sign in to comment.
Something went wrong with that request. Please try again.