summaryrefslogtreecommitdiffstats
path: root/testing/mozbase/manifestparser/tests
diff options
context:
space:
mode:
Diffstat (limited to 'testing/mozbase/manifestparser/tests')
-rw-r--r--testing/mozbase/manifestparser/tests/comment-example.ini11
-rw-r--r--testing/mozbase/manifestparser/tests/default-skipif.ini22
-rw-r--r--testing/mozbase/manifestparser/tests/default-suppfiles.ini9
-rw-r--r--testing/mozbase/manifestparser/tests/filter-example.ini11
-rw-r--r--testing/mozbase/manifestparser/tests/fleem1
-rw-r--r--testing/mozbase/manifestparser/tests/include-example.ini11
-rw-r--r--testing/mozbase/manifestparser/tests/include-invalid.ini1
-rw-r--r--testing/mozbase/manifestparser/tests/include/bar.ini4
-rw-r--r--testing/mozbase/manifestparser/tests/include/crash-handling1
-rw-r--r--testing/mozbase/manifestparser/tests/include/flowers1
-rw-r--r--testing/mozbase/manifestparser/tests/include/foo.ini5
-rw-r--r--testing/mozbase/manifestparser/tests/just-defaults.ini2
-rw-r--r--testing/mozbase/manifestparser/tests/manifest.ini11
-rw-r--r--testing/mozbase/manifestparser/tests/missing-path.ini2
-rw-r--r--testing/mozbase/manifestparser/tests/mozmill-example.ini80
-rw-r--r--testing/mozbase/manifestparser/tests/mozmill-restart-example.ini26
-rw-r--r--testing/mozbase/manifestparser/tests/no-tests.ini2
-rw-r--r--testing/mozbase/manifestparser/tests/parent/include/first/manifest.ini3
-rw-r--r--testing/mozbase/manifestparser/tests/parent/include/manifest.ini8
-rw-r--r--testing/mozbase/manifestparser/tests/parent/include/second/manifest.ini3
-rw-r--r--testing/mozbase/manifestparser/tests/parent/level_1/level_1.ini5
-rw-r--r--testing/mozbase/manifestparser/tests/parent/level_1/level_1_server-root.ini5
-rw-r--r--testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_2.ini3
-rw-r--r--testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_2_server-root.ini3
-rw-r--r--testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_3/level_3.ini3
-rw-r--r--testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_3/level_3_default.ini6
-rw-r--r--testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_3/level_3_server-root.ini3
-rw-r--r--testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_3/test_31
-rw-r--r--testing/mozbase/manifestparser/tests/parent/level_1/level_2/test_21
-rw-r--r--testing/mozbase/manifestparser/tests/parent/level_1/test_11
-rw-r--r--testing/mozbase/manifestparser/tests/parent/root/dummy0
-rw-r--r--testing/mozbase/manifestparser/tests/path-example.ini2
-rw-r--r--testing/mozbase/manifestparser/tests/relative-path.ini5
-rw-r--r--testing/mozbase/manifestparser/tests/subsuite.ini13
-rw-r--r--testing/mozbase/manifestparser/tests/test_chunking.py302
-rwxr-xr-xtesting/mozbase/manifestparser/tests/test_convert_directory.py181
-rwxr-xr-xtesting/mozbase/manifestparser/tests/test_convert_symlinks.py139
-rwxr-xr-xtesting/mozbase/manifestparser/tests/test_default_overrides.py115
-rwxr-xr-xtesting/mozbase/manifestparser/tests/test_expressionparser.py152
-rw-r--r--testing/mozbase/manifestparser/tests/test_filters.py182
-rwxr-xr-xtesting/mozbase/manifestparser/tests/test_manifestparser.py325
-rwxr-xr-xtesting/mozbase/manifestparser/tests/test_read_ini.py70
-rw-r--r--testing/mozbase/manifestparser/tests/test_testmanifest.py122
-rw-r--r--testing/mozbase/manifestparser/tests/verifyDirectory/subdir/manifest.ini1
-rw-r--r--testing/mozbase/manifestparser/tests/verifyDirectory/subdir/test_sub.js1
-rw-r--r--testing/mozbase/manifestparser/tests/verifyDirectory/test_1.js1
-rw-r--r--testing/mozbase/manifestparser/tests/verifyDirectory/test_2.js1
-rw-r--r--testing/mozbase/manifestparser/tests/verifyDirectory/test_3.js1
-rw-r--r--testing/mozbase/manifestparser/tests/verifyDirectory/verifyDirectory.ini4
-rw-r--r--testing/mozbase/manifestparser/tests/verifyDirectory/verifyDirectory_incomplete.ini3
-rw-r--r--testing/mozbase/manifestparser/tests/verifyDirectory/verifyDirectory_toocomplete.ini5
51 files changed, 1870 insertions, 0 deletions
diff --git a/testing/mozbase/manifestparser/tests/comment-example.ini b/testing/mozbase/manifestparser/tests/comment-example.ini
new file mode 100644
index 000000000..030ceffdb
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/comment-example.ini
@@ -0,0 +1,11 @@
+; See https://bugzilla.mozilla.org/show_bug.cgi?id=813674
+
+[test_0180_fileInUse_xp_win_complete.js]
+[test_0181_fileInUse_xp_win_partial.js]
+[test_0182_rmrfdirFileInUse_xp_win_complete.js]
+[test_0183_rmrfdirFileInUse_xp_win_partial.js]
+[test_0184_fileInUse_xp_win_complete.js]
+[test_0185_fileInUse_xp_win_partial.js]
+[test_0186_rmrfdirFileInUse_xp_win_complete.js]
+[test_0187_rmrfdirFileInUse_xp_win_partial.js]
+; [test_0202_app_launch_apply_update_dirlocked.js] # Test disabled, bug 757632 \ No newline at end of file
diff --git a/testing/mozbase/manifestparser/tests/default-skipif.ini b/testing/mozbase/manifestparser/tests/default-skipif.ini
new file mode 100644
index 000000000..d3c268733
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/default-skipif.ini
@@ -0,0 +1,22 @@
+[DEFAULT]
+skip-if = os == 'win' && debug # a pesky comment
+
+
+[test1]
+skip-if = debug
+
+[test2]
+skip-if = os == 'linux'
+
+[test3]
+skip-if = os == 'win'
+
+[test4]
+skip-if = os == 'win' && debug
+
+[test5]
+foo = bar
+
+[test6]
+skip-if = debug # a second pesky comment
+
diff --git a/testing/mozbase/manifestparser/tests/default-suppfiles.ini b/testing/mozbase/manifestparser/tests/default-suppfiles.ini
new file mode 100644
index 000000000..12af247b8
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/default-suppfiles.ini
@@ -0,0 +1,9 @@
+[DEFAULT]
+support-files = foo.js # a comment
+
+[test7]
+[test8]
+support-files = bar.js # another comment
+[test9]
+foo = bar
+
diff --git a/testing/mozbase/manifestparser/tests/filter-example.ini b/testing/mozbase/manifestparser/tests/filter-example.ini
new file mode 100644
index 000000000..13a8734c3
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/filter-example.ini
@@ -0,0 +1,11 @@
+# illustrate test filters based on various categories
+
+[windowstest]
+skip-if = os != 'win'
+
+[fleem]
+skip-if = os == 'mac'
+
+[linuxtest]
+skip-if = (os == 'mac') || (os == 'win')
+fail-if = toolkit == 'cocoa'
diff --git a/testing/mozbase/manifestparser/tests/fleem b/testing/mozbase/manifestparser/tests/fleem
new file mode 100644
index 000000000..744817b82
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/fleem
@@ -0,0 +1 @@
+# dummy spot for "fleem" test
diff --git a/testing/mozbase/manifestparser/tests/include-example.ini b/testing/mozbase/manifestparser/tests/include-example.ini
new file mode 100644
index 000000000..69e728c3b
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/include-example.ini
@@ -0,0 +1,11 @@
+[DEFAULT]
+foo = bar
+
+[include:include/bar.ini]
+
+[fleem]
+
+[include:include/foo.ini]
+red = roses
+blue = violets
+yellow = daffodils \ No newline at end of file
diff --git a/testing/mozbase/manifestparser/tests/include-invalid.ini b/testing/mozbase/manifestparser/tests/include-invalid.ini
new file mode 100644
index 000000000..e3ed0dd6b
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/include-invalid.ini
@@ -0,0 +1 @@
+[include:invalid.ini]
diff --git a/testing/mozbase/manifestparser/tests/include/bar.ini b/testing/mozbase/manifestparser/tests/include/bar.ini
new file mode 100644
index 000000000..bcb312d1d
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/include/bar.ini
@@ -0,0 +1,4 @@
+[DEFAULT]
+foo = fleem
+
+[crash-handling] \ No newline at end of file
diff --git a/testing/mozbase/manifestparser/tests/include/crash-handling b/testing/mozbase/manifestparser/tests/include/crash-handling
new file mode 100644
index 000000000..8e19a6375
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/include/crash-handling
@@ -0,0 +1 @@
+# dummy spot for "crash-handling" test
diff --git a/testing/mozbase/manifestparser/tests/include/flowers b/testing/mozbase/manifestparser/tests/include/flowers
new file mode 100644
index 000000000..a25acfbe2
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/include/flowers
@@ -0,0 +1 @@
+# dummy spot for "flowers" test
diff --git a/testing/mozbase/manifestparser/tests/include/foo.ini b/testing/mozbase/manifestparser/tests/include/foo.ini
new file mode 100644
index 000000000..cfc90ace8
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/include/foo.ini
@@ -0,0 +1,5 @@
+[DEFAULT]
+blue = ocean
+
+[flowers]
+yellow = submarine \ No newline at end of file
diff --git a/testing/mozbase/manifestparser/tests/just-defaults.ini b/testing/mozbase/manifestparser/tests/just-defaults.ini
new file mode 100644
index 000000000..83a0cec0c
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/just-defaults.ini
@@ -0,0 +1,2 @@
+[DEFAULT]
+foo = bar
diff --git a/testing/mozbase/manifestparser/tests/manifest.ini b/testing/mozbase/manifestparser/tests/manifest.ini
new file mode 100644
index 000000000..dfa185649
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/manifest.ini
@@ -0,0 +1,11 @@
+# test manifest for manifestparser
+[test_expressionparser.py]
+[test_manifestparser.py]
+[test_testmanifest.py]
+[test_read_ini.py]
+[test_convert_directory.py]
+[test_filters.py]
+[test_chunking.py]
+
+[test_convert_symlinks.py]
+disabled = https://bugzilla.mozilla.org/show_bug.cgi?id=920938
diff --git a/testing/mozbase/manifestparser/tests/missing-path.ini b/testing/mozbase/manifestparser/tests/missing-path.ini
new file mode 100644
index 000000000..919d8e04d
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/missing-path.ini
@@ -0,0 +1,2 @@
+[foo]
+[bar]
diff --git a/testing/mozbase/manifestparser/tests/mozmill-example.ini b/testing/mozbase/manifestparser/tests/mozmill-example.ini
new file mode 100644
index 000000000..114cf48c4
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/mozmill-example.ini
@@ -0,0 +1,80 @@
+[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]
diff --git a/testing/mozbase/manifestparser/tests/mozmill-restart-example.ini b/testing/mozbase/manifestparser/tests/mozmill-restart-example.ini
new file mode 100644
index 000000000..e27ae9b93
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/mozmill-restart-example.ini
@@ -0,0 +1,26 @@
+[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]
diff --git a/testing/mozbase/manifestparser/tests/no-tests.ini b/testing/mozbase/manifestparser/tests/no-tests.ini
new file mode 100644
index 000000000..83a0cec0c
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/no-tests.ini
@@ -0,0 +1,2 @@
+[DEFAULT]
+foo = bar
diff --git a/testing/mozbase/manifestparser/tests/parent/include/first/manifest.ini b/testing/mozbase/manifestparser/tests/parent/include/first/manifest.ini
new file mode 100644
index 000000000..828525c18
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/parent/include/first/manifest.ini
@@ -0,0 +1,3 @@
+[parent:../manifest.ini]
+
+[testFirst.js]
diff --git a/testing/mozbase/manifestparser/tests/parent/include/manifest.ini b/testing/mozbase/manifestparser/tests/parent/include/manifest.ini
new file mode 100644
index 000000000..fb9756d6a
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/parent/include/manifest.ini
@@ -0,0 +1,8 @@
+[DEFAULT]
+top = data
+
+[include:first/manifest.ini]
+disabled = YES
+
+[include:second/manifest.ini]
+disabled = NO
diff --git a/testing/mozbase/manifestparser/tests/parent/include/second/manifest.ini b/testing/mozbase/manifestparser/tests/parent/include/second/manifest.ini
new file mode 100644
index 000000000..31f053756
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/parent/include/second/manifest.ini
@@ -0,0 +1,3 @@
+[parent:../manifest.ini]
+
+[testSecond.js]
diff --git a/testing/mozbase/manifestparser/tests/parent/level_1/level_1.ini b/testing/mozbase/manifestparser/tests/parent/level_1/level_1.ini
new file mode 100644
index 000000000..ac7c370c3
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/parent/level_1/level_1.ini
@@ -0,0 +1,5 @@
+[DEFAULT]
+x = level_1
+
+[test_1]
+[test_2]
diff --git a/testing/mozbase/manifestparser/tests/parent/level_1/level_1_server-root.ini b/testing/mozbase/manifestparser/tests/parent/level_1/level_1_server-root.ini
new file mode 100644
index 000000000..486a9596e
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/parent/level_1/level_1_server-root.ini
@@ -0,0 +1,5 @@
+[DEFAULT]
+server-root = ../root
+other-root = ../root
+
+[test_1]
diff --git a/testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_2.ini b/testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_2.ini
new file mode 100644
index 000000000..ada6a510d
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_2.ini
@@ -0,0 +1,3 @@
+[parent:../level_1.ini]
+
+[test_2]
diff --git a/testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_2_server-root.ini b/testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_2_server-root.ini
new file mode 100644
index 000000000..218789784
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_2_server-root.ini
@@ -0,0 +1,3 @@
+[parent:../level_1_server-root.ini]
+
+[test_2]
diff --git a/testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_3/level_3.ini b/testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_3/level_3.ini
new file mode 100644
index 000000000..2edd647fc
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_3/level_3.ini
@@ -0,0 +1,3 @@
+[parent:../level_2.ini]
+
+[test_3]
diff --git a/testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_3/level_3_default.ini b/testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_3/level_3_default.ini
new file mode 100644
index 000000000..d6aae60ae
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_3/level_3_default.ini
@@ -0,0 +1,6 @@
+[parent:../level_2.ini]
+
+[DEFAULT]
+x = level_3
+
+[test_3]
diff --git a/testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_3/level_3_server-root.ini b/testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_3/level_3_server-root.ini
new file mode 100644
index 000000000..0427087b4
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_3/level_3_server-root.ini
@@ -0,0 +1,3 @@
+[parent:../level_2_server-root.ini]
+
+[test_3]
diff --git a/testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_3/test_3 b/testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_3/test_3
new file mode 100644
index 000000000..f5de58752
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/parent/level_1/level_2/level_3/test_3
@@ -0,0 +1 @@
+# dummy spot for "test_3" test
diff --git a/testing/mozbase/manifestparser/tests/parent/level_1/level_2/test_2 b/testing/mozbase/manifestparser/tests/parent/level_1/level_2/test_2
new file mode 100644
index 000000000..5b77e04f3
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/parent/level_1/level_2/test_2
@@ -0,0 +1 @@
+# dummy spot for "test_2" test
diff --git a/testing/mozbase/manifestparser/tests/parent/level_1/test_1 b/testing/mozbase/manifestparser/tests/parent/level_1/test_1
new file mode 100644
index 000000000..dccbf04e4
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/parent/level_1/test_1
@@ -0,0 +1 @@
+# dummy spot for "test_1" test
diff --git a/testing/mozbase/manifestparser/tests/parent/root/dummy b/testing/mozbase/manifestparser/tests/parent/root/dummy
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/parent/root/dummy
diff --git a/testing/mozbase/manifestparser/tests/path-example.ini b/testing/mozbase/manifestparser/tests/path-example.ini
new file mode 100644
index 000000000..366782d95
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/path-example.ini
@@ -0,0 +1,2 @@
+[foo]
+path = fleem \ No newline at end of file
diff --git a/testing/mozbase/manifestparser/tests/relative-path.ini b/testing/mozbase/manifestparser/tests/relative-path.ini
new file mode 100644
index 000000000..57105489b
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/relative-path.ini
@@ -0,0 +1,5 @@
+[foo]
+path = ../fleem
+
+[bar]
+path = ../testsSIBLING/example
diff --git a/testing/mozbase/manifestparser/tests/subsuite.ini b/testing/mozbase/manifestparser/tests/subsuite.ini
new file mode 100644
index 000000000..c1a70bd44
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/subsuite.ini
@@ -0,0 +1,13 @@
+[test1]
+subsuite=bar,foo=="bar" # this has a comment
+
+[test2]
+subsuite=bar,foo=="bar"
+
+[test3]
+subsuite=baz
+
+[test4]
+[test5]
+[test6]
+subsuite=bar,foo=="szy" || foo=="bar" \ No newline at end of file
diff --git a/testing/mozbase/manifestparser/tests/test_chunking.py b/testing/mozbase/manifestparser/tests/test_chunking.py
new file mode 100644
index 000000000..719bbca80
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/test_chunking.py
@@ -0,0 +1,302 @@
+#!/usr/bin/env python
+
+from itertools import chain
+from unittest import TestCase
+import os
+import random
+
+from manifestparser.filters import (
+ chunk_by_dir,
+ chunk_by_runtime,
+ chunk_by_slice,
+)
+
+here = os.path.dirname(os.path.abspath(__file__))
+
+
+class ChunkBySlice(TestCase):
+ """Test chunking related filters"""
+
+ def generate_tests(self, num, disabled=None):
+ disabled = disabled or []
+ tests = []
+ for i in range(num):
+ test = {'name': 'test%i' % i}
+ if i in disabled:
+ test['disabled'] = ''
+ tests.append(test)
+ return tests
+
+ def run_all_combos(self, num_tests, disabled=None):
+ tests = self.generate_tests(num_tests, disabled=disabled)
+
+ for total in range(1, num_tests + 1):
+ res = []
+ res_disabled = []
+ for chunk in range(1, total + 1):
+ f = chunk_by_slice(chunk, total)
+ res.append(list(f(tests, {})))
+ if disabled:
+ f.disabled = True
+ res_disabled.append(list(f(tests, {})))
+
+ lengths = [len([t for t in c if 'disabled' not in t]) for c in res]
+ # the chunk with the most tests should have at most one more test
+ # than the chunk with the least tests
+ self.assertLessEqual(max(lengths) - min(lengths), 1)
+
+ # chaining all chunks back together should equal the original list
+ # of tests
+ self.assertEqual(list(chain.from_iterable(res)), list(tests))
+
+ if disabled:
+ lengths = [len(c) for c in res_disabled]
+ self.assertLessEqual(max(lengths) - min(lengths), 1)
+ self.assertEqual(list(chain.from_iterable(res_disabled)),
+ list(tests))
+
+ def test_chunk_by_slice(self):
+ chunk = chunk_by_slice(1, 1)
+ self.assertEqual(list(chunk([], {})), [])
+
+ self.run_all_combos(num_tests=1)
+ self.run_all_combos(num_tests=10, disabled=[1, 2])
+
+ num_tests = 67
+ disabled = list(i for i in xrange(num_tests) if i % 4 == 0)
+ self.run_all_combos(num_tests=num_tests, disabled=disabled)
+
+ def test_two_times_more_chunks_than_tests(self):
+ # test case for bug 1182817
+ tests = self.generate_tests(5)
+
+ total_chunks = 10
+ for i in range(1, total_chunks + 1):
+ # ensure IndexError is not raised
+ chunk_by_slice(i, total_chunks)(tests, {})
+
+
+class ChunkByDir(TestCase):
+ """Test chunking related filters"""
+
+ def generate_tests(self, dirs):
+ """
+ :param dirs: dict of the form,
+ { <dir>: <num tests> }
+ """
+ i = 0
+ for d, num in dirs.iteritems():
+ for j in range(num):
+ i += 1
+ name = 'test%i' % i
+ test = {'name': name,
+ 'relpath': os.path.join(d, name)}
+ yield test
+
+ def run_all_combos(self, dirs):
+ tests = list(self.generate_tests(dirs))
+
+ deepest = max(len(t['relpath'].split(os.sep)) - 1 for t in tests)
+ for depth in range(1, deepest + 1):
+
+ def num_groups(tests):
+ unique = set()
+ for p in [t['relpath'] for t in tests]:
+ p = p.split(os.sep)
+ p = p[:min(depth, len(p) - 1)]
+ unique.add(os.sep.join(p))
+ return len(unique)
+
+ for total in range(1, num_groups(tests) + 1):
+ res = []
+ for this in range(1, total + 1):
+ f = chunk_by_dir(this, total, depth)
+ res.append(list(f(tests, {})))
+
+ lengths = map(num_groups, res)
+ # the chunk with the most dirs should have at most one more
+ # dir than the chunk with the least dirs
+ self.assertLessEqual(max(lengths) - min(lengths), 1)
+
+ all_chunks = list(chain.from_iterable(res))
+ # chunk_by_dir will mess up order, but chained chunks should
+ # contain all of the original tests and be the same length
+ self.assertEqual(len(all_chunks), len(tests))
+ for t in tests:
+ self.assertIn(t, all_chunks)
+
+ def test_chunk_by_dir(self):
+ chunk = chunk_by_dir(1, 1, 1)
+ self.assertEqual(list(chunk([], {})), [])
+
+ dirs = {
+ 'a': 2,
+ }
+ self.run_all_combos(dirs)
+
+ dirs = {
+ '': 1,
+ 'foo': 1,
+ 'bar': 0,
+ '/foobar': 1,
+ }
+ self.run_all_combos(dirs)
+
+ dirs = {
+ 'a': 1,
+ 'b': 1,
+ 'a/b': 2,
+ 'a/c': 1,
+ }
+ self.run_all_combos(dirs)
+
+ dirs = {
+ 'a': 5,
+ 'a/b': 4,
+ 'a/b/c': 7,
+ 'a/b/c/d': 1,
+ 'a/b/c/e': 3,
+ 'b/c': 2,
+ 'b/d': 5,
+ 'b/d/e': 6,
+ 'c': 8,
+ 'c/d/e/f/g/h/i/j/k/l': 5,
+ 'c/d/e/f/g/i/j/k/l/m/n': 2,
+ 'c/e': 1,
+ }
+ self.run_all_combos(dirs)
+
+
+class ChunkByRuntime(TestCase):
+ """Test chunking related filters"""
+
+ def generate_tests(self, dirs):
+ """
+ :param dirs: dict of the form,
+ { <dir>: <num tests> }
+ """
+ i = 0
+ for d, num in dirs.iteritems():
+ for j in range(num):
+ i += 1
+ name = 'test%i' % i
+ test = {'name': name,
+ 'relpath': os.path.join(d, name),
+ 'manifest': os.path.join(d, 'manifest.ini')}
+ yield test
+
+ def get_runtimes(self, tests):
+ runtimes = {}
+ for test in tests:
+ runtimes[test['relpath']] = random.randint(0, 100)
+ return runtimes
+
+ def chunk_by_round_robin(self, tests, runtimes):
+ manifests = set(t['manifest'] for t in tests)
+ tests_by_manifest = []
+ for manifest in manifests:
+ mtests = [t for t in tests if t['manifest'] == manifest]
+ total = sum(runtimes[t['relpath']] for t in mtests
+ if 'disabled' not in t)
+ tests_by_manifest.append((total, mtests))
+ tests_by_manifest.sort()
+
+ chunks = [[] for i in range(total)]
+ d = 1 # direction
+ i = 0
+ for runtime, batch in tests_by_manifest:
+ chunks[i].extend(batch)
+
+ # "draft" style (last pick goes first in the next round)
+ if (i == 0 and d == -1) or (i == total - 1 and d == 1):
+ d = -d
+ else:
+ i += d
+
+ # make sure this test algorithm is valid
+ all_chunks = list(chain.from_iterable(chunks))
+ self.assertEqual(len(all_chunks), len(tests))
+ for t in tests:
+ self.assertIn(t, all_chunks)
+
+ return chunks
+
+ def run_all_combos(self, dirs):
+ tests = list(self.generate_tests(dirs))
+ runtimes = self.get_runtimes(tests)
+
+ for total in range(1, len(dirs) + 1):
+ chunks = []
+ for this in range(1, total + 1):
+ f = chunk_by_runtime(this, total, runtimes)
+ ret = list(f(tests, {}))
+ chunks.append(ret)
+
+ # chunk_by_runtime will mess up order, but chained chunks should
+ # contain all of the original tests and be the same length
+ all_chunks = list(chain.from_iterable(chunks))
+ self.assertEqual(len(all_chunks), len(tests))
+ for t in tests:
+ self.assertIn(t, all_chunks)
+
+ # calculate delta between slowest and fastest chunks
+ def runtime_delta(chunks):
+ totals = []
+ for chunk in chunks:
+ total = sum(runtimes[t['relpath']] for t in chunk
+ if 'disabled' not in t)
+ totals.append(total)
+ return max(totals) - min(totals)
+ delta = runtime_delta(chunks)
+
+ # redo the chunking a second time using a round robin style
+ # algorithm
+ chunks = self.chunk_by_round_robin(tests, runtimes)
+
+ # since chunks will never have exactly equal runtimes, it's hard
+ # to tell if they were chunked optimally. Make sure it at least
+ # beats a naive round robin approach.
+ self.assertLessEqual(delta, runtime_delta(chunks))
+
+ def test_chunk_by_runtime(self):
+ random.seed(42)
+
+ chunk = chunk_by_runtime(1, 1, {})
+ self.assertEqual(list(chunk([], {})), [])
+
+ dirs = {
+ 'a': 2,
+ }
+ self.run_all_combos(dirs)
+
+ dirs = {
+ '': 1,
+ 'foo': 1,
+ 'bar': 0,
+ '/foobar': 1,
+ }
+ self.run_all_combos(dirs)
+
+ dirs = {
+ 'a': 1,
+ 'b': 1,
+ 'a/b': 2,
+ 'a/c': 1,
+ }
+ self.run_all_combos(dirs)
+
+ dirs = {
+ 'a': 5,
+ 'a/b': 4,
+ 'a/b/c': 7,
+ 'a/b/c/d': 1,
+ 'a/b/c/e': 3,
+ 'b/c': 2,
+ 'b/d': 5,
+ 'b/d/e': 6,
+ 'c': 8,
+ 'c/d/e/f/g/h/i/j/k/l': 5,
+ 'c/d/e/f/g/i/j/k/l/m/n': 2,
+ 'c/e': 1,
+ }
+ self.run_all_combos(dirs)
diff --git a/testing/mozbase/manifestparser/tests/test_convert_directory.py b/testing/mozbase/manifestparser/tests/test_convert_directory.py
new file mode 100755
index 000000000..12776e4e4
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/test_convert_directory.py
@@ -0,0 +1,181 @@
+#!/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/.
+
+import os
+import shutil
+import tempfile
+import unittest
+
+from manifestparser import convert
+from manifestparser import ManifestParser
+
+here = os.path.dirname(os.path.abspath(__file__))
+
+# In some cases tempfile.mkdtemp() may returns a path which contains
+# symlinks. Some tests here will then break, as the manifestparser.convert
+# function returns paths that does not contains symlinks.
+#
+# Workaround is to use the following function, if absolute path of temp dir
+# must be compared.
+
+
+def create_realpath_tempdir():
+ """
+ Create a tempdir without symlinks.
+ """
+ return os.path.realpath(tempfile.mkdtemp())
+
+
+class TestDirectoryConversion(unittest.TestCase):
+ """test conversion of a directory tree to a manifest structure"""
+
+ def create_stub(self, directory=None):
+ """stub out a directory with files in it"""
+
+ files = ('foo', 'bar', 'fleem')
+ if directory is None:
+ directory = create_realpath_tempdir()
+ for i in files:
+ 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
+
+ def test_directory_to_manifest(self):
+ """
+ Test our ability to convert a static directory structure to a
+ manifest.
+ """
+
+ # create a stub directory
+ stub = self.create_stub()
+ try:
+ stub = stub.replace(os.path.sep, "/")
+ self.assertTrue(os.path.exists(stub) and os.path.isdir(stub))
+
+ # Make a manifest for it
+ manifest = convert([stub])
+ out_tmpl = """[%(stub)s/bar]
+
+[%(stub)s/fleem]
+
+[%(stub)s/foo]
+
+[%(stub)s/subdir/subfile]
+
+""" # noqa
+ self.assertEqual(str(manifest), out_tmpl % dict(stub=stub))
+ except:
+ raise
+ finally:
+ shutil.rmtree(stub) # cleanup
+
+ def test_convert_directory_manifests_in_place(self):
+ """
+ keep the manifests in place
+ """
+
+ stub = self.create_stub()
+ try:
+ ManifestParser.populate_directory_manifests([stub], filename='manifest.ini')
+ self.assertEqual(sorted(os.listdir(stub)),
+ ['bar', 'fleem', 'foo', 'manifest.ini', 'subdir'])
+ parser = ManifestParser()
+ parser.read(os.path.join(stub, 'manifest.ini'))
+ self.assertEqual([i['name'] for i in parser.tests],
+ ['subfile', 'bar', 'fleem', 'foo'])
+ parser = ManifestParser()
+ parser.read(os.path.join(stub, 'subdir', 'manifest.ini'))
+ self.assertEqual(len(parser.tests), 1)
+ self.assertEqual(parser.tests[0]['name'], 'subfile')
+ except:
+ raise
+ finally:
+ shutil.rmtree(stub)
+
+ def test_manifest_ignore(self):
+ """test manifest `ignore` parameter for ignoring directories"""
+
+ stub = self.create_stub()
+ try:
+ ManifestParser.populate_directory_manifests(
+ [stub], filename='manifest.ini', ignore=('subdir',))
+ parser = ManifestParser()
+ parser.read(os.path.join(stub, 'manifest.ini'))
+ self.assertEqual([i['name'] for i in parser.tests],
+ ['bar', 'fleem', 'foo'])
+ self.assertFalse(os.path.exists(os.path.join(stub, 'subdir', 'manifest.ini')))
+ except:
+ raise
+ finally:
+ shutil.rmtree(stub)
+
+ def test_pattern(self):
+ """test directory -> manifest with a file pattern"""
+
+ stub = self.create_stub()
+ try:
+ parser = convert([stub], pattern='f*', relative_to=stub)
+ self.assertEqual([i['name'] for i in parser.tests],
+ ['fleem', 'foo'])
+
+ # test multiple patterns
+ parser = convert([stub], pattern=('f*', 's*'), relative_to=stub)
+ self.assertEqual([i['name'] for i in parser.tests],
+ ['fleem', 'foo', 'subdir/subfile'])
+ except:
+ raise
+ finally:
+ shutil.rmtree(stub)
+
+ def test_update(self):
+ """
+ Test our ability to update tests from a manifest and a directory of
+ files
+ """
+
+ # boilerplate
+ tempdir = create_realpath_tempdir()
+ for i in range(10):
+ file(os.path.join(tempdir, str(i)), 'w').write(str(i))
+
+ # otherwise empty directory with a manifest file
+ newtempdir = create_realpath_tempdir()
+ manifest_file = os.path.join(newtempdir, 'manifest.ini')
+ manifest_contents = str(convert([tempdir], relative_to=tempdir))
+ with file(manifest_file, 'w') as f:
+ f.write(manifest_contents)
+
+ # get the manifest
+ manifest = ManifestParser(manifests=(manifest_file,))
+
+ # All of the tests are initially missing:
+ paths = [str(i) for i in range(10)]
+ self.assertEqual([i['name'] for i in manifest.missing()],
+ paths)
+
+ # But then we copy one over:
+ self.assertEqual(manifest.get('name', name='1'), ['1'])
+ manifest.update(tempdir, name='1')
+ self.assertEqual(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)
+ self.assertEqual(sorted(os.listdir(newtempdir)),
+ ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'manifest.ini'])
+ self.assertEqual(file(os.path.join(newtempdir, '1')).read().strip(),
+ 'secret door')
+
+ # clean up:
+ shutil.rmtree(tempdir)
+ shutil.rmtree(newtempdir)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/manifestparser/tests/test_convert_symlinks.py b/testing/mozbase/manifestparser/tests/test_convert_symlinks.py
new file mode 100755
index 000000000..9a0640b4b
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/test_convert_symlinks.py
@@ -0,0 +1,139 @@
+#!/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/.
+
+import os
+import shutil
+import tempfile
+import unittest
+
+from manifestparser import convert, ManifestParser
+
+
+class TestSymlinkConversion(unittest.TestCase):
+ """
+ test conversion of a directory tree with symlinks to a manifest structure
+ """
+
+ def create_stub(self, directory=None):
+ """stub out a directory with files in it"""
+
+ files = ('foo', 'bar', 'fleem')
+ if directory is None:
+ directory = tempfile.mkdtemp()
+ for i in files:
+ 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
+
+ def test_relpath(self):
+ """test convert `relative_to` functionality"""
+
+ oldcwd = os.getcwd()
+ stub = self.create_stub()
+ try:
+ # subdir with in-memory manifest
+ files = ['../bar', '../fleem', '../foo', 'subfile']
+ subdir = os.path.join(stub, 'subdir')
+ os.chdir(subdir)
+ parser = convert([stub], relative_to='.')
+ self.assertEqual([i['name'] for i in parser.tests],
+ files)
+ except:
+ raise
+ finally:
+ shutil.rmtree(stub)
+ os.chdir(oldcwd)
+
+ @unittest.skipIf(not hasattr(os, 'symlink'),
+ "symlinks unavailable on this platform")
+ def test_relpath_symlink(self):
+ """
+ Ensure `relative_to` works in a symlink.
+ Not available on windows.
+ """
+
+ oldcwd = os.getcwd()
+ workspace = tempfile.mkdtemp()
+ try:
+ tmpdir = os.path.join(workspace, 'directory')
+ os.makedirs(tmpdir)
+ linkdir = os.path.join(workspace, 'link')
+ os.symlink(tmpdir, linkdir)
+ self.create_stub(tmpdir)
+
+ # subdir with in-memory manifest
+ files = ['../bar', '../fleem', '../foo', 'subfile']
+ subdir = os.path.join(linkdir, 'subdir')
+ os.chdir(os.path.realpath(subdir))
+ for directory in (tmpdir, linkdir):
+ parser = convert([directory], relative_to='.')
+ self.assertEqual([i['name'] for i in parser.tests],
+ files)
+ finally:
+ shutil.rmtree(workspace)
+ os.chdir(oldcwd)
+
+ # a more complicated example
+ oldcwd = os.getcwd()
+ workspace = tempfile.mkdtemp()
+ try:
+ tmpdir = os.path.join(workspace, 'directory')
+ os.makedirs(tmpdir)
+ linkdir = os.path.join(workspace, 'link')
+ os.symlink(tmpdir, linkdir)
+ self.create_stub(tmpdir)
+ files = ['../bar', '../fleem', '../foo', 'subfile']
+ subdir = os.path.join(linkdir, 'subdir')
+ subsubdir = os.path.join(subdir, 'sub')
+ os.makedirs(subsubdir)
+ linksubdir = os.path.join(linkdir, 'linky')
+ linksubsubdir = os.path.join(subsubdir, 'linky')
+ os.symlink(subdir, linksubdir)
+ os.symlink(subdir, linksubsubdir)
+ for dest in (subdir,):
+ os.chdir(dest)
+ for directory in (tmpdir, linkdir):
+ parser = convert([directory], relative_to='.')
+ self.assertEqual([i['name'] for i in parser.tests],
+ files)
+ finally:
+ shutil.rmtree(workspace)
+ os.chdir(oldcwd)
+
+ @unittest.skipIf(not hasattr(os, 'symlink'),
+ "symlinks unavailable on this platform")
+ def test_recursion_symlinks(self):
+ workspace = tempfile.mkdtemp()
+ self.addCleanup(shutil.rmtree, workspace)
+
+ # create two dirs
+ os.makedirs(os.path.join(workspace, 'dir1'))
+ os.makedirs(os.path.join(workspace, 'dir2'))
+
+ # create cyclical symlinks
+ os.symlink(os.path.join('..', 'dir1'),
+ os.path.join(workspace, 'dir2', 'ldir1'))
+ os.symlink(os.path.join('..', 'dir2'),
+ os.path.join(workspace, 'dir1', 'ldir2'))
+
+ # create one file in each dir
+ open(os.path.join(workspace, 'dir1', 'f1.txt'), 'a').close()
+ open(os.path.join(workspace, 'dir1', 'ldir2', 'f2.txt'), 'a').close()
+
+ data = []
+
+ def callback(rootdirectory, directory, subdirs, files):
+ for f in files:
+ data.append(f)
+
+ ManifestParser._walk_directories([workspace], callback)
+ self.assertEqual(sorted(data), ['f1.txt', 'f2.txt'])
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/manifestparser/tests/test_default_overrides.py b/testing/mozbase/manifestparser/tests/test_default_overrides.py
new file mode 100755
index 000000000..3341c4bd8
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/test_default_overrides.py
@@ -0,0 +1,115 @@
+#!/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/.
+
+import os
+import unittest
+from manifestparser import ManifestParser
+from manifestparser import combine_fields
+
+here = os.path.dirname(os.path.abspath(__file__))
+
+
+class TestDefaultSkipif(unittest.TestCase):
+ """Tests applying a skip-if condition in [DEFAULT] and || with the value for the test"""
+
+ def test_defaults(self):
+
+ default = os.path.join(here, 'default-skipif.ini')
+ parser = ManifestParser(manifests=(default,))
+ for test in parser.tests:
+ if test['name'] == 'test1':
+ self.assertEqual(test['skip-if'], "(os == 'win' && debug ) || (debug)")
+ elif test['name'] == 'test2':
+ self.assertEqual(test['skip-if'], "(os == 'win' && debug ) || (os == 'linux')")
+ elif test['name'] == 'test3':
+ self.assertEqual(test['skip-if'], "(os == 'win' && debug ) || (os == 'win')")
+ elif test['name'] == 'test4':
+ self.assertEqual(
+ test['skip-if'], "(os == 'win' && debug ) || (os == 'win' && debug)")
+ elif test['name'] == 'test5':
+ self.assertEqual(test['skip-if'], "os == 'win' && debug # a pesky comment")
+ elif test['name'] == 'test6':
+ self.assertEqual(test['skip-if'], "(os == 'win' && debug ) || (debug )")
+
+
+class TestDefaultSupportFiles(unittest.TestCase):
+ """Tests combining support-files field in [DEFAULT] with the value for a test"""
+
+ def test_defaults(self):
+
+ default = os.path.join(here, 'default-suppfiles.ini')
+ parser = ManifestParser(manifests=(default,))
+ expected_supp_files = {
+ 'test7': 'foo.js # a comment',
+ 'test8': 'foo.js bar.js ',
+ 'test9': 'foo.js # a comment',
+ }
+ for test in parser.tests:
+ expected = expected_supp_files[test['name']]
+ self.assertEqual(test['support-files'], expected)
+
+
+class TestOmitDefaults(unittest.TestCase):
+ """Tests passing omit-defaults prevents defaults from propagating to definitions.
+ """
+
+ def test_defaults(self):
+ manifests = (os.path.join(here, 'default-suppfiles.ini'),
+ os.path.join(here, 'default-skipif.ini'))
+ parser = ManifestParser(manifests=manifests, handle_defaults=False)
+ expected_supp_files = {
+ 'test8': 'bar.js # another comment',
+ }
+ expected_skip_ifs = {
+ 'test1': "debug",
+ 'test2': "os == 'linux'",
+ 'test3': "os == 'win'",
+ 'test4': "os == 'win' && debug",
+ 'test6': "debug # a second pesky comment",
+ }
+ for test in parser.tests:
+ for field, expectations in (('support-files', expected_supp_files),
+ ('skip-if', expected_skip_ifs)):
+ expected = expectations.get(test['name'])
+ if not expected:
+ self.assertNotIn(field, test)
+ else:
+ self.assertEqual(test[field], expected)
+
+ expected_defaults = {
+ os.path.join(here, 'default-suppfiles.ini'): {
+ "support-files": "foo.js # a comment",
+ },
+ os.path.join(here, 'default-skipif.ini'): {
+ "skip-if": "os == 'win' && debug # a pesky comment",
+ },
+ }
+ for path, defaults in expected_defaults.items():
+ self.assertIn(path, parser.manifest_defaults)
+ actual_defaults = parser.manifest_defaults[path]
+ for key, value in defaults.items():
+ self.assertIn(key, actual_defaults)
+ self.assertEqual(value, actual_defaults[key])
+
+
+class TestSubsuiteDefaults(unittest.TestCase):
+ """Test that subsuites are handled correctly when managing defaults
+ outside of the manifest parser."""
+ def test_subsuite_defaults(self):
+ manifest = os.path.join(here, 'default-subsuite.ini')
+ parser = ManifestParser(manifests=(manifest,), handle_defaults=False)
+ expected_subsuites = {
+ 'test1': 'baz',
+ 'test2': 'foo',
+ }
+ defaults = parser.manifest_defaults[manifest]
+ for test in parser.tests:
+ value = combine_fields(defaults, test)
+ self.assertEqual(expected_subsuites[value['name']],
+ value['subsuite'])
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/manifestparser/tests/test_expressionparser.py b/testing/mozbase/manifestparser/tests/test_expressionparser.py
new file mode 100755
index 000000000..dc3f2fd3d
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/test_expressionparser.py
@@ -0,0 +1,152 @@
+#!/usr/bin/env python
+
+import unittest
+from manifestparser import parse
+
+
+class ExpressionParserTest(unittest.TestCase):
+ """Test the conditional expression parser."""
+
+ def test_basic(self):
+
+ self.assertEqual(parse("1"), 1)
+ self.assertEqual(parse("100"), 100)
+ self.assertEqual(parse("true"), True)
+ self.assertEqual(parse("false"), False)
+ self.assertEqual('', parse('""'))
+ self.assertEqual(parse('"foo bar"'), 'foo bar')
+ self.assertEqual(parse("'foo bar'"), 'foo bar')
+ self.assertEqual(parse("foo", foo=1), 1)
+ self.assertEqual(parse("bar", bar=True), True)
+ self.assertEqual(parse("abc123", abc123="xyz"), 'xyz')
+
+ def test_equality(self):
+
+ self.assertTrue(parse("true == true"))
+ self.assertTrue(parse("false == false"))
+ self.assertTrue(parse("1 == 1"))
+ self.assertTrue(parse("100 == 100"))
+ self.assertTrue(parse('"some text" == "some text"'))
+ self.assertTrue(parse("true != false"))
+ self.assertTrue(parse("1 != 2"))
+ self.assertTrue(parse('"text" != "other text"'))
+ self.assertTrue(parse("foo == true", foo=True))
+ self.assertTrue(parse("foo == 1", foo=1))
+ self.assertTrue(parse('foo == "bar"', foo='bar'))
+ self.assertTrue(parse("foo == bar", foo=True, bar=True))
+ self.assertTrue(parse("true == foo", foo=True))
+ self.assertTrue(parse("foo != true", foo=False))
+ self.assertTrue(parse("foo != 2", foo=1))
+ self.assertTrue(parse('foo != "bar"', foo='abc'))
+ self.assertTrue(parse("foo != bar", foo=True, bar=False))
+ self.assertTrue(parse("true != foo", foo=False))
+ self.assertTrue(parse("!false"))
+
+ def test_conjunctures(self):
+ self.assertTrue(parse("true && true"))
+ self.assertTrue(parse("true || false"))
+ self.assertFalse(parse("false || false"))
+ self.assertFalse(parse("true && false"))
+ self.assertTrue(parse("true || false && false"))
+
+ def test_parentheses(self):
+ self.assertTrue(parse("(true)"))
+ self.assertEqual(parse("(10)"), 10)
+ self.assertEqual(parse('("foo")'), 'foo')
+ self.assertEqual(parse("(foo)", foo=1), 1)
+ self.assertTrue(parse("(true == true)"), True)
+ self.assertTrue(parse("(true != false)"))
+ self.assertTrue(parse("(true && true)"))
+ self.assertTrue(parse("(true || false)"))
+ self.assertTrue(parse("(true && true || false)"))
+ self.assertFalse(parse("(true || false) && false"))
+ self.assertTrue(parse("(true || false) && true"))
+ self.assertTrue(parse("true && (true || false)"))
+ self.assertTrue(parse("true && (true || false)"))
+ self.assertTrue(parse("(true && false) || (true && (true || false))"))
+
+ def test_comments(self):
+ # comments in expressions work accidentally, via an implementation
+ # detail - the '#' character doesn't match any of the regular
+ # expressions we specify as tokens, and thus are ignored.
+ # However, having explicit tests for them means that should the
+ # implementation ever change, comments continue to work, even if that
+ # means a new implementation must handle them explicitly.
+ self.assertTrue(parse("true == true # it does!"))
+ self.assertTrue(parse("false == false # it does"))
+ self.assertTrue(parse("false != true # it doesnt"))
+ self.assertTrue(parse('"string with #" == "string with #" # really, it does'))
+ self.assertTrue(parse('"string with #" != "string with # but not the same" # no match!'))
+
+ def test_not(self):
+ """
+ Test the ! operator.
+ """
+ self.assertTrue(parse("!false"))
+ self.assertTrue(parse("!(false)"))
+ self.assertFalse(parse("!true"))
+ self.assertFalse(parse("!(true)"))
+ self.assertTrue(parse("!true || true)"))
+ self.assertTrue(parse("true || !true)"))
+ self.assertFalse(parse("!true && true"))
+ self.assertFalse(parse("true && !true"))
+
+ def test_lesser_than(self):
+ """
+ Test the < operator.
+ """
+ self.assertTrue(parse("1 < 2"))
+ self.assertFalse(parse("3 < 2"))
+ self.assertTrue(parse("false || (1 < 2)"))
+ self.assertTrue(parse("1 < 2 && true"))
+ self.assertTrue(parse("true && 1 < 2"))
+ self.assertTrue(parse("!(5 < 1)"))
+ self.assertTrue(parse("'abc' < 'def'"))
+ self.assertFalse(parse("1 < 1"))
+ self.assertFalse(parse("'abc' < 'abc'"))
+
+ def test_greater_than(self):
+ """
+ Test the > operator.
+ """
+ self.assertTrue(parse("2 > 1"))
+ self.assertFalse(parse("2 > 3"))
+ self.assertTrue(parse("false || (2 > 1)"))
+ self.assertTrue(parse("2 > 1 && true"))
+ self.assertTrue(parse("true && 2 > 1"))
+ self.assertTrue(parse("!(1 > 5)"))
+ self.assertTrue(parse("'def' > 'abc'"))
+ self.assertFalse(parse("1 > 1"))
+ self.assertFalse(parse("'abc' > 'abc'"))
+
+ def test_lesser_or_equals_than(self):
+ """
+ Test the <= operator.
+ """
+ self.assertTrue(parse("1 <= 2"))
+ self.assertFalse(parse("3 <= 2"))
+ self.assertTrue(parse("false || (1 <= 2)"))
+ self.assertTrue(parse("1 < 2 && true"))
+ self.assertTrue(parse("true && 1 <= 2"))
+ self.assertTrue(parse("!(5 <= 1)"))
+ self.assertTrue(parse("'abc' <= 'def'"))
+ self.assertTrue(parse("1 <= 1"))
+ self.assertTrue(parse("'abc' <= 'abc'"))
+
+ def test_greater_or_equals_than(self):
+ """
+ Test the > operator.
+ """
+ self.assertTrue(parse("2 >= 1"))
+ self.assertFalse(parse("2 >= 3"))
+ self.assertTrue(parse("false || (2 >= 1)"))
+ self.assertTrue(parse("2 >= 1 && true"))
+ self.assertTrue(parse("true && 2 >= 1"))
+ self.assertTrue(parse("!(1 >= 5)"))
+ self.assertTrue(parse("'def' >= 'abc'"))
+ self.assertTrue(parse("1 >= 1"))
+ self.assertTrue(parse("'abc' >= 'abc'"))
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/manifestparser/tests/test_filters.py b/testing/mozbase/manifestparser/tests/test_filters.py
new file mode 100644
index 000000000..5b0772492
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/test_filters.py
@@ -0,0 +1,182 @@
+#!/usr/bin/env python
+# flake8: noqa
+
+from copy import deepcopy
+import os
+import unittest
+
+from manifestparser.filters import (
+ subsuite,
+ tags,
+ skip_if,
+ run_if,
+ fail_if,
+ enabled,
+ filterlist,
+)
+
+here = os.path.dirname(os.path.abspath(__file__))
+
+
+class FilterList(unittest.TestCase):
+ """Test filterlist datatype"""
+
+ def test_data_model(self):
+ foo = lambda x, y: x
+ bar = lambda x, y: x
+ baz = lambda x, y: x
+ fl = filterlist()
+
+ fl.extend([foo, bar])
+ self.assertEquals(len(fl), 2)
+ self.assertTrue(foo in fl)
+
+ fl.append(baz)
+ self.assertEquals(fl[2], baz)
+
+ fl.remove(baz)
+ self.assertFalse(baz in fl)
+
+ item = fl.pop()
+ self.assertEquals(item, bar)
+
+ self.assertEquals(fl.index(foo), 0)
+
+ del fl[0]
+ self.assertFalse(foo in fl)
+ with self.assertRaises(IndexError):
+ fl[0]
+
+ def test_add_non_callable_to_list(self):
+ fl = filterlist()
+ with self.assertRaises(TypeError):
+ fl.append('foo')
+
+ def test_add_duplicates_to_list(self):
+ foo = lambda x, y: x
+ bar = lambda x, y: x
+ sub = subsuite('foo')
+ fl = filterlist([foo, bar, sub])
+ self.assertEquals(len(fl), 3)
+ self.assertEquals(fl[0], foo)
+
+ with self.assertRaises(ValueError):
+ fl.append(foo)
+
+ with self.assertRaises(ValueError):
+ fl.append(subsuite('bar'))
+
+ def test_add_two_tags_filters(self):
+ tag1 = tags('foo')
+ tag2 = tags('bar')
+ fl = filterlist([tag1])
+
+ with self.assertRaises(ValueError):
+ fl.append(tag1)
+
+ fl.append(tag2)
+ self.assertEquals(len(fl), 2)
+
+ def test_filters_run_in_order(self):
+ a = lambda x, y: x
+ b = lambda x, y: x
+ c = lambda x, y: x
+ d = lambda x, y: x
+ e = lambda x, y: x
+ f = lambda x, y: x
+
+ fl = filterlist([a, b])
+ fl.append(c)
+ fl.extend([d, e])
+ fl += [f]
+ self.assertEquals([i for i in fl], [a, b, c, d, e, f])
+
+
+class BuiltinFilters(unittest.TestCase):
+ """Test the built-in filters"""
+
+ tests = (
+ {"name": "test0"},
+ {"name": "test1", "skip-if": "foo == 'bar'"},
+ {"name": "test2", "run-if": "foo == 'bar'"},
+ {"name": "test3", "fail-if": "foo == 'bar'"},
+ {"name": "test4", "disabled": "some reason"},
+ {"name": "test5", "subsuite": "baz"},
+ {"name": "test6", "subsuite": "baz,foo == 'bar'"},
+ {"name": "test7", "tags": "foo bar"},
+ )
+
+ def test_skip_if(self):
+ tests = deepcopy(self.tests)
+ tests = list(skip_if(tests, {}))
+ self.assertEquals(len(tests), len(self.tests))
+
+ tests = deepcopy(self.tests)
+ tests = list(skip_if(tests, {'foo': 'bar'}))
+ self.assertNotIn(self.tests[1], tests)
+
+ def test_run_if(self):
+ tests = deepcopy(self.tests)
+ tests = list(run_if(tests, {}))
+ self.assertNotIn(self.tests[2], tests)
+
+ tests = deepcopy(self.tests)
+ tests = list(run_if(tests, {'foo': 'bar'}))
+ self.assertEquals(len(tests), len(self.tests))
+
+ def test_fail_if(self):
+ tests = deepcopy(self.tests)
+ tests = list(fail_if(tests, {}))
+ self.assertNotIn('expected', tests[3])
+
+ tests = deepcopy(self.tests)
+ tests = list(fail_if(tests, {'foo': 'bar'}))
+ self.assertEquals(tests[3]['expected'], 'fail')
+
+ def test_enabled(self):
+ tests = deepcopy(self.tests)
+ tests = list(enabled(tests, {}))
+ self.assertNotIn(self.tests[4], tests)
+
+ def test_subsuite(self):
+ sub1 = subsuite()
+ sub2 = subsuite('baz')
+
+ tests = deepcopy(self.tests)
+ tests = list(sub1(tests, {}))
+ self.assertNotIn(self.tests[5], tests)
+ self.assertEquals(len(tests), len(self.tests) - 1)
+
+ tests = deepcopy(self.tests)
+ tests = list(sub2(tests, {}))
+ self.assertEquals(len(tests), 1)
+ self.assertIn(self.tests[5], tests)
+
+ def test_subsuite_condition(self):
+ sub1 = subsuite()
+ sub2 = subsuite('baz')
+
+ tests = deepcopy(self.tests)
+
+ tests = list(sub1(tests, {'foo': 'bar'}))
+ self.assertNotIn(self.tests[5], tests)
+ self.assertNotIn(self.tests[6], tests)
+
+ tests = deepcopy(self.tests)
+ tests = list(sub2(tests, {'foo': 'bar'}))
+ self.assertEquals(len(tests), 2)
+ self.assertEquals(tests[0]['name'], 'test5')
+ self.assertEquals(tests[1]['name'], 'test6')
+
+ def test_tags(self):
+ ftags1 = tags([])
+ ftags2 = tags(['bar', 'baz'])
+
+ tests = deepcopy(self.tests)
+ tests = list(ftags1(tests, {}))
+ self.assertEquals(len(tests), 0)
+
+ tests = deepcopy(self.tests)
+ tests = list(ftags2(tests, {}))
+ self.assertEquals(len(tests), 1)
+ self.assertIn(self.tests[7], tests)
diff --git a/testing/mozbase/manifestparser/tests/test_manifestparser.py b/testing/mozbase/manifestparser/tests/test_manifestparser.py
new file mode 100755
index 000000000..ca80911fb
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/test_manifestparser.py
@@ -0,0 +1,325 @@
+#!/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/.
+
+import os
+import shutil
+import tempfile
+import unittest
+from manifestparser import ManifestParser
+from StringIO import StringIO
+
+here = os.path.dirname(os.path.abspath(__file__))
+
+
+class TestManifestParser(unittest.TestCase):
+ """
+ Test the manifest parser
+
+ You must have manifestparser installed before running these tests.
+ Run ``python manifestparser.py setup develop`` with setuptools installed.
+ """
+
+ def test_sanity(self):
+ """Ensure basic parser is sane"""
+
+ parser = ManifestParser()
+ mozmill_example = os.path.join(here, 'mozmill-example.ini')
+ parser.read(mozmill_example)
+ tests = parser.tests
+ self.assertEqual(len(tests), len(file(mozmill_example).read().strip().splitlines()))
+
+ # Ensure that capitalization and order aren't an issue:
+ lines = ['[%s]' % test['name'] for test in tests]
+ self.assertEqual(lines, file(mozmill_example).read().strip().splitlines())
+
+ # Show how you select subsets of tests:
+ mozmill_restart_example = os.path.join(here, 'mozmill-restart-example.ini')
+ parser.read(mozmill_restart_example)
+ restart_tests = parser.get(type='restart')
+ self.assertTrue(len(restart_tests) < len(parser.tests))
+ self.assertEqual(len(restart_tests), len(parser.get(manifest=mozmill_restart_example)))
+ self.assertFalse([test for test in restart_tests
+ if test['manifest'] != os.path.join(here,
+ 'mozmill-restart-example.ini')])
+ self.assertEqual(parser.get('name', tags=['foo']),
+ ['restartTests/testExtensionInstallUninstall/test2.js',
+ 'restartTests/testExtensionInstallUninstall/test1.js'])
+ self.assertEqual(parser.get('name', foo='bar'),
+ ['restartTests/testExtensionInstallUninstall/test2.js'])
+
+ def test_include(self):
+ """Illustrate how include works"""
+
+ include_example = os.path.join(here, 'include-example.ini')
+ parser = ManifestParser(manifests=(include_example,))
+
+ # All of the tests should be included, in order:
+ self.assertEqual(parser.get('name'),
+ ['crash-handling', 'fleem', 'flowers'])
+ self.assertEqual([(test['name'], os.path.basename(test['manifest']))
+ for test in parser.tests],
+ [('crash-handling', 'bar.ini'),
+ ('fleem', 'include-example.ini'),
+ ('flowers', 'foo.ini')])
+
+ # The including manifest is always reported as a part of the generated test object.
+ self.assertTrue(all([t['ancestor-manifest'] == include_example
+ for t in parser.tests if t['name'] != 'fleem']))
+
+ # The manifests should be there too:
+ self.assertEqual(len(parser.manifests()), 3)
+
+ # We already have the root directory:
+ self.assertEqual(here, parser.rootdir)
+
+ # DEFAULT values should persist across includes, unless they're
+ # overwritten. In this example, include-example.ini sets foo=bar, but
+ # it's overridden to fleem in bar.ini
+ self.assertEqual(parser.get('name', foo='bar'),
+ ['fleem', 'flowers'])
+ self.assertEqual(parser.get('name', foo='fleem'),
+ ['crash-handling'])
+
+ # Passing parameters in the include section allows defining variables in
+ # the submodule scope:
+ self.assertEqual(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:
+ self.assertEqual(parser.get(name='flowers')[0]['blue'],
+ 'ocean')
+ self.assertEqual(parser.get(name='flowers')[0]['yellow'],
+ 'submarine')
+
+ # You can query multiple times if you need to:
+ flowers = parser.get(foo='bar')
+ self.assertEqual(len(flowers), 2)
+
+ # Using the inverse flag should invert the set of tests returned:
+ self.assertEqual(parser.get('name', inverse=True, tags=['red']),
+ ['crash-handling', 'fleem'])
+
+ # All of the included tests actually exist:
+ self.assertEqual([i['name'] for i in parser.missing()], [])
+
+ # Write the output to a manifest:
+ buffer = StringIO()
+ parser.write(fp=buffer, global_kwargs={'foo': 'bar'})
+ expected_output = """[DEFAULT]
+foo = bar
+
+[fleem]
+
+[include/flowers]
+blue = ocean
+red = roses
+yellow = submarine""" # noqa
+
+ self.assertEqual(buffer.getvalue().strip(),
+ expected_output)
+
+ def test_invalid_path(self):
+ """
+ Test invalid path should not throw when not strict
+ """
+ manifest = os.path.join(here, 'include-invalid.ini')
+ ManifestParser(manifests=(manifest,), strict=False)
+
+ def test_parent_inheritance(self):
+ """
+ Test parent manifest variable inheritance
+ Specifically tests that inherited variables from parent includes
+ properly propagate downstream
+ """
+ parent_example = os.path.join(here, 'parent', 'level_1', 'level_2',
+ 'level_3', 'level_3.ini')
+ parser = ManifestParser(manifests=(parent_example,))
+
+ # Parent manifest test should not be included
+ self.assertEqual(parser.get('name'),
+ ['test_3'])
+ self.assertEqual([(test['name'], os.path.basename(test['manifest']))
+ for test in parser.tests],
+ [('test_3', 'level_3.ini')])
+
+ # DEFAULT values should be the ones from level 1
+ self.assertEqual(parser.get('name', x='level_1'),
+ ['test_3'])
+
+ # Write the output to a manifest:
+ buffer = StringIO()
+ parser.write(fp=buffer, global_kwargs={'x': 'level_1'})
+ self.assertEqual(buffer.getvalue().strip(),
+ '[DEFAULT]\nx = level_1\n\n[test_3]')
+
+ def test_parent_defaults(self):
+ """
+ Test downstream variables should overwrite upstream variables
+ """
+ parent_example = os.path.join(here, 'parent', 'level_1', 'level_2',
+ 'level_3', 'level_3_default.ini')
+ parser = ManifestParser(manifests=(parent_example,))
+
+ # Parent manifest test should not be included
+ self.assertEqual(parser.get('name'),
+ ['test_3'])
+ self.assertEqual([(test['name'], os.path.basename(test['manifest']))
+ for test in parser.tests],
+ [('test_3', 'level_3_default.ini')])
+
+ # DEFAULT values should be the ones from level 3
+ self.assertEqual(parser.get('name', x='level_3'),
+ ['test_3'])
+
+ # Write the output to a manifest:
+ buffer = StringIO()
+ parser.write(fp=buffer, global_kwargs={'x': 'level_3'})
+ self.assertEqual(buffer.getvalue().strip(),
+ '[DEFAULT]\nx = level_3\n\n[test_3]')
+
+ def test_parent_defaults_include(self):
+ parent_example = os.path.join(here, 'parent', 'include', 'manifest.ini')
+ parser = ManifestParser(manifests=(parent_example,))
+
+ # global defaults should inherit all includes
+ self.assertEqual(parser.get('name', top='data'),
+ ['testFirst.js', 'testSecond.js'])
+
+ # include specific defaults should only inherit the actual include
+ self.assertEqual(parser.get('name', disabled='YES'),
+ ['testFirst.js'])
+ self.assertEqual(parser.get('name', disabled='NO'),
+ ['testSecond.js'])
+
+ def test_server_root(self):
+ """
+ Test server_root properly expands as an absolute path
+ """
+ server_example = os.path.join(here, 'parent', 'level_1', 'level_2',
+ 'level_3', 'level_3_server-root.ini')
+ parser = ManifestParser(manifests=(server_example,))
+
+ # A regular variable will inherit its value directly
+ self.assertEqual(parser.get('name', **{'other-root': '../root'}),
+ ['test_3'])
+
+ # server-root will expand its value as an absolute path
+ # we will not find anything for the original value
+ self.assertEqual(parser.get('name', **{'server-root': '../root'}), [])
+
+ # check that the path has expanded
+ self.assertEqual(parser.get('server-root')[0],
+ os.path.join(here, 'parent', 'root'))
+
+ def test_copy(self):
+ """Test our ability to copy a set of manifests"""
+
+ tempdir = tempfile.mkdtemp()
+ include_example = os.path.join(here, 'include-example.ini')
+ manifest = ManifestParser(manifests=(include_example,))
+ manifest.copy(tempdir)
+ self.assertEqual(sorted(os.listdir(tempdir)),
+ ['fleem', 'include', 'include-example.ini'])
+ self.assertEqual(sorted(os.listdir(os.path.join(tempdir, 'include'))),
+ ['bar.ini', 'crash-handling', 'flowers', 'foo.ini'])
+ from_manifest = ManifestParser(manifests=(include_example,))
+ to_manifest = os.path.join(tempdir, 'include-example.ini')
+ to_manifest = ManifestParser(manifests=(to_manifest,))
+ self.assertEqual(to_manifest.get('name'), from_manifest.get('name'))
+ shutil.rmtree(tempdir)
+
+ def test_path_override(self):
+ """You can override the path in the section too.
+ This shows that you can use a relative path"""
+ path_example = os.path.join(here, 'path-example.ini')
+ manifest = ManifestParser(manifests=(path_example,))
+ self.assertEqual(manifest.tests[0]['path'],
+ os.path.join(here, 'fleem'))
+
+ def test_relative_path(self):
+ """
+ Relative test paths are correctly calculated.
+ """
+ relative_path = os.path.join(here, 'relative-path.ini')
+ manifest = ManifestParser(manifests=(relative_path,))
+ self.assertEqual(manifest.tests[0]['path'],
+ os.path.join(os.path.dirname(here), 'fleem'))
+ self.assertEqual(manifest.tests[0]['relpath'],
+ os.path.join('..', 'fleem'))
+ self.assertEqual(manifest.tests[1]['relpath'],
+ os.path.join('..', 'testsSIBLING', 'example'))
+
+ def test_path_from_fd(self):
+ """
+ Test paths are left untouched when manifest is a file-like object.
+ """
+ fp = StringIO("[section]\npath=fleem")
+ manifest = ManifestParser(manifests=(fp,))
+ self.assertEqual(manifest.tests[0]['path'], 'fleem')
+ self.assertEqual(manifest.tests[0]['relpath'], 'fleem')
+ self.assertEqual(manifest.tests[0]['manifest'], None)
+
+ def test_comments(self):
+ """
+ ensure comments work, see
+ https://bugzilla.mozilla.org/show_bug.cgi?id=813674
+ """
+ comment_example = os.path.join(here, 'comment-example.ini')
+ manifest = ManifestParser(manifests=(comment_example,))
+ self.assertEqual(len(manifest.tests), 8)
+ names = [i['name'] for i in manifest.tests]
+ self.assertFalse('test_0202_app_launch_apply_update_dirlocked.js' in names)
+
+ def test_verifyDirectory(self):
+
+ directory = os.path.join(here, 'verifyDirectory')
+
+ # correct manifest
+ manifest_path = os.path.join(directory, 'verifyDirectory.ini')
+ manifest = ManifestParser(manifests=(manifest_path,))
+ missing = manifest.verifyDirectory(directory, extensions=('.js',))
+ self.assertEqual(missing, (set(), set()))
+
+ # manifest is missing test_1.js
+ test_1 = os.path.join(directory, 'test_1.js')
+ manifest_path = os.path.join(directory, 'verifyDirectory_incomplete.ini')
+ manifest = ManifestParser(manifests=(manifest_path,))
+ missing = manifest.verifyDirectory(directory, extensions=('.js',))
+ self.assertEqual(missing, (set(), set([test_1])))
+
+ # filesystem is missing test_notappearinginthisfilm.js
+ missing_test = os.path.join(directory, 'test_notappearinginthisfilm.js')
+ manifest_path = os.path.join(directory, 'verifyDirectory_toocomplete.ini')
+ manifest = ManifestParser(manifests=(manifest_path,))
+ missing = manifest.verifyDirectory(directory, extensions=('.js',))
+ self.assertEqual(missing, (set([missing_test]), set()))
+
+ def test_just_defaults(self):
+ """Ensure a manifest with just a DEFAULT section exposes that data."""
+
+ parser = ManifestParser()
+ manifest = os.path.join(here, 'just-defaults.ini')
+ parser.read(manifest)
+ self.assertEqual(len(parser.tests), 0)
+ self.assertTrue(manifest in parser.manifest_defaults)
+ self.assertEquals(parser.manifest_defaults[manifest]['foo'], 'bar')
+
+ def test_manifest_list(self):
+ """
+ Ensure a manifest with just a DEFAULT section still returns
+ itself from the manifests() method.
+ """
+
+ parser = ManifestParser()
+ manifest = os.path.join(here, 'no-tests.ini')
+ parser.read(manifest)
+ self.assertEqual(len(parser.tests), 0)
+ self.assertTrue(len(parser.manifests()) == 1)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/manifestparser/tests/test_read_ini.py b/testing/mozbase/manifestparser/tests/test_read_ini.py
new file mode 100755
index 000000000..df4a8973b
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/test_read_ini.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+
+"""
+test .ini parsing
+
+ensure our .ini parser is doing what we want; to be deprecated for
+python's standard ConfigParser when 2.7 is reality so OrderedDict
+is the default:
+
+http://docs.python.org/2/library/configparser.html
+"""
+
+import unittest
+from manifestparser import read_ini
+from ConfigParser import ConfigParser
+from StringIO import StringIO
+
+
+class IniParserTest(unittest.TestCase):
+
+ def test_inline_comments(self):
+ """
+ We have no inline comments; so we're testing to ensure we don't:
+ https://bugzilla.mozilla.org/show_bug.cgi?id=855288
+ """
+
+ # test '#' inline comments (really, the lack thereof)
+ string = """[test_felinicity.py]
+kittens = true # This test requires kittens
+"""
+ buffer = StringIO()
+ buffer.write(string)
+ buffer.seek(0)
+ result = read_ini(buffer)[0][1]['kittens']
+ self.assertEqual(result, "true # This test requires kittens")
+
+ # compare this to ConfigParser
+ # python 2.7 ConfigParser does not support '#' as an
+ # inline comment delimeter (for "backwards compatability"):
+ # http://docs.python.org/2/library/configparser.html
+ buffer.seek(0)
+ parser = ConfigParser()
+ parser.readfp(buffer)
+ control = parser.get('test_felinicity.py', 'kittens')
+ self.assertEqual(result, control)
+
+ # test ';' inline comments (really, the lack thereof)
+ string = string.replace('#', ';')
+ buffer = StringIO()
+ buffer.write(string)
+ buffer.seek(0)
+ result = read_ini(buffer)[0][1]['kittens']
+ self.assertEqual(result, "true ; This test requires kittens")
+
+ # compare this to ConfigParser
+ # python 2.7 ConfigParser *does* support ';' as an
+ # inline comment delimeter (ibid).
+ # Python 3.x configparser, OTOH, does not support
+ # inline-comments by default. It does support their specification,
+ # though they are weakly discouraged:
+ # http://docs.python.org/dev/library/configparser.html
+ buffer.seek(0)
+ parser = ConfigParser()
+ parser.readfp(buffer)
+ control = parser.get('test_felinicity.py', 'kittens')
+ self.assertNotEqual(result, control)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/manifestparser/tests/test_testmanifest.py b/testing/mozbase/manifestparser/tests/test_testmanifest.py
new file mode 100644
index 000000000..5f79dd48a
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/test_testmanifest.py
@@ -0,0 +1,122 @@
+#!/usr/bin/env python
+
+import os
+import shutil
+import tempfile
+import unittest
+
+from manifestparser import TestManifest, ParseError
+from manifestparser.filters import subsuite
+
+here = os.path.dirname(os.path.abspath(__file__))
+
+
+class TestTestManifest(unittest.TestCase):
+ """Test the Test Manifest"""
+
+ def test_testmanifest(self):
+ # Test filtering based on platform:
+ filter_example = os.path.join(here, 'filter-example.ini')
+ manifest = TestManifest(manifests=(filter_example,), strict=False)
+ self.assertEqual([i['name'] for i in manifest.active_tests(os='win', disabled=False,
+ exists=False)],
+ ['windowstest', 'fleem'])
+ self.assertEqual([i['name'] for i in manifest.active_tests(os='linux', disabled=False,
+ exists=False)],
+ ['fleem', 'linuxtest'])
+
+ # Look for existing tests. There is only one:
+ self.assertEqual([i['name'] for i in manifest.active_tests()],
+ ['fleem'])
+
+ # You should be able to expect failures:
+ last = manifest.active_tests(exists=False, toolkit='gtk2')[-1]
+ self.assertEqual(last['name'], 'linuxtest')
+ self.assertEqual(last['expected'], 'pass')
+ last = manifest.active_tests(exists=False, toolkit='cocoa')[-1]
+ self.assertEqual(last['expected'], 'fail')
+
+ def test_missing_paths(self):
+ """
+ Test paths that don't exist raise an exception in strict mode.
+ """
+ tempdir = tempfile.mkdtemp()
+
+ missing_path = os.path.join(here, 'missing-path.ini')
+ manifest = TestManifest(manifests=(missing_path,), strict=True)
+ self.assertRaises(IOError, manifest.active_tests)
+ self.assertRaises(IOError, manifest.copy, tempdir)
+ self.assertRaises(IOError, manifest.update, tempdir)
+
+ shutil.rmtree(tempdir)
+
+ def test_comments(self):
+ """
+ ensure comments work, see
+ https://bugzilla.mozilla.org/show_bug.cgi?id=813674
+ """
+ comment_example = os.path.join(here, 'comment-example.ini')
+ manifest = TestManifest(manifests=(comment_example,))
+ self.assertEqual(len(manifest.tests), 8)
+ names = [i['name'] for i in manifest.tests]
+ self.assertFalse('test_0202_app_launch_apply_update_dirlocked.js' in names)
+
+ def test_manifest_subsuites(self):
+ """
+ test subsuites and conditional subsuites
+ """
+ relative_path = os.path.join(here, 'subsuite.ini')
+ manifest = TestManifest(manifests=(relative_path,))
+ info = {'foo': 'bar'}
+
+ # 6 tests total
+ tests = manifest.active_tests(exists=False, **info)
+ self.assertEquals(len(tests), 6)
+
+ # only 3 tests for subsuite bar when foo==bar
+ tests = manifest.active_tests(exists=False,
+ filters=[subsuite('bar')],
+ **info)
+ self.assertEquals(len(tests), 3)
+
+ # only 1 test for subsuite baz, regardless of conditions
+ other = {'something': 'else'}
+ tests = manifest.active_tests(exists=False,
+ filters=[subsuite('baz')],
+ **info)
+ self.assertEquals(len(tests), 1)
+ tests = manifest.active_tests(exists=False,
+ filters=[subsuite('baz')],
+ **other)
+ self.assertEquals(len(tests), 1)
+
+ # 4 tests match when the condition doesn't match (all tests except
+ # the unconditional subsuite)
+ info = {'foo': 'blah'}
+ tests = manifest.active_tests(exists=False,
+ filters=[subsuite()],
+ **info)
+ self.assertEquals(len(tests), 5)
+
+ # test for illegal subsuite value
+ manifest.tests[0]['subsuite'] = 'subsuite=bar,foo=="bar",type="nothing"'
+ with self.assertRaises(ParseError):
+ manifest.active_tests(exists=False,
+ filters=[subsuite('foo')],
+ **info)
+
+ def test_none_and_empty_manifest(self):
+ """
+ Test TestManifest for None and empty manifest, see
+ https://bugzilla.mozilla.org/show_bug.cgi?id=1087682
+ """
+ none_manifest = TestManifest(manifests=None, strict=False)
+ self.assertEqual(len(none_manifest.test_paths()), 0)
+ self.assertEqual(len(none_manifest.active_tests()), 0)
+
+ empty_manifest = TestManifest(manifests=[], strict=False)
+ self.assertEqual(len(empty_manifest.test_paths()), 0)
+ self.assertEqual(len(empty_manifest.active_tests()), 0)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/manifestparser/tests/verifyDirectory/subdir/manifest.ini b/testing/mozbase/manifestparser/tests/verifyDirectory/subdir/manifest.ini
new file mode 100644
index 000000000..509ebd62e
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/verifyDirectory/subdir/manifest.ini
@@ -0,0 +1 @@
+[test_sub.js]
diff --git a/testing/mozbase/manifestparser/tests/verifyDirectory/subdir/test_sub.js b/testing/mozbase/manifestparser/tests/verifyDirectory/subdir/test_sub.js
new file mode 100644
index 000000000..df48720d9
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/verifyDirectory/subdir/test_sub.js
@@ -0,0 +1 @@
+// test_sub.js
diff --git a/testing/mozbase/manifestparser/tests/verifyDirectory/test_1.js b/testing/mozbase/manifestparser/tests/verifyDirectory/test_1.js
new file mode 100644
index 000000000..c5a966f46
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/verifyDirectory/test_1.js
@@ -0,0 +1 @@
+// test_1.js
diff --git a/testing/mozbase/manifestparser/tests/verifyDirectory/test_2.js b/testing/mozbase/manifestparser/tests/verifyDirectory/test_2.js
new file mode 100644
index 000000000..d8648599c
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/verifyDirectory/test_2.js
@@ -0,0 +1 @@
+// test_2.js
diff --git a/testing/mozbase/manifestparser/tests/verifyDirectory/test_3.js b/testing/mozbase/manifestparser/tests/verifyDirectory/test_3.js
new file mode 100644
index 000000000..794bc2c34
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/verifyDirectory/test_3.js
@@ -0,0 +1 @@
+// test_3.js
diff --git a/testing/mozbase/manifestparser/tests/verifyDirectory/verifyDirectory.ini b/testing/mozbase/manifestparser/tests/verifyDirectory/verifyDirectory.ini
new file mode 100644
index 000000000..10e0c79c8
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/verifyDirectory/verifyDirectory.ini
@@ -0,0 +1,4 @@
+[test_1.js]
+[test_2.js]
+[test_3.js]
+[include:subdir/manifest.ini]
diff --git a/testing/mozbase/manifestparser/tests/verifyDirectory/verifyDirectory_incomplete.ini b/testing/mozbase/manifestparser/tests/verifyDirectory/verifyDirectory_incomplete.ini
new file mode 100644
index 000000000..cde526acf
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/verifyDirectory/verifyDirectory_incomplete.ini
@@ -0,0 +1,3 @@
+[test_2.js]
+[test_3.js]
+[include:subdir/manifest.ini]
diff --git a/testing/mozbase/manifestparser/tests/verifyDirectory/verifyDirectory_toocomplete.ini b/testing/mozbase/manifestparser/tests/verifyDirectory/verifyDirectory_toocomplete.ini
new file mode 100644
index 000000000..88994ae26
--- /dev/null
+++ b/testing/mozbase/manifestparser/tests/verifyDirectory/verifyDirectory_toocomplete.ini
@@ -0,0 +1,5 @@
+[test_1.js]
+[test_2.js]
+[test_3.js]
+[test_notappearinginthisfilm.js]
+[include:subdir/manifest.ini]