From 386c1343441dd466168d7002b97fc7be957df871 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 21 Aug 2014 12:26:22 +0800 Subject: [PATCH] Wrap Selenium in xvfb-run if requested --- mdk/commands/behat.py | 24 ++++++++++++++++++++++++ mdk/config-dist.json | 6 ++++++ 2 files changed, 30 insertions(+) diff --git a/mdk/commands/behat.py b/mdk/commands/behat.py index 8bf8c9fe..c3033196 100644 --- a/mdk/commands/behat.py +++ b/mdk/commands/behat.py @@ -112,6 +112,22 @@ class BehatCommand(Command): 'help': 'outputs the output from selenium in the same window' } ), + ( + ['-x', '--xvfb'], + { + 'action': 'store_true', + 'dest': 'xvfb', + 'help': 'Use XVFB when starting selenium' + } + ), + ( + ['-X', '--no-xvfb'], + { + 'action': 'store_true', + 'dest': 'noxvfb', + 'help': 'Do not use XVFB when starting selenium' + } + ), ( ['name'], { @@ -223,6 +239,14 @@ def run(self, args): if seleniumPath: seleniumCommand = '%s -jar %s' % (self.C.get('java'), seleniumPath) + usexvfb = ((self.C.get('xvfb') and not args.noxvfb) or + (not self.C.get('xvfb') and args.xvfb and not args.noxvfb)) + if usexvfb: + xvfbPath = self.C.get('xvfb-run') + seleniumCommand = '%s %s' % (xvfbPath, seleniumCommand) + if not os.path.isfile(xvfbPath): + raise Exception('xvfb-run command could not be found in the specified location %s' % (xvfbPath)); + olderThan27 = M.branch_compare(27, '<') if args.run: diff --git a/mdk/config-dist.json b/mdk/config-dist.json index 792fd5ce..1f68f508 100644 --- a/mdk/config-dist.json +++ b/mdk/config-dist.json @@ -186,6 +186,12 @@ "lessc": "/usr/local/bin/lessc", // Path to shifter "shifter": "/usr/bin/shifter", + // Path to xvfb-run + "xvfb-run": "/usr/bin/xvfb-run", + + // Whether to use xvfb by default + "xvfb": false, + // Path to your favourite editor. Set to null to guess it from the System environment. "editor": null,