Bug 707976 - Remove manifestdestiny from its old location in m-c and use that in testing/mozbase;r=ahal

--HG--
extra : rebase_source : 78e596979ddfb001475270580afeab992694ed45
This commit is contained in:
Jeff Hammel 2013-06-07 12:30:11 -07:00
parent 3317047283
commit 7fc49a98a4
18 changed files with 15 additions and 1689 deletions

View File

@ -78,10 +78,6 @@ GDBINIT_FILES := $(topsrcdir)/.gdbinit
GDBINIT_DEST = $(FINAL_TARGET)
INSTALL_TARGETS += GDBINIT
PYTHON_UNIT_TESTS := \
tests/test.py \
$(NULL)
include $(topsrcdir)/config/rules.mk
# we install to _leaktest/

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +0,0 @@
# illustrate test filters based on various categories
[windowstest]
run-if = os == 'win'
[fleem]
skip-if = os == 'mac'
[linuxtest]
skip-if = (os == 'mac') || (os == 'win')
fail-if = toolkit == 'cocoa'

View File

@ -1 +0,0 @@
# dummy spot for "fleem" test

View File

@ -1,11 +0,0 @@
[DEFAULT]
foo = bar
[include:include/bar.ini]
[fleem]
[include:include/foo.ini]
red = roses
blue = violets
yellow = daffodils

View File

@ -1,4 +0,0 @@
[DEFAULT]
foo = fleem
[crash-handling]

View File

@ -1 +0,0 @@
# dummy spot for "crash-handling" test

View File

@ -1 +0,0 @@
# dummy spot for "flowers" test

View File

@ -1,5 +0,0 @@
[DEFAULT]
blue = ocean
[flowers]
yellow = submarine

View File

@ -1,80 +0,0 @@
[testAddons/testDisableEnablePlugin.js]
[testAddons/testGetAddons.js]
[testAddons/testSearchAddons.js]
[testAwesomeBar/testAccessLocationBar.js]
[testAwesomeBar/testCheckItemHighlight.js]
[testAwesomeBar/testEscapeAutocomplete.js]
[testAwesomeBar/testFaviconInAutocomplete.js]
[testAwesomeBar/testGoButton.js]
[testAwesomeBar/testLocationBarSearches.js]
[testAwesomeBar/testPasteLocationBar.js]
[testAwesomeBar/testSuggestHistoryBookmarks.js]
[testAwesomeBar/testVisibleItemsMax.js]
[testBookmarks/testAddBookmarkToMenu.js]
[testCookies/testDisableCookies.js]
[testCookies/testEnableCookies.js]
[testCookies/testRemoveAllCookies.js]
[testCookies/testRemoveCookie.js]
[testDownloading/testCloseDownloadManager.js]
[testDownloading/testDownloadStates.js]
[testDownloading/testOpenDownloadManager.js]
[testFindInPage/testFindInPage.js]
[testFormManager/testAutoCompleteOff.js]
[testFormManager/testBasicFormCompletion.js]
[testFormManager/testClearFormHistory.js]
[testFormManager/testDisableFormManager.js]
[testGeneral/testGoogleSuggestions.js]
[testGeneral/testStopReloadButtons.js]
[testInstallation/testBreakpadInstalled.js]
[testLayout/testNavigateFTP.js]
[testPasswordManager/testPasswordNotSaved.js]
[testPasswordManager/testPasswordSavedAndDeleted.js]
[testPopups/testPopupsAllowed.js]
[testPopups/testPopupsBlocked.js]
[testPreferences/testPaneRetention.js]
[testPreferences/testPreferredLanguage.js]
[testPreferences/testRestoreHomepageToDefault.js]
[testPreferences/testSetToCurrentPage.js]
[testPreferences/testSwitchPanes.js]
[testPrivateBrowsing/testAboutPrivateBrowsing.js]
[testPrivateBrowsing/testCloseWindow.js]
[testPrivateBrowsing/testDisabledElements.js]
[testPrivateBrowsing/testDisabledPermissions.js]
[testPrivateBrowsing/testDownloadManagerClosed.js]
[testPrivateBrowsing/testGeolocation.js]
[testPrivateBrowsing/testStartStopPBMode.js]
[testPrivateBrowsing/testTabRestoration.js]
[testPrivateBrowsing/testTabsDismissedOnStop.js]
[testSearch/testAddMozSearchProvider.js]
[testSearch/testFocusAndSearch.js]
[testSearch/testGetMoreSearchEngines.js]
[testSearch/testOpenSearchAutodiscovery.js]
[testSearch/testRemoveSearchEngine.js]
[testSearch/testReorderSearchEngines.js]
[testSearch/testRestoreDefaults.js]
[testSearch/testSearchSelection.js]
[testSearch/testSearchSuggestions.js]
[testSecurity/testBlueLarry.js]
[testSecurity/testDefaultPhishingEnabled.js]
[testSecurity/testDefaultSecurityPrefs.js]
[testSecurity/testEncryptedPageWarning.js]
[testSecurity/testGreenLarry.js]
[testSecurity/testGreyLarry.js]
[testSecurity/testIdentityPopupOpenClose.js]
[testSecurity/testSSLDisabledErrorPage.js]
[testSecurity/testSafeBrowsingNotificationBar.js]
[testSecurity/testSafeBrowsingWarningPages.js]
[testSecurity/testSecurityInfoViaMoreInformation.js]
[testSecurity/testSecurityNotification.js]
[testSecurity/testSubmitUnencryptedInfoWarning.js]
[testSecurity/testUnknownIssuer.js]
[testSecurity/testUntrustedConnectionErrorPage.js]
[testSessionStore/testUndoTabFromContextMenu.js]
[testTabbedBrowsing/testBackgroundTabScrolling.js]
[testTabbedBrowsing/testCloseTab.js]
[testTabbedBrowsing/testNewTab.js]
[testTabbedBrowsing/testNewWindow.js]
[testTabbedBrowsing/testOpenInBackground.js]
[testTabbedBrowsing/testOpenInForeground.js]
[testTechnicalTools/testAccessPageInfoDialog.js]
[testToolbar/testBackForwardButtons.js]

View File

@ -1,26 +0,0 @@
[DEFAULT]
type = restart
[restartTests/testExtensionInstallUninstall/test2.js]
foo = bar
[restartTests/testExtensionInstallUninstall/test1.js]
foo = baz
[restartTests/testExtensionInstallUninstall/test3.js]
[restartTests/testSoftwareUpdateAutoProxy/test2.js]
[restartTests/testSoftwareUpdateAutoProxy/test1.js]
[restartTests/testMasterPassword/test1.js]
[restartTests/testExtensionInstallGetAddons/test2.js]
[restartTests/testExtensionInstallGetAddons/test1.js]
[restartTests/testMultipleExtensionInstallation/test2.js]
[restartTests/testMultipleExtensionInstallation/test1.js]
[restartTests/testThemeInstallUninstall/test2.js]
[restartTests/testThemeInstallUninstall/test1.js]
[restartTests/testThemeInstallUninstall/test3.js]
[restartTests/testDefaultBookmarks/test1.js]
[softwareUpdate/testFallbackUpdate/test2.js]
[softwareUpdate/testFallbackUpdate/test1.js]
[softwareUpdate/testFallbackUpdate/test3.js]
[softwareUpdate/testDirectUpdate/test2.js]
[softwareUpdate/testDirectUpdate/test1.js]

View File

@ -1,2 +0,0 @@
[foo]
path = fleem

View File

@ -1,81 +0,0 @@
#!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""tests for ManifestDestiny"""
import doctest
import os
import sys
from optparse import OptionParser
def run_tests(raise_on_error=False, report_first=False):
# add results here
results = {}
# doctest arguments
directory = os.path.dirname(os.path.abspath(__file__))
extraglobs = {}
doctest_args = dict(extraglobs=extraglobs,
module_relative=False,
raise_on_error=raise_on_error)
if report_first:
doctest_args['optionflags'] = doctest.REPORT_ONLY_FIRST_FAILURE
# gather tests
directory = os.path.dirname(os.path.abspath(__file__))
tests = [ test for test in os.listdir(directory)
if test.endswith('.txt') and test.startswith('test_')]
os.chdir(directory)
# run the tests
for test in tests:
try:
results[test] = doctest.testfile(test, **doctest_args)
except doctest.DocTestFailure, failure:
raise
except doctest.UnexpectedException, failure:
raise failure.exc_info[0], failure.exc_info[1], failure.exc_info[2]
return results
def main(args=sys.argv[1:]):
# parse command line options
parser = OptionParser(description=__doc__)
parser.add_option('--raise', dest='raise_on_error',
default=False, action='store_true',
help="raise on first error")
parser.add_option('--report-first', dest='report_first',
default=False, action='store_true',
help="report the first error only (all tests will still run)")
parser.add_option('-q', '--quiet', dest='quiet',
default=False, action='store_true',
help="minimize output")
options, args = parser.parse_args(args)
quiet = options.__dict__.pop('quiet')
# run the tests
results = run_tests(**options.__dict__)
# check for failure
failed = False
for result in results.values():
if result[0]: # failure count; http://docs.python.org/library/doctest.html#basic-api
failed = True
break
if failed:
sys.exit(1) # error
if not quiet:
# print results
print "manifestparser.py: All tests pass!"
for test in sorted(results.keys()):
result = results[test]
print "%s: failed=%s, attempted=%s" % (test, result[0], result[1])
if __name__ == '__main__':
main()

View File

@ -1,120 +0,0 @@
Test Expressionparser
=====================
Test the conditional expression parser.
Boilerplate::
>>> from manifestparser import parse
Test basic values::
>>> parse("1")
1
>>> parse("100")
100
>>> parse("true")
True
>>> parse("false")
False
>>> '' == parse('""')
True
>>> parse('"foo bar"')
'foo bar'
>>> parse("'foo bar'")
'foo bar'
>>> parse("foo", foo=1)
1
>>> parse("bar", bar=True)
True
>>> parse("abc123", abc123="xyz")
'xyz'
Test equality::
>>> parse("true == true")
True
>>> parse("false == false")
True
>>> parse("false == false")
True
>>> parse("1 == 1")
True
>>> parse("100 == 100")
True
>>> parse('"some text" == "some text"')
True
>>> parse("true != false")
True
>>> parse("1 != 2")
True
>>> parse('"text" != "other text"')
True
>>> parse("foo == true", foo=True)
True
>>> parse("foo == 1", foo=1)
True
>>> parse('foo == "bar"', foo='bar')
True
>>> parse("foo == bar", foo=True, bar=True)
True
>>> parse("true == foo", foo=True)
True
>>> parse("foo != true", foo=False)
True
>>> parse("foo != 2", foo=1)
True
>>> parse('foo != "bar"', foo='abc')
True
>>> parse("foo != bar", foo=True, bar=False)
True
>>> parse("true != foo", foo=False)
True
>>> parse("!false")
True
Test conjunctions::
>>> parse("true && true")
True
>>> parse("true || false")
True
>>> parse("false || false")
False
>>> parse("true && false")
False
>>> parse("true || false && false")
True
Test parentheses::
>>> parse("(true)")
True
>>> parse("(10)")
10
>>> parse('("foo")')
'foo'
>>> parse("(foo)", foo=1)
1
>>> parse("(true == true)")
True
>>> parse("(true != false)")
True
>>> parse("(true && true)")
True
>>> parse("(true || false)")
True
>>> parse("(true && true || false)")
True
>>> parse("(true || false) && false")
False
>>> parse("(true || false) && true")
True
>>> parse("true && (true || false)")
True
>>> parse("true && (true || false)")
True
>>> parse("(true && false) || (true && (true || false))")
True

View File

@ -1,217 +0,0 @@
Test the manifest parser
========================
You must have ManifestDestiny installed before running these tests.
Run ``python manifestparser.py setup develop`` with setuptools installed.
Ensure basic parser is sane::
>>> from manifestparser import ManifestParser
>>> parser = ManifestParser()
>>> parser.read('mozmill-example.ini')
>>> tests = parser.tests
>>> len(tests) == len(file('mozmill-example.ini').read().strip().splitlines())
True
Ensure that capitalization and order aren't an issue:
>>> lines = ['[%s]' % test['name'] for test in tests]
>>> lines == file('mozmill-example.ini').read().strip().splitlines()
True
Show how you select subsets of tests:
>>> parser.read('mozmill-restart-example.ini')
>>> restart_tests = parser.get(type='restart')
>>> len(restart_tests) < len(parser.tests)
True
>>> import os
>>> len(restart_tests) == len(parser.get(manifest=os.path.abspath('mozmill-restart-example.ini')))
True
>>> assert not [test for test in restart_tests if test['manifest'] != os.path.abspath('mozmill-restart-example.ini')]
>>> parser.get('name', tags=['foo'])
['restartTests/testExtensionInstallUninstall/test2.js', 'restartTests/testExtensionInstallUninstall/test1.js']
>>> parser.get('name', foo='bar')
['restartTests/testExtensionInstallUninstall/test2.js']
Illustrate how include works::
>>> parser = ManifestParser(manifests=('include-example.ini',))
All of the tests should be included, in order::
>>> parser.get('name')
['crash-handling', 'fleem', 'flowers']
>>> [(test['name'], os.path.basename(test['manifest'])) for test in parser.tests]
[('crash-handling', 'bar.ini'), ('fleem', 'include-example.ini'), ('flowers', 'foo.ini')]
The manifests should be there too::
>>> len(parser.manifests())
3
We're already in the root directory::
>>> os.getcwd() == parser.rootdir
True
DEFAULT values should persist across includes, unless they're
overwritten. In this example, include-example.ini sets foo=bar, but
its overridden to fleem in bar.ini::
>>> parser.get('name', foo='bar')
['fleem', 'flowers']
>>> parser.get('name', foo='fleem')
['crash-handling']
Passing parameters in the include section allows defining variables in
the submodule scope:
>>> parser.get('name', tags=['red'])
['flowers']
However, this should be overridable from the DEFAULT section in the
included file and that overridable via the key directly connected to
the test::
>>> parser.get(name='flowers')[0]['blue']
'ocean'
>>> parser.get(name='flowers')[0]['yellow']
'submarine'
You can query multiple times if you need to::
>>> flowers = parser.get(foo='bar')
>>> len(flowers)
2
>>> roses = parser.get(tests=flowers, red='roses')
Using the inverse flag should invert the set of tests returned::
>>> parser.get('name', inverse=True, tags=['red'])
['crash-handling', 'fleem']
All of the included tests actually exist::
>>> [i['name'] for i in parser.missing()]
[]
Write the output to a manifest:
>>> from StringIO import StringIO
>>> buffer = StringIO()
>>> parser.write(fp=buffer, global_kwargs={'foo': 'bar'})
>>> buffer.getvalue().strip()
'[DEFAULT]\nfoo = bar\n\n[fleem]\n\n[include/flowers]\nblue = ocean\nred = roses\nyellow = submarine'
Test our ability to convert a static directory structure to a
manifest. First, stub out a directory with files in it::
>>> import shutil, tempfile
>>> def create_stub():
... directory = tempfile.mkdtemp()
... for i in 'foo', 'bar', 'fleem':
... file(os.path.join(directory, i), 'w').write(i)
... subdir = os.path.join(directory, 'subdir')
... os.mkdir(subdir)
... file(os.path.join(subdir, 'subfile'), 'w').write('baz')
... return directory
>>> stub = create_stub()
>>> os.path.exists(stub) and os.path.isdir(stub)
True
Make a manifest for it::
>>> from manifestparser import convert
>>> print convert([stub])
[bar]
[fleem]
[foo]
[subdir/subfile]
>>> shutil.rmtree(stub)
Now do the same thing but keep the manifests in place::
>>> stub = create_stub()
>>> convert([stub], write='manifest.ini')
>>> sorted(os.listdir(stub))
['bar', 'fleem', 'foo', 'manifest.ini', 'subdir']
>>> parser = ManifestParser()
>>> parser.read(os.path.join(stub, 'manifest.ini'))
>>> [i['name'] for i in parser.tests]
['subfile', 'bar', 'fleem', 'foo']
>>> parser = ManifestParser()
>>> parser.read(os.path.join(stub, 'subdir', 'manifest.ini'))
>>> len(parser.tests)
1
>>> parser.tests[0]['name']
'subfile'
>>> shutil.rmtree(stub)
Test our ability to copy a set of manifests::
>>> tempdir = tempfile.mkdtemp()
>>> manifest = ManifestParser(manifests=('include-example.ini',))
>>> manifest.copy(tempdir)
>>> sorted(os.listdir(tempdir))
['fleem', 'include', 'include-example.ini']
>>> sorted(os.listdir(os.path.join(tempdir, 'include')))
['bar.ini', 'crash-handling', 'flowers', 'foo.ini']
>>> from_manifest = ManifestParser(manifests=('include-example.ini',))
>>> to_manifest = os.path.join(tempdir, 'include-example.ini')
>>> to_manifest = ManifestParser(manifests=(to_manifest,))
>>> to_manifest.get('name') == from_manifest.get('name')
True
>>> shutil.rmtree(tempdir)
Test our ability to update tests from a manifest and a directory of
files::
>>> tempdir = tempfile.mkdtemp()
>>> for i in range(10):
... file(os.path.join(tempdir, str(i)), 'w').write(str(i))
First, make a manifest::
>>> manifest = convert([tempdir])
>>> newtempdir = tempfile.mkdtemp()
>>> manifest_file = os.path.join(newtempdir, 'manifest.ini')
>>> file(manifest_file,'w').write(manifest)
>>> manifest = ManifestParser(manifests=(manifest_file,))
>>> manifest.get('name') == [str(i) for i in range(10)]
True
All of the tests are initially missing::
>>> [i['name'] for i in manifest.missing()] == [str(i) for i in range(10)]
True
But then we copy one over::
>>> manifest.get('name', name='1')
['1']
>>> manifest.update(tempdir, name='1')
>>> sorted(os.listdir(newtempdir))
['1', 'manifest.ini']
Update that one file and copy all the "tests"::
>>> file(os.path.join(tempdir, '1'), 'w').write('secret door')
>>> manifest.update(tempdir)
>>> sorted(os.listdir(newtempdir))
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'manifest.ini']
>>> file(os.path.join(newtempdir, '1')).read().strip()
'secret door'
Clean up::
>>> shutil.rmtree(tempdir)
>>> shutil.rmtree(newtempdir)
You can override the path in the section too. This shows that you can
use a relative path::
>>> manifest = ManifestParser(manifests=('path-example.ini',))
>>> manifest.tests[0]['path'] == os.path.abspath('fleem')
True

View File

@ -1,32 +0,0 @@
Test the Test Manifest
======================
Boilerplate::
>>> import os
Test filtering based on platform::
>>> from manifestparser import TestManifest
>>> manifest = TestManifest(manifests=('filter-example.ini',))
>>> [i['name'] for i in manifest.active_tests(os='win', disabled=False, exists=False)]
['windowstest', 'fleem']
>>> [i['name'] for i in manifest.active_tests(os='linux', disabled=False, exists=False)]
['fleem', 'linuxtest']
Look for existing tests. There is only one::
>>> [i['name'] for i in manifest.active_tests()]
['fleem']
You should be able to expect failures::
>>> last_test = manifest.active_tests(exists=False, toolkit='gtk2')[-1]
>>> last_test['name']
'linuxtest'
>>> last_test['expected']
'pass'
>>> last_test = manifest.active_tests(exists=False, toolkit='cocoa')[-1]
>>> last_test['expected']
'fail'

View File

@ -40,10 +40,10 @@ _SERV_FILES = \
$(topsrcdir)/testing/mozbase/mozdevice/mozdevice/devicemanager.py \
$(topsrcdir)/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py \
$(topsrcdir)/testing/mozbase/mozdevice/mozdevice/devicemanagerSUT.py \
$(topsrcdir)/testing/mozbase/manifestdestiny/manifestparser/manifestparser.py \
$(topsrcdir)/testing/mozbase/mozdevice/mozdevice/droid.py \
$(topsrcdir)/testing/mozbase/mozdevice/mozdevice/Zeroconf.py \
$(topsrcdir)/build/automationutils.py \
$(topsrcdir)/build/manifestparser.py \
$(topsrcdir)/build/mobile/remoteautomation.py \
$(topsrcdir)/build/mobile/b2gautomation.py \
gen_template.pl \

View File

@ -11,7 +11,6 @@ from optparse import OptionParser
from subprocess import Popen, PIPE, STDOUT
from tempfile import mkdtemp, gettempdir
from threading import Timer
import manifestparser
import mozinfo
import random
import socket
@ -28,19 +27,21 @@ HARNESS_TIMEOUT = 5 * 60
here = os.path.dirname(__file__)
mozbase = os.path.realpath(os.path.join(os.path.dirname(here), 'mozbase'))
try:
import mozcrash
except:
deps = ['mozcrash',
'mozfile',
'mozlog']
for dep in deps:
module = os.path.join(mozbase, dep)
if module not in sys.path:
sys.path.append(module)
import mozcrash
# ---------------------------------------------------------------
# hand enumerate our own deps
modules = [('mozcrash', ['mozcrash', 'mozfile', 'mozlog']),
('manifestparser', ['manifestdestiny'])]
for module, deps in modules:
try:
globals()[module] = __import__(module)
except ImportError:
for dep in deps:
module_path = os.path.join(mozbase, dep)
if module_path not in sys.path:
sys.path.append(module_path)
globals()[module] = __import__(module)
# ---------------------------------------------------------------
#TODO: replace this with json.loads when Python 2.6 is required.
def parse_json(j):
"""