5b4556a3a1c34ff586a094d123b2ad8ab49c5dbb
[WebKit-https.git] / Tools / BuildSlaveSupport / build.webkit.org-config / wkbuild_unittest.py
1 # Copyright (C) 2010 Apple Inc. All rights reserved.
2 #
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions
5 # are met:
6 # 1.  Redistributions of source code must retain the above copyright
7 #     notice, this list of conditions and the following disclaimer.
8 # 2.  Redistributions in binary form must reproduce the above copyright
9 #     notice, this list of conditions and the following disclaimer in the
10 #     documentation and/or other materials provided with the distribution.
11 #
12 # THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
13 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
14 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
15 # DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
16 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
18 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
19 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
20 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
21 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
23 import unittest2 as unittest
24
25 import wkbuild
26
27
28 class ShouldBuildTest(unittest.TestCase):
29     _should_build_tests = [
30         (["ChangeLog", "Source/WebCore/ChangeLog", "Source/WebKit2/ChangeLog-2011-02-11"], []),
31         (["GNUmakefile.am", "Source/WebCore/GNUmakefile.am"], ["gtk"]),
32         (["Websites/bugs.webkit.org/foo", "Source/WebCore/bar"], ["*"]),
33         (["Websites/bugs.webkit.org/foo"], []),
34         (["Source/JavaScriptCore/JavaScriptCore.xcodeproj/foo"], ["mac-leopard", "mac-lion",  "mac-mountainlion", "mac-snowleopard"]),
35         (["Source/JavaScriptCore/JavaScriptCore.vcproj/foo", "Source/WebKit2/win/WebKit2.vcproj", "Source/WebKit/win/WebKit.sln", "Tools/WebKitTestRunner/Configurations/WebKitTestRunnerCommon.vsprops"], ["win"]),
36         (["LayoutTests/platform/mac/foo", "Source/WebCore/bar"], ["*"]),
37         (["LayoutTests/foo"], ["*"]),
38         (["LayoutTests/canvas/philip/tests/size.attributes.parse.exp-expected.txt", "LayoutTests/canvas/philip/tests/size.attributes.parse.exp.html"], ["*"]),
39         (["LayoutTests/platform/chromium-linux/foo"], ["chromium-linux"]),
40         (["LayoutTests/platform/chromium-win/fast/compact/001-expected.txt"], ["chromium-win"]),
41         (["LayoutTests/platform/mac-leopard/foo"], ["mac-leopard"]),
42         (["LayoutTests/platform/mac-lion/foo"], ["mac-leopard", "mac-lion", "mac-snowleopard", "win"]),
43         (["LayoutTests/platform/mac-snowleopard/foo"], ["mac-leopard", "mac-snowleopard"]),
44         (["LayoutTests/platform/mac-wk2/Skipped"], ["mac-lion",  "mac-mountainlion", "mac-snowleopard", "win"]),
45         (["LayoutTests/platform/mac/foo"], ["mac-leopard", "mac-lion", "mac-mountainlion", "mac-snowleopard", "win"]),
46         (["LayoutTests/platform/win-xp/foo"], ["win"]),
47         (["LayoutTests/platform/win-wk2/foo"], ["win"]),
48         (["LayoutTests/platform/win/foo"], ["win"]),
49         (["Source/WebCore.exp.in", "Source/WebKit/mac/WebKit.exp"], ["mac-leopard", "mac-lion",  "mac-mountainlion", "mac-snowleopard"]),
50         (["Source/WebCore/mac/foo"], ["chromium-mac", "mac-leopard", "mac-lion",  "mac-mountainlion", "mac-snowleopard"]),
51         (["Source/WebCore/win/foo"], ["chromium-win", "win"]),
52         (["Source/WebCore/platform/graphics/gpu/foo"], ["mac-leopard", "mac-lion",  "mac-mountainlion", "mac-snowleopard"]),
53         (["Source/WebCore/platform/wx/wxcode/win/foo"], []),
54         (["Source/WebCore/rendering/RenderThemeMac.mm", "Source/WebCore/rendering/RenderThemeMac.h"], ["mac-leopard", "mac-lion",  "mac-mountainlion", "mac-snowleopard"]),
55         (["Source/WebCore/rendering/RenderThemeChromiumDefault.h"], ["chromium-linux"]),
56         (["Source/WebCore/rendering/RenderThemeWinCE.h"], []),
57         (["Tools/BuildSlaveSupport/build.webkit.org-config/public_html/LeaksViewer/LeaksViewer.js"], []),
58     ]
59
60     def test_should_build(self):
61         for files, platforms in self._should_build_tests:
62             # FIXME: We should test more platforms here once
63             # wkbuild._should_file_trigger_build is implemented for them.
64             for platform in ["mac-leopard", "mac-lion",  "mac-mountainlion", "mac-snowleopard", "win"]:
65                 should_build = platform in platforms or "*" in platforms
66                 self.assertEqual(wkbuild.should_build(platform, files), should_build, "%s should%s have built but did%s (files: %s)" % (platform, "" if should_build else "n't", "n't" if should_build else "", str(files)))
67
68 # FIXME: We should run this file as part of test-rm .
69 # Unfortunately test-rm  currently requires that unittests
70 # be located in a directory with a valid module name.
71 # 'build.webkit.org-config' is not a valid module name (due to '.' and '-')
72 # so for now this is a stand-alone test harness.
73 if __name__ == '__main__':
74     unittest.main()