Bug 993478 - Let a user select docroot for the webserver, r=jgriffin
authorMalini Das <mdas@mozilla.com>
Thu, 10 Apr 2014 13:02:23 -0400
changeset 179458 993c3b5ff4596e3ac7425c8e723f5eb97bc17c50
parent 179457 ff84ce7e5f85065cd9d40a81748aa538edd61173
child 179459 800df0af425160dd45f7d9cbf63796b7b6a4c633
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersjgriffin
bugs993478
milestone31.0a1
Bug 993478 - Let a user select docroot for the webserver, r=jgriffin
testing/marionette/client/MANIFEST.in
testing/marionette/client/marionette/runner/base.py
--- a/testing/marionette/client/MANIFEST.in
+++ b/testing/marionette/client/MANIFEST.in
@@ -1,4 +1,6 @@
 recursive-include marionette/touch *.js
+recursive-include marionette/www *
+recursive-include marionette/chrome *
 recursive-include marionette/runner/mixins/resources *
 exclude MANIFEST.in
 include requirements.txt
--- a/testing/marionette/client/marionette/runner/base.py
+++ b/testing/marionette/client/marionette/runner/base.py
@@ -470,16 +470,20 @@ class BaseMarionetteOptions(OptionParser
         self.add_option('--this-chunk',
                         dest='this_chunk',
                         type=int,
                         help='which chunk to run')
         self.add_option('--sources',
                         dest='sources',
                         action='store',
                         help='path to sources.xml (Firefox OS only)')
+        self.add_option('--server-root',
+                        dest='server_root',
+                        action='store',
+                        help='sets the web server\'s root directory to the given path')
 
     def parse_args(self, args=None, values=None):
         options, tests = OptionParser.parse_args(self, args, values)
         for handler in self.parse_args_handlers:
             handler(options, tests, args, values)
 
         return (options, tests)
 
@@ -540,17 +544,18 @@ class BaseMarionetteTestRunner(object):
 
     def __init__(self, address=None, emulator=None, emulatorBinary=None,
                  emulatorImg=None, emulator_res='480x800', homedir=None,
                  app=None, app_args=None, bin=None, profile=None, autolog=False,
                  revision=None, logger=None, testgroup="marionette", noWindow=False,
                  logcat_dir=None, xml_output=None, repeat=0, gecko_path=None,
                  testvars=None, tree=None, type=None, device_serial=None,
                  symbols_path=None, timeout=None, es_servers=None, shuffle=False,
-                 sdcard=None, this_chunk=1, total_chunks=1, sources=None, **kwargs):
+                 sdcard=None, this_chunk=1, total_chunks=1, sources=None, server_root=None,
+                 **kwargs):
         self.address = address
         self.emulator = emulator
         self.emulatorBinary = emulatorBinary
         self.emulatorImg = emulatorImg
         self.emulator_res = emulator_res
         self.homedir = homedir
         self.app = app
         self.app_args = app_args or []
@@ -576,16 +581,17 @@ class BaseMarionetteTestRunner(object):
         self.timeout = timeout
         self._device = None
         self._capabilities = None
         self._appName = None
         self.es_servers = es_servers
         self.shuffle = shuffle
         self.sdcard = sdcard
         self.sources = sources
+        self.server_root = server_root
         self.this_chunk = this_chunk
         self.total_chunks = total_chunks
         self.mixin_run_tests = []
         self.manifest_skipped_tests = []
         self.tests = []
 
         if testvars:
             if not os.path.exists(testvars):
@@ -649,19 +655,22 @@ class BaseMarionetteTestRunner(object):
         self.failed = 0
         self.todo = 0
         self.failures = []
 
     def start_httpd(self, need_external_ip):
         host = "127.0.0.1"
         if need_external_ip:
             host = moznetwork.get_ip()
+        docroot = self.server_root or os.path.join(os.path.dirname(os.path.dirname(__file__)), 'www')
+        if not os.path.isdir(docroot):
+            raise Exception("Server root %s is not a valid path" % docroot)
         self.httpd = MozHttpd(host=host,
                               port=0,
-                              docroot=os.path.join(os.path.dirname(os.path.dirname(__file__)), 'www'))
+                              docroot=docroot)
         self.httpd.start()
         self.marionette.baseurl = 'http://%s:%d/' % (host, self.httpd.httpd.server_port)
         self.logger.info('running webserver on %s' % self.marionette.baseurl)
 
 
     def _build_kwargs(self):
         kwargs = {
             'device_serial': self.device_serial,