This guide walks through adding a simple
testimplementation for Bash that runs the
shunit2test runner. See here for the final implementation.
Usually, you will want to add a "test" target type for your language, such as
python_test. A test target contrasts with a "source" target, such as
shell_source. A test target is useful so that
./pants test :: doesn't try to run tests on non-test files.
When creating a test target, you should usually subclass
SingleSourceField. You may also want to create
TimeoutField, which should subclass
See Creating new targets for a guide on how to define new target types.
from pants.engine.target import ( COMMON_TARGET_FIELDS, Dependencies, IntField, SingleSourceField, Target, ) class ShellSourceField(SingleSourceField): expected_file_extensions = (".sh",) class ShellTestSourceField(SingleSourceField): pass class ShellTestTimeoutField(IntField): alias = "timeout" help = "Whether to time out after a certain period of time." class ShellTestTarget(Target): alias = "bash_tests" help = "Shell tests that are run via `shunit2`." core_fields = (*COMMON_TARGET_FIELDS, Dependencies, ShellTestSourceField, ShellTestTimeoutField)
Updated about 2 months ago