Skip to content

Commit

Permalink
bug 1540655: moztest: add test path resolution for Puppeteer tests; r…
Browse files Browse the repository at this point in the history
…=ahal

Makes it possible for mach to resolve test paths for Puppeteer,
so that individual tests can be run from the command line using
"./mach test", as such:

	% ./mach test remote/test/puppeteer/test/screenshot.spec.js

As the Puppeteer test suite is imported from upstream and we cannot
change this directory at will (i.e. to add test manifest files),
we take the same approach as for WPT and populate the manifest by
recursively walking the remote/test/puppeteer/test/**/*.spec.js file tree.

Differential Revision: https://phabricator.services.mozilla.com/D37013
  • Loading branch information
andreastt committed Aug 16, 2019
1 parent a9856ca commit a5b8a92
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion testing/mozbase/moztest/moztest/resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

from __future__ import absolute_import, print_function, unicode_literals

import pickle
import fnmatch
import os
import pickle
import sys
from collections import defaultdict

Expand Down Expand Up @@ -147,6 +148,11 @@ def WebglSuite(name):
'mochitest-webgl2-core': WebglSuite('webgl2-core'),
'mochitest-webgl2-ext': WebglSuite('webgl2-ext'),
'mochitest-webgl2-deqp': WebglSuite('webgl2-deqp'),
'puppeteer': {
'aliases': ('remote/test/puppeteer',),
'mach_command': 'puppeteer-test',
'kwargs': {},
},
'python': {
'mach_command': 'python-test',
'kwargs': {'tests': None},
Expand Down Expand Up @@ -234,6 +240,7 @@ def WebglSuite(name):
'firefox-ui-update': 'firefox-ui-update',
'marionette': 'marionette',
'mochitest': 'mochitest-plain',
'puppeteer': 'puppeteer',
'python': 'python',
'reftest': 'reftest',
'steeplechase': '',
Expand Down Expand Up @@ -425,6 +432,8 @@ def fltr(tests):

candidate_paths = set()

if flavor in (None, 'puppeteer') and any(self.is_puppeteer_path(p) for p in paths):
self.add_puppeteer_manifest_data()
if flavor in (None, 'web-platform-tests') and any(self.is_wpt_path(p) for p in paths):
self.add_wpt_manifest_data()

Expand Down Expand Up @@ -455,6 +464,30 @@ def fltr(tests):
for test in fltr(tests):
yield test

def is_puppeteer_path(self, path):
if path is None:
return True
return mozpath.match(path, "remote/test/puppeteer/test/**")

def add_puppeteer_manifest_data(self):
test_path = os.path.join(self._srcdir, "remote", "test", "puppeteer", "test")
for root, dirs, paths in os.walk(test_path):
for filename in fnmatch.filter(paths, "*.spec.js"):
path = os.path.join(root, filename)
self._tests_by_path[path].append({
"path": os.path.abspath(path),
"flavor": "puppeteer",
"here": os.path.dirname(path),
"manifest": None,
"name": path,
"file_relpath": path,
"head": "",
"support-files": "",
"subsuite": "puppeteer",
"dir_relpath": os.path.dirname(path),
"srcdir_relpath": path,
})

def is_wpt_path(self, path):
if path is None:
return True
Expand Down

0 comments on commit a5b8a92

Please sign in to comment.