Title: [230969] trunk/Tools
Revision
230969
Author
[email protected]
Date
2018-04-24 13:15:02 -0700 (Tue, 24 Apr 2018)

Log Message

[build.webkit.org] unit-tests fail when passwords.json is missing
https://bugs.webkit.org/show_bug.cgi?id=180390

Reviewed by Carlos Alberto Lopez Perez.

* BuildSlaveSupport/build.webkit.org-config/loadConfig.py:
(loadBuilderConfig): Add support for test_mode. Load mock passwords in test_mode.
* BuildSlaveSupport/build.webkit.org-config/steps_unittest.py:
(BuildBotConfigLoader._add_dependant_modules_to_sys_modules): Call _add_webkitpy_to_sys_path as well.
(BuildBotConfigLoader._mock_open): Deleted.
(BuildBotConfigLoader.load_config): Deleted.

Modified Paths

Diff

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/loadConfig.py (230968 => 230969)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/loadConfig.py	2018-04-24 19:51:22 UTC (rev 230968)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/loadConfig.py	2018-04-24 20:15:02 UTC (rev 230969)
@@ -33,6 +33,7 @@
 import operator
 
 from committer_auth import CommitterAuth
+import make_passwords_json
 import wkbuild
 
 trunk_filter = ChangeFilter(branch=["trunk", None])
@@ -42,9 +43,12 @@
     return max(requests, key=operator.attrgetter("submittedAt"))
 
 
-def loadBuilderConfig(c):
+def loadBuilderConfig(c, test_mode_is_enabled=False):
     # FIXME: These file handles are leaked.
-    passwords = json.load(open('passwords.json'))
+    if test_mode_is_enabled:
+        passwords = make_passwords_json.create_mock_slave_passwords_dict()
+    else:
+        passwords = json.load(open('passwords.json'))
     config = json.load(open('config.json'))
 
     c['slaves'] = [BuildSlave(slave['name'], passwords[slave['name']], max_builds=1) for slave in config['slaves']]

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/steps_unittest.py (230968 => 230969)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/steps_unittest.py	2018-04-24 19:51:22 UTC (rev 230968)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/steps_unittest.py	2018-04-24 20:15:02 UTC (rev 230969)
@@ -23,31 +23,12 @@
         scripts_dir = os.path.join(webkit_tools_dir, 'Scripts')
         sys.path.append(scripts_dir)
 
-    def _mock_open(self, filename):
-        if filename == 'passwords.json':
-            return StringIO.StringIO(json.dumps(make_passwords_json.create_mock_slave_passwords_dict()))
-        return __builtins__.open(filename)
-
-    def _add_dependant_modules_to_sys_modules(self):
+    def _add_dependent_modules_to_sys_modules(self):
+        self._add_webkitpy_to_sys_path()
         from webkitpy.thirdparty.autoinstalled import buildbot
         sys.modules['buildbot'] = buildbot
 
-    def load_config(self, master_cfg_path):
-        # Before we can use webkitpy.thirdparty, we need to fix our path to include webkitpy.
-        # FIXME: If we're ever run by test-webkitpy we won't need this step.
-        self._add_webkitpy_to_sys_path()
-        # master.cfg expects the buildbot module to be in sys.path.
-        self._add_dependant_modules_to_sys_modules()
 
-        # master.cfg expects a passwords.json file which is not checked in.  Fake it by mocking open().
-        globals()['open'] = self._mock_open
-        # Because the master_cfg_path may have '.' in its name, we can't just use import, we have to use execfile.
-        # We pass globals() as both the globals and locals to mimic exectuting in the global scope, so
-        # that globals defined in master.cfg will be global to this file too.
-        execfile(master_cfg_path, globals(), globals())
-        globals()['open'] = __builtins__.open  # Stop mocking open().
-
-
 class RunWebKitTestsTest(unittest.TestCase):
     def test_nrwt_leaks_parsing(self):
         run_webkit_tests = RunWebKitTests()  # pylint is confused by the way we import the module ... pylint: disable-msg=E0602
@@ -551,7 +532,10 @@
 # 'build.webkit.org-config' is not a valid module name (due to '.' and '-')
 # so for now this is a stand-alone test harness.
 if __name__ == '__main__':
-    BuildBotConfigLoader().load_config('master.cfg')
+    BuildBotConfigLoader()._add_dependent_modules_to_sys_modules()
+    from loadConfig import *
+    c = {}
+    loadBuilderConfig(c, test_mode_is_enabled=True)
     BuildStepsConstructorTest.generateTests()
     BuildStepsTest.generateTests()
     unittest.main()

Modified: trunk/Tools/ChangeLog (230968 => 230969)


--- trunk/Tools/ChangeLog	2018-04-24 19:51:22 UTC (rev 230968)
+++ trunk/Tools/ChangeLog	2018-04-24 20:15:02 UTC (rev 230969)
@@ -1,3 +1,17 @@
+2018-04-24  Aakash Jain  <[email protected]>
+
+        [build.webkit.org] unit-tests fail when passwords.json is missing
+        https://bugs.webkit.org/show_bug.cgi?id=180390
+
+        Reviewed by Carlos Alberto Lopez Perez.
+
+        * BuildSlaveSupport/build.webkit.org-config/loadConfig.py:
+        (loadBuilderConfig): Add support for test_mode. Load mock passwords in test_mode.
+        * BuildSlaveSupport/build.webkit.org-config/steps_unittest.py:
+        (BuildBotConfigLoader._add_dependant_modules_to_sys_modules): Call _add_webkitpy_to_sys_path as well.
+        (BuildBotConfigLoader._mock_open): Deleted.
+        (BuildBotConfigLoader.load_config): Deleted.
+
 2018-04-24  John Wilander  <[email protected]>
 
         From-Origin: Support for 'same' and 'same-site' response header, nested frame origin check
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to