mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 1403131: [mozharness] Run lint against tests; r=mtabara
Differential Revision: https://phabricator.services.mozilla.com/D10250 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
d94635b7d1
commit
2819b8db83
@ -48,14 +48,18 @@ class TestParseConfigFile(unittest.TestCase):
|
||||
self.assertEqual(config_dict[key], c._config[key])
|
||||
|
||||
def test_illegal_config(self):
|
||||
self.assertRaises(IOError, config.parse_config_file, "this_file_does_not_exist.py", search_path="yadda")
|
||||
self.assertRaises(
|
||||
IOError,
|
||||
config.parse_config_file, "this_file_does_not_exist.py", search_path="yadda")
|
||||
|
||||
def test_illegal_suffix(self):
|
||||
self.assertRaises(RuntimeError, config.parse_config_file, "test/test.illegal_suffix")
|
||||
|
||||
def test_malformed_json(self):
|
||||
if JSON_TYPE == 'simplejson':
|
||||
self.assertRaises(json.decoder.JSONDecodeError, config.parse_config_file, "test/test_malformed.json")
|
||||
self.assertRaises(
|
||||
json.decoder.JSONDecodeError,
|
||||
config.parse_config_file, "test/test_malformed.json")
|
||||
else:
|
||||
self.assertRaises(ValueError, config.parse_config_file, "test/test_malformed.json")
|
||||
|
||||
@ -105,7 +109,7 @@ class TestReadOnlyDict(unittest.TestCase):
|
||||
control_dict = {
|
||||
'b': '2',
|
||||
'c': {'d': '4'},
|
||||
'e': ['f', 'g'],
|
||||
'h': ['f', 'g'],
|
||||
'e': ['f', 'g', {'turtles': ['turtle1']}],
|
||||
'd': {
|
||||
'turtles': ['turtle1']
|
||||
@ -169,7 +173,7 @@ class TestReadOnlyDict(unittest.TestCase):
|
||||
# all on 2.7.
|
||||
try:
|
||||
r['e'] = 2
|
||||
except:
|
||||
except AssertionError:
|
||||
pass
|
||||
else:
|
||||
self.assertEqual(0, 1, msg="can set r['e'] when locked")
|
||||
@ -178,7 +182,7 @@ class TestReadOnlyDict(unittest.TestCase):
|
||||
r = self.get_locked_ROD()
|
||||
try:
|
||||
del r['e']
|
||||
except:
|
||||
except AssertionError:
|
||||
pass
|
||||
else:
|
||||
self.assertEqual(0, 1, "can del r['e'] when locked")
|
||||
@ -256,7 +260,7 @@ class TestActions(unittest.TestCase):
|
||||
c = config.BaseConfig(initial_config_file='test/test.json')
|
||||
try:
|
||||
c.verify_actions(['not_a_real_action'])
|
||||
except:
|
||||
except SystemExit:
|
||||
pass
|
||||
else:
|
||||
self.assertEqual(0, 1, msg="verify_actions() didn't die on invalid action")
|
||||
@ -304,5 +308,6 @@ class TestActions(unittest.TestCase):
|
||||
self.assertEqual(['a', 'e'], c.get_actions(),
|
||||
msg="--ACTION broken")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@ -1,6 +1,5 @@
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import unittest
|
||||
|
||||
import mozharness.base.log as log
|
||||
@ -38,5 +37,6 @@ class TestLog(unittest.TestCase):
|
||||
self.assertTrue(os.path.exists(get_log_file_path()))
|
||||
del(l)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@ -11,7 +11,7 @@ if os.name == 'nt':
|
||||
try:
|
||||
import win32file
|
||||
PYWIN32 = True
|
||||
except:
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
|
@ -4,7 +4,6 @@ import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
import mozharness.base.errors as errors
|
||||
import mozharness.base.vcs.mercurial as mercurial
|
||||
|
||||
test_string = '''foo
|
||||
@ -14,7 +13,8 @@ baz'''
|
||||
HG = ['hg'] + mercurial.HG_OPTIONS
|
||||
|
||||
# Known default .hgrc
|
||||
os.environ['HGRCPATH'] = os.path.abspath(os.path.join(os.path.dirname(__file__), 'helper_files', '.hgrc'))
|
||||
os.environ['HGRCPATH'] = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
||||
'helper_files', '.hgrc'))
|
||||
|
||||
|
||||
def cleanup():
|
||||
@ -39,7 +39,8 @@ def get_mercurial_vcs_obj():
|
||||
def get_revisions(dest):
|
||||
m = get_mercurial_vcs_obj()
|
||||
retval = []
|
||||
for rev in m.get_output_from_command(HG + ['log', '-R', dest, '--template', '{node}\n']).split('\n'):
|
||||
command = HG + ['log', '-R', dest, '--template', '{node}\n']
|
||||
for rev in m.get_output_from_command(command).split('\n'):
|
||||
rev = rev.strip()
|
||||
if not rev:
|
||||
continue
|
||||
@ -70,7 +71,9 @@ class TestMakeAbsolute(unittest.TestCase):
|
||||
|
||||
def test_relative_file_path(self):
|
||||
m = get_mercurial_vcs_obj()
|
||||
self.assertEquals(m._make_absolute("file://foo/bar"), "file://%s/foo/bar" % os.getcwd())
|
||||
self.assertEquals(
|
||||
m._make_absolute("file://foo/bar"),
|
||||
"file://%s/foo/bar" % os.getcwd())
|
||||
|
||||
|
||||
class TestHg(unittest.TestCase):
|
||||
@ -330,7 +333,7 @@ class TestHg(unittest.TestCase):
|
||||
self.failUnless(os.path.exists(os.path.join(self.wc, 'test.txt')))
|
||||
|
||||
def test_make_hg_url(self):
|
||||
#construct an hg url specific to revision, branch and filename and try to pull it down
|
||||
# construct an hg url specific to revision, branch and filename and try to pull it down
|
||||
file_url = mercurial.make_hg_url(
|
||||
"hg.mozilla.org",
|
||||
'//build/tools/',
|
||||
@ -338,7 +341,10 @@ class TestHg(unittest.TestCase):
|
||||
filename="/lib/python/util/hg.py",
|
||||
protocol='https',
|
||||
)
|
||||
expected_url = "https://hg.mozilla.org/build/tools/raw-file/FIREFOX_3_6_12_RELEASE/lib/python/util/hg.py"
|
||||
expected_url = (
|
||||
"https://hg.mozilla.org/build/tools/raw-file/"
|
||||
"FIREFOX_3_6_12_RELEASE/lib/python/util/hg.py"
|
||||
)
|
||||
self.assertEquals(file_url, expected_url)
|
||||
|
||||
def test_make_hg_url_no_filename(self):
|
||||
@ -369,5 +375,6 @@ class TestHg(unittest.TestCase):
|
||||
expected_url = "ssh://hg.mozilla.org/build/tools"
|
||||
self.assertEquals(repo_url, expected_url)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@ -1,10 +1,7 @@
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import mozharness.base.log as log
|
||||
import mozharness.base.script as script
|
||||
import mozharness.mozilla.l10n.locales as locales
|
||||
|
||||
@ -12,10 +9,12 @@ ALL_LOCALES = ['ar', 'be', 'de', 'es-ES']
|
||||
|
||||
MH_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
||||
def cleanup():
|
||||
if os.path.exists('test_logs'):
|
||||
shutil.rmtree('test_logs')
|
||||
|
||||
|
||||
class LocalesTest(locales.LocalesMixin, script.BaseScript):
|
||||
def __init__(self, **kwargs):
|
||||
if 'config' not in kwargs:
|
||||
@ -27,8 +26,10 @@ class LocalesTest(locales.LocalesMixin, script.BaseScript):
|
||||
self.config = {}
|
||||
self.log_obj = None
|
||||
|
||||
|
||||
class TestLocalesMixin(unittest.TestCase):
|
||||
BASE_ABS_DIRS = ['abs_log_dir', 'abs_work_dir', 'base_work_dir']
|
||||
|
||||
def setUp(self):
|
||||
cleanup()
|
||||
|
||||
@ -74,7 +75,9 @@ class TestLocalesMixin(unittest.TestCase):
|
||||
|
||||
def test_parse_locales_file(self):
|
||||
l = LocalesTest()
|
||||
self.assertEqual(ALL_LOCALES, l.parse_locales_file(os.path.join(MH_DIR, 'test/helper_files/locales.txt')))
|
||||
self.assertEqual(
|
||||
ALL_LOCALES,
|
||||
l.parse_locales_file(os.path.join(MH_DIR, 'test/helper_files/locales.txt')))
|
||||
|
||||
def _get_query_abs_dirs_obj(self):
|
||||
l = LocalesTest()
|
||||
@ -111,7 +114,8 @@ class TestLocalesMixin(unittest.TestCase):
|
||||
l.config['locales_dir'] = "locales_dir"
|
||||
dirs = l.query_abs_dirs().keys()
|
||||
dirs.sort()
|
||||
expected_dirs = self.BASE_ABS_DIRS + ['abs_mozilla_dir', 'abs_locales_src_dir', 'abs_l10n_dir']
|
||||
expected_dirs = self.BASE_ABS_DIRS + [
|
||||
'abs_mozilla_dir', 'abs_locales_src_dir', 'abs_l10n_dir']
|
||||
expected_dirs.sort()
|
||||
self.assertEqual(dirs, expected_dirs)
|
||||
|
||||
@ -123,9 +127,12 @@ class TestLocalesMixin(unittest.TestCase):
|
||||
l.config['objdir'] = "objdir"
|
||||
dirs = l.query_abs_dirs().keys()
|
||||
dirs.sort()
|
||||
expected_dirs = self.BASE_ABS_DIRS + ['abs_mozilla_dir', 'abs_locales_src_dir', 'abs_l10n_dir', 'abs_objdir', 'abs_locales_dir']
|
||||
expected_dirs = self.BASE_ABS_DIRS + [
|
||||
'abs_mozilla_dir', 'abs_locales_src_dir', 'abs_l10n_dir',
|
||||
'abs_objdir', 'abs_locales_dir']
|
||||
expected_dirs.sort()
|
||||
self.assertEqual(dirs, expected_dirs)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@ -51,11 +51,11 @@ proofs = [
|
||||
[nodeC, nodeD],
|
||||
]
|
||||
|
||||
known_proof5 = ('020000' + \
|
||||
'0000000000000007' + '0000000000000005' + \
|
||||
'0063' + \
|
||||
'20' + leaves[4].encode('hex') + \
|
||||
'20' + leaves[6].encode('hex') + \
|
||||
known_proof5 = ('020000' +
|
||||
'0000000000000007' + '0000000000000005' +
|
||||
'0063' +
|
||||
'20' + leaves[4].encode('hex') +
|
||||
'20' + leaves[6].encode('hex') +
|
||||
'20' + nodeD.encode('hex')).decode('hex')
|
||||
|
||||
|
||||
@ -73,7 +73,6 @@ class TestMerkleTree(unittest.TestCase):
|
||||
self.assertEquals(proof.tree_size, tree.n)
|
||||
self.assertEquals(proof.path_elements, proofs[i])
|
||||
|
||||
|
||||
def testInclusionProofEncodeDecode(self):
|
||||
tree = MerkleTree(hash_fn, data)
|
||||
|
||||
@ -97,7 +96,10 @@ class TestMerkleTree(unittest.TestCase):
|
||||
def testLargeTree(self):
|
||||
TEST_SIZE = 5000
|
||||
ELEM_SIZE_BYTES = 16
|
||||
data = [bytearray(random.getrandbits(8) for _ in xrange(ELEM_SIZE_BYTES)) for _ in xrange(TEST_SIZE)]
|
||||
data = [
|
||||
bytearray(random.getrandbits(8) for _ in xrange(ELEM_SIZE_BYTES))
|
||||
for _ in xrange(TEST_SIZE)
|
||||
]
|
||||
tree = MerkleTree(hash_fn, data)
|
||||
head = tree.head()
|
||||
|
||||
|
@ -41,6 +41,7 @@ flake8:
|
||||
- testing/mozharness/mozharness/mozilla/tooltool.py
|
||||
- testing/mozharness/mozinfo
|
||||
- testing/mozharness/scripts
|
||||
- testing/mozharness/test
|
||||
- testing/raptor
|
||||
- testing/remotecppunittests.py
|
||||
- testing/runcppunittests.py
|
||||
|
Loading…
Reference in New Issue
Block a user