[LNT] r255959 - Cleanups and test fixes for rules
Chris Matthews via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 17 17:44:39 PST 2015
Author: cmatthews
Date: Thu Dec 17 19:44:38 2015
New Revision: 255959
URL: http://llvm.org/viewvc/llvm-project?rev=255959&view=rev
Log:
Cleanups and test fixes for rules
Added:
lnt/trunk/lnt/server/db/rules/__init__.py
lnt/trunk/lnt/server/db/rules_manager.py
- copied, changed from r255958, lnt/trunk/lnt/server/db/rules.py
Removed:
lnt/trunk/lnt/server/db/rules.py
Modified:
lnt/trunk/lnt/server/db/rules/rule_update_fixed_regressions.py
lnt/trunk/lnt/server/ui/app.py
lnt/trunk/lnt/server/ui/regression_views.py
lnt/trunk/lnt/server/ui/views.py
Removed: lnt/trunk/lnt/server/db/rules.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/rules.py?rev=255958&view=auto
==============================================================================
--- lnt/trunk/lnt/server/db/rules.py (original)
+++ lnt/trunk/lnt/server/db/rules.py (removed)
@@ -1,73 +0,0 @@
-"""
-Define facilities for automatically applying rules to data.
-"""
-
-import logging
-import os
-import re
-
-def load_rules():
- """
- Load available rules scripts from a directory.
-
- Rules are organized as:
-
- <current dir>/rules/
- <current dir>/rules/rule_.*.py
- ...
- """
-
- rule_script_rex = re.compile(
- r'^rule_(.*)\.py$')
- rule_scripts = {}
-
- rules_path = os.path.join(os.path.dirname(__file__),
- 'rules')
- for item in os.listdir(rules_path):
- # Ignore certain known non-scripts.
- if item in ('README.txt', '__init__.py') or item.endswith('.pyc'):
- continue
-
- # Ignore non-matching files.
- m = rule_script_rex.match(item)
- if m is None:
- logger.warning(
- "ignoring item %r in rule directory: %r",
- item, rules_path)
- continue
-
- name = m.groups()[0]
- # Allow rules to be disabled by name
- if name.endswith("disabled"):
- continue
-
- rule_scripts[name] = os.path.join(rules_path, item)
-
- return rule_scripts
-
-# Places our rules can hook to.
-HOOKS = {'post_test_hook':[],
- 'post_submission_hook':[],
- 'post_regression_create_hook':[]}
-
-DESCRIPTIONS = {}
-
-def register_hooks():
- """Exec all the rules files. Gather the hooks from them
- and load them into the hook dict for later use.
- """
- for name, path in load_rules().items():
- globals = {}
- execfile(path, globals)
- DESCRIPTIONS[name] = globals['__doc__']
- for hook_name in HOOKS.keys():
- if hook_name in globals:
- HOOKS[hook_name].append(globals[hook_name])
- return HOOKS
-
-def post_submission_hooks(ts, run_id):
- """Run all the post submission hooks on the submitted run."""
- for func in HOOKS['post_submission_hook']:
- func(ts, run)
-
-logger = logging.getLogger(__name__)
Added: lnt/trunk/lnt/server/db/rules/__init__.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/rules/__init__.py?rev=255959&view=auto
==============================================================================
--- lnt/trunk/lnt/server/db/rules/__init__.py (added)
+++ lnt/trunk/lnt/server/db/rules/__init__.py Thu Dec 17 19:44:38 2015
@@ -0,0 +1 @@
+__all__ = []
Modified: lnt/trunk/lnt/server/db/rules/rule_update_fixed_regressions.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/rules/rule_update_fixed_regressions.py?rev=255959&r1=255958&r2=255959&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/rules/rule_update_fixed_regressions.py (original)
+++ lnt/trunk/lnt/server/db/rules/rule_update_fixed_regressions.py Thu Dec 17 19:44:38 2015
@@ -22,13 +22,12 @@ def is_fixed(ts, regression):
fixed?
"""
r_inds = get_ris(ts, regression)
- changes = [r.field_change for r in r_inds]
- fixes = [_fixed_rind(ts, x) for x in changes]
+ fixes = [_fixed_rind(ts, x) for x in r_inds]
return all(fixes)
-def regression_evolution(ts, regressions):
+def regression_evolution(ts, run_id):
"""Analyse regressions. If they have changes, process them.
Look at each regression in state detect. Move to ignore if it is fixed.
Look at each regression in state stage. Move to verify if fixed.
@@ -36,6 +35,7 @@ def regression_evolution(ts, regressions
"""
note("Running regression evolution")
+ regressions = ts.query(ts.Regression).all()
detects = [r for r in regressions if r.state == RegressionState.DETECTED]
for regression in detects:
Copied: lnt/trunk/lnt/server/db/rules_manager.py (from r255958, lnt/trunk/lnt/server/db/rules.py)
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/rules_manager.py?p2=lnt/trunk/lnt/server/db/rules_manager.py&p1=lnt/trunk/lnt/server/db/rules.py&r1=255958&r2=255959&rev=255959&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/rules.py (original)
+++ lnt/trunk/lnt/server/db/rules_manager.py Thu Dec 17 19:44:38 2015
@@ -68,6 +68,4 @@ def register_hooks():
def post_submission_hooks(ts, run_id):
"""Run all the post submission hooks on the submitted run."""
for func in HOOKS['post_submission_hook']:
- func(ts, run)
-
-logger = logging.getLogger(__name__)
+ func(ts, run_id)
Modified: lnt/trunk/lnt/server/ui/app.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/app.py?rev=255959&r1=255958&r2=255959&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/app.py (original)
+++ lnt/trunk/lnt/server/ui/app.py Thu Dec 17 19:44:38 2015
@@ -23,6 +23,7 @@ import lnt.server.ui.views
import lnt.server.ui.regression_views
from lnt.server.ui.api import load_api_resources
+import lnt.server.db.rules_manager
class RootSlashPatchMiddleware(object):
@@ -151,6 +152,8 @@ class App(flask.Flask):
# Set the application secret key.
self.secret_key = self.old_config.secretKey
+
+ lnt.server.db.rules_manager.register_hooks()
def start_file_logging(self):
"""Start server production logging. At this point flask already logs
Modified: lnt/trunk/lnt/server/ui/regression_views.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/regression_views.py?rev=255959&r1=255958&r2=255959&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/regression_views.py (original)
+++ lnt/trunk/lnt/server/ui/regression_views.py Thu Dec 17 19:44:38 2015
@@ -1,5 +1,6 @@
import datetime
from flask import g
+from flask import abort
from flask import render_template
from flask import request
from flask import make_response
@@ -23,9 +24,9 @@ from wtforms import SelectMultipleField,
from flask_wtf import Form
from wtforms.validators import DataRequired
import lnt.server.ui.util as util
-
+from lnt.testing.util.commands import warning, error, note
import lnt.server.db.fieldchange
-
+from lnt.server.db import rules_manager as rule_hooks
class RegressionState:
# A new regression, not approved by the user yet.
@@ -251,6 +252,10 @@ class MergeRegressionForm(Form):
@v4_route("/regressions/", methods=["GET", "POST"])
def v4_regression_list():
+ warning("regression list")
+ error("regression list")
+ note("regression list")
+
ts = request.get_testsuite()
form = MergeRegressionForm(request.form)
@@ -401,3 +406,9 @@ def v4_regression_detail(id):
testsuite_name=g.testsuite_name,
regression=regression_info, changes=crs,
form=form, analysis=lnt.server.reporting.analysis)
+
+ at v4_route("/hook", methods=["GET"])
+def v4_hook():
+ ts = request.get_testsuite()
+ rule_hooks.post_submission_hooks(ts, 0)
+ abort(400)
Modified: lnt/trunk/lnt/server/ui/views.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/views.py?rev=255959&r1=255958&r2=255959&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/views.py (original)
+++ lnt/trunk/lnt/server/ui/views.py Thu Dec 17 19:44:38 2015
@@ -28,7 +28,7 @@ from lnt.server.ui.decorators import fro
import lnt.server.ui.util
import lnt.server.reporting.dailyreport
import lnt.server.reporting.summaryreport
-import lnt.server.db.rules
+import lnt.server.db.rules_manager
from collections import namedtuple
integral_rex = re.compile(r"[\d]+")
@@ -1166,8 +1166,7 @@ You must define a summary report configu
@frontend.route('/rules')
def rules():
- lnt.server.db.rules.register_hooks()
- discovered_rules = lnt.server.db.rules.DESCRIPTIONS
+ discovered_rules = lnt.server.db.rules_manager.DESCRIPTIONS
return render_template("rules.html",rules=discovered_rules)
@frontend.route('/log')
More information about the llvm-commits
mailing list