Skip to content

Commit

Permalink
Bug 1399800 - integrate pytest and add initial tests r=jmaher
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: FNQwCEtM1MB

--HG--
rename : testing/talos/tests/__init__.py => testing/talos/talos/unittests/__init__.py
rename : testing/talos/tests/browser_output.ts.txt => testing/talos/talos/unittests/browser_output.ts.txt
rename : testing/talos/tests/browser_output.tsvg.txt => testing/talos/talos/unittests/browser_output.tsvg.txt
rename : testing/talos/tests/profile.tgz => testing/talos/talos/unittests/profile.tgz
rename : testing/talos/tests/ps-Acj.out => testing/talos/talos/unittests/ps-Acj.out
rename : testing/talos/tests/test_talosconfig_browser_config.json => testing/talos/talos/unittests/test_talosconfig_browser_config.json
rename : testing/talos/tests/test_talosconfig_test_config.json => testing/talos/talos/unittests/test_talosconfig_test_config.json
rename : testing/talos/tests/xrestop_output.txt => testing/talos/talos/unittests/xrestop_output.txt
extra : rebase_source : 0e4652fcf1950926d87089e9b64b1da031920b21
  • Loading branch information
Ionut Goldan committed Oct 24, 2017
1 parent 14392e7 commit 9c2b03d
Show file tree
Hide file tree
Showing 46 changed files with 1,570 additions and 842 deletions.
1 change: 1 addition & 0 deletions build/virtualenv_packages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ mozilla.pth:testing/marionette/client
mozilla.pth:testing/marionette/harness
mozilla.pth:testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py
mozilla.pth:testing/marionette/puppeteer/firefox
mozilla.pth:testing/talos
packages.txt:testing/mozbase/packages.txt
mozilla.pth:tools
mozilla.pth:testing/web-platform
Expand Down
1 change: 1 addition & 0 deletions moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] or not CONFIG['MOZ_BUILD_APP']:
'layout/tools/reftest/selftest/python.ini',
'testing/marionette/harness/marionette_harness/tests/harness_unit/python.ini',
'testing/mochitest/tests/python/python.ini',
'testing/talos/talos/unittests/python.ini'
]

CONFIGURE_SUBST_FILES += [
Expand Down
61 changes: 60 additions & 1 deletion testing/talos/talos/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# data is filtered
"""

_FILTERS = {}


class Filter(object):
def __init__(self, func, *args, **kwargs):
Expand Down Expand Up @@ -45,9 +47,54 @@ def prepare(*args, **kwargs):
func.prepare = prepare
return func

# filters that return a scalar

def register_filter(func):
"""
all filters defined in this module
should be registered
"""
global _FILTERS

_FILTERS[func.__name__] = func
return func


def filters(*args):
global _FILTERS

filters_ = [_FILTERS[filter] for filter in args]
return filters_


def apply(data, filters):
for filter in filters:
data = filter(data)

return data


def parse(string_):

def to_number(string_number):
try:
return int(string_number)
except ValueError:
return float(string_number)

tokens = string_.split(":")

func = tokens[0]
digits = []
if len(tokens) > 1:
digits.extend(tokens[1].split(","))
digits = [to_number(digit) for digit in digits]

return [func, digits]


# filters that return a scalar

@register_filter
@define_filter
def mean(series):
"""
Expand All @@ -56,6 +103,7 @@ def mean(series):
return sum(series)/float(len(series))


@register_filter
@define_filter
def median(series):
"""
Expand All @@ -71,6 +119,7 @@ def median(series):
return 0.5*(series[middle-1] + series[middle])


@register_filter
@define_filter
def variance(series):
"""
Expand All @@ -82,6 +131,7 @@ def variance(series):
return variance


@register_filter
@define_filter
def stddev(series):
"""
Expand All @@ -90,6 +140,7 @@ def stddev(series):
return variance(series)**0.5


@register_filter
@define_filter
def dromaeo(series):
"""
Expand All @@ -106,12 +157,14 @@ def dromaeo(series):
return geometric_mean(means)


@register_filter
@define_filter
def dromaeo_chunks(series, size):
for i in range(0, len(series), size):
yield series[i:i+size]


@register_filter
@define_filter
def geometric_mean(series):
"""
Expand All @@ -125,6 +178,7 @@ def geometric_mean(series):
# filters that return a list


@register_filter
@define_filter
def ignore_first(series, number=1):
"""
Expand All @@ -136,6 +190,7 @@ def ignore_first(series, number=1):
return series[number:]


@register_filter
@define_filter
def ignore(series, function):
"""
Expand All @@ -150,6 +205,7 @@ def ignore(series, function):
return series


@register_filter
@define_filter
def ignore_max(series):
"""
Expand All @@ -158,6 +214,7 @@ def ignore_max(series):
return ignore(series, max)


@register_filter
@define_filter
def ignore_min(series):
"""
Expand All @@ -166,6 +223,7 @@ def ignore_min(series):
return ignore(series, min)


@register_filter
@define_filter
def v8_subtest(series, name):
"""
Expand All @@ -190,6 +248,7 @@ def v8_subtest(series, name):
return reference[name] / geometric_mean(series)


@register_filter
@define_filter
def responsiveness_Metric(val_list):
return sum([float(x)*float(x) / 1000000.0 for x in val_list])
2 changes: 2 additions & 0 deletions testing/talos/talos/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def test_dict():

class Test(object):
"""abstract base class for a Talos test case"""
__test__ = False # not pytest

cycles = None # number of cycles
keys = []
desktop = True
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions testing/talos/talos/unittests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from __future__ import absolute_import

import os

here = os.path.realpath(__file__)
__TESTS_DIR = os.path.join(os.path.dirname(os.path.dirname(here)), 'tests')


def remove_develop_files(starting_dir=__TESTS_DIR):
for file_name in os.listdir(starting_dir):

file_path = os.path.join(starting_dir, file_name)

if file_name.endswith('.develop') and os.path.isfile(file_path):
os.remove(file_path)
elif os.path.isdir(file_path):
remove_develop_files(file_path)
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions testing/talos/talos/unittests/python.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[DEFAULT]
subsuite = talos

[test_config.py]
[test_ffsetup.py]
[test_test.py]
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Loading

0 comments on commit 9c2b03d

Please sign in to comment.