aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Eric Boren <borenet@google.com>2017-04-13 10:22:11 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-13 17:01:17 +0000
commit2ce36ea09e941d888e4b417a70ce9a90e6d7be2a (patch)
tree0d43a9c2adc249e3461508da4cabff4a602a4074
parent9866817d5f8b65aa8f45abc21d995001dce71769 (diff)
Add infra/bots/Makefile to simplify test/train
eg. $ make test or $ make train Update docs accordingly. Bug: skia: Change-Id: I069fa686833f0a78f398bd85eb8bb44025cae0d5 Reviewed-on: https://skia-review.googlesource.com/13327 Reviewed-by: Joe Gregorio <jcgregorio@google.com> Commit-Queue: Eric Boren <borenet@google.com>
-rw-r--r--infra/bots/Makefile5
-rw-r--r--infra/bots/README.md8
-rwxr-xr-xinfra/bots/infra_tests.py31
-rw-r--r--infra/bots/recipe_modules/README.md4
-rw-r--r--infra/bots/recipes/README.md4
-rw-r--r--infra/bots/recipes/infra.expected/failed_one_update.json7
-rw-r--r--infra/bots/recipes/infra.expected/infra_tests.json7
-rw-r--r--infra/bots/recipes/infra.py3
8 files changed, 54 insertions, 15 deletions
diff --git a/infra/bots/Makefile b/infra/bots/Makefile
new file mode 100644
index 0000000000..0df77df351
--- /dev/null
+++ b/infra/bots/Makefile
@@ -0,0 +1,5 @@
+test:
+ python infra_tests.py
+
+train:
+ python infra_tests.py --train
diff --git a/infra/bots/README.md b/infra/bots/README.md
index e7cbe7fcc1..9683e18e71 100644
--- a/infra/bots/README.md
+++ b/infra/bots/README.md
@@ -41,11 +41,19 @@ need to run gen_tasks.go to regenerate tasks.json:
$ go run infra/bots/gen_tasks.go
+Or:
+
+ $ cd infra/bots; make train
+
There is also a test mode which performs sanity-checks and verifies that
tasks.json is unchanged:
$ go run infra/bots/gen_tasks.go --test
+Or:
+
+ $ cd infra/bots; make test
+
Recipes
-------
diff --git a/infra/bots/infra_tests.py b/infra/bots/infra_tests.py
index 779ea8d83b..9e83427cad 100755
--- a/infra/bots/infra_tests.py
+++ b/infra/bots/infra_tests.py
@@ -25,20 +25,26 @@ def test(cmd, cwd):
return e.output
-def python_unit_tests():
+def python_unit_tests(train):
+ if train:
+ return None
return test(
['python', '-m', 'unittest', 'discover', '-s', '.', '-p', '*_test.py'],
INFRA_BOTS_DIR)
-def recipe_simulation_test():
- return test(
- ['python', os.path.join(INFRA_BOTS_DIR, 'recipes.py'), 'simulation_test'],
- SKIA_DIR)
+def recipe_simulation_test(train):
+ cmd = [
+ 'python', os.path.join(INFRA_BOTS_DIR, 'recipes.py'), 'simulation_test']
+ if train:
+ cmd.append('train')
+ return test(cmd, SKIA_DIR)
-def gen_tasks_test():
- cmd = ['go', 'run', 'gen_tasks.go', '--test']
+def gen_tasks_test(train):
+ cmd = ['go', 'run', 'gen_tasks.go']
+ if not train:
+ cmd.append('--test')
try:
output = test(cmd, INFRA_BOTS_DIR)
except OSError:
@@ -51,6 +57,10 @@ def gen_tasks_test():
def main():
+ train = False
+ if '--train' in sys.argv:
+ train = True
+
tests = (
python_unit_tests,
recipe_simulation_test,
@@ -58,7 +68,7 @@ def main():
)
errs = []
for t in tests:
- err = t()
+ err = t(train)
if err:
errs.append(err)
@@ -70,7 +80,10 @@ def main():
print >> sys.stderr, '=============================='
sys.exit(1)
- print 'All tests passed!'
+ if train:
+ print 'Trained tests successfully.'
+ else:
+ print 'All tests passed!'
if __name__ == '__main__':
diff --git a/infra/bots/recipe_modules/README.md b/infra/bots/recipe_modules/README.md
index 3ddf5ab248..4ed9632eaf 100644
--- a/infra/bots/recipe_modules/README.md
+++ b/infra/bots/recipe_modules/README.md
@@ -21,6 +21,10 @@ test:
$ python infra/bots/recipes.py simulation_test train
+Or:
+
+ $ cd infra/bots; make train
+
Each recipe module contains a few files:
* api.py - This is the meat of the module.
diff --git a/infra/bots/recipes/README.md b/infra/bots/recipes/README.md
index a9c4c6ab43..69dab23460 100644
--- a/infra/bots/recipes/README.md
+++ b/infra/bots/recipes/README.md
@@ -15,6 +15,10 @@ When you change a recipe, you generally need to re-train the simulation test:
$ python infra/bots/recipes.py simulation_test train
+Or:
+
+ $ cd infra/bots; make train
+
The simulation_test generates expectations files for the tests contained within
each recipe which illustrate which steps would run, given a particular set of
inputs. Pay attention to the diffs in these files when making changes to ensure
diff --git a/infra/bots/recipes/infra.expected/failed_one_update.json b/infra/bots/recipes/infra.expected/failed_one_update.json
index eaab71ecf3..f626748982 100644
--- a/infra/bots/recipes/infra.expected/failed_one_update.json
+++ b/infra/bots/recipes/infra.expected/failed_one_update.json
@@ -148,8 +148,11 @@
},
{
"cmd": [
- "python",
- "[CUSTOM_/_B_WORK]/skia/infra/bots/infra_tests.py"
+ "make",
+ "-v",
+ "-C",
+ "infra/bots",
+ "test"
],
"cwd": "[CUSTOM_/_B_WORK]/skia",
"env": {
diff --git a/infra/bots/recipes/infra.expected/infra_tests.json b/infra/bots/recipes/infra.expected/infra_tests.json
index 02b54bf83f..0152483509 100644
--- a/infra/bots/recipes/infra.expected/infra_tests.json
+++ b/infra/bots/recipes/infra.expected/infra_tests.json
@@ -126,8 +126,11 @@
},
{
"cmd": [
- "python",
- "[CUSTOM_/_B_WORK]/skia/infra/bots/infra_tests.py"
+ "make",
+ "-v",
+ "-C",
+ "infra/bots",
+ "test"
],
"cwd": "[CUSTOM_/_B_WORK]/skia",
"env": {
diff --git a/infra/bots/recipes/infra.py b/infra/bots/recipes/infra.py
index 2122aea641..24b9c622b5 100644
--- a/infra/bots/recipes/infra.py
+++ b/infra/bots/recipes/infra.py
@@ -23,9 +23,8 @@ def RunSteps(api):
api.infra.update_go_deps()
# Run the infra tests.
- infra_tests = api.vars.skia_dir.join('infra', 'bots', 'infra_tests.py')
with api.step.context({'cwd': api.vars.skia_dir, 'env': api.infra.go_env}):
- api.step('infra_tests', cmd=['python', infra_tests])
+ api.step('infra_tests', cmd=['make', '-v', '-C', 'infra/bots', 'test'])
def GenTests(api):