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 "tests" target type for your language, such as
python_tests. A binary target contrasts with a "library" target, such as
bash_library. A test target is useful so that
./pants test :: doesn't try to run tests on non-test files.
When creating a tests target, you should usually subclass the
Sources field and set the
default. You may also want to create a
Timeout field, 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, Sources, Target class BashSources(Sources): expected_file_extensions = (".sh",) class BashTestSources(BashSources): default = ("*_test.sh", "test_*.sh") class BashTestTimeout(IntField): """Whether to time out after a certain amount of time. If unset, the test will never time out. """ alias = "timeout" class BashTests(Target): """Bash tests that are run via `shunit2`.""" alias = "bash_tests" core_fields = (*COMMON_TARGET_FIELDS, Dependencies, BashTestSources, BashTestTimeout)
Updated about 1 year ago