2012-04-10 06:19:49 +08:00
|
|
|
# Copyright 2012 Google Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
"""Builds and executes a set of test rules.
|
|
|
|
|
TODO: need some custom rules (test_js or something?) that provide parameters
|
|
|
|
|
to some test framework (BusterJS?)
|
|
|
|
|
|
|
|
|
|
Example:
|
2012-04-11 10:58:07 +08:00
|
|
|
anvil test :test_rule ...
|
2012-04-10 06:19:49 +08:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
__author__ = 'benvanik@google.com (Ben Vanik)'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
import anvil.commands.util as commandutil
|
2012-04-12 05:11:34 +08:00
|
|
|
from anvil.manage import ManageCommand
|
2012-04-10 06:19:49 +08:00
|
|
|
|
|
|
|
|
|
2012-04-12 05:11:34 +08:00
|
|
|
class TestCommand(ManageCommand):
|
|
|
|
|
def __init__(self):
|
|
|
|
|
super(TestCommand, self).__init__(
|
|
|
|
|
name='test',
|
|
|
|
|
help_short='Builds and runs test rules.',
|
|
|
|
|
help_long=__doc__)
|
2012-04-12 06:57:23 +08:00
|
|
|
self._add_common_build_hints()
|
2012-04-10 06:19:49 +08:00
|
|
|
|
2012-04-12 05:11:34 +08:00
|
|
|
def create_argument_parser(self):
|
|
|
|
|
parser = super(TestCommand, self).create_argument_parser()
|
2012-04-10 06:19:49 +08:00
|
|
|
|
2012-04-12 05:11:34 +08:00
|
|
|
# Add all common args
|
|
|
|
|
self._add_common_build_arguments(parser, targets=True)
|
2012-04-10 06:19:49 +08:00
|
|
|
|
2012-04-12 05:11:34 +08:00
|
|
|
return parser
|
2012-04-10 06:19:49 +08:00
|
|
|
|
2012-04-12 05:11:34 +08:00
|
|
|
def execute(self, args, cwd):
|
|
|
|
|
(result, all_target_outputs) = commandutil.run_build(cwd, args)
|
2012-04-10 06:19:49 +08:00
|
|
|
|
2013-08-20 06:21:57 +08:00
|
|
|
print(all_target_outputs)
|
2012-04-10 06:19:49 +08:00
|
|
|
|
2012-04-12 05:11:34 +08:00
|
|
|
return 0 if result else 1
|