mirror of
https://github.com/gravitational/teleport.git
synced 2026-11-01 21:52:02 +08:00
Signed-off-by: Jakub Nyckowski <jakub.nyckowski@goteleport.com> Co-authored-by: Victor Sokolov <gzigzigzeo@gmail.com>
difftest
This tool finds tests which were changed since a previous git revision.
Usage
To see changes:
difftest diff --path . --branch master
To get go test flags to run only newly appeared tests:
difftest test --path . --branch master --exclude-updates
How it works
- Calls
git diff $(git merge-base --fork-point <branch>) - Filters all added/modified files ending with
_test.go. - Builds a map of
Test*methods in every file. - Calculates
SHA1hash of each method body. - Does the same for the counterpart files at the fork point.
- Compares the results. If a method was not there previously, it's marked as new. If a method's contents was changed, it is marked as changed.
testify/suite support
-
Tool detects suite start signatures like the following:
func TestSingleSuite(t *testing.T) { suite.Run(t, &SingleSuite{}) }where
suitereferences totestify/suitepackage, andtreferencestestingpackage. -
All methods related to a single suite must be in the same package (directory).
-
All suite parts must redside in a files matching
*_test.gopattern. -
If a test method has a receiver, which was not detected as a
testify/suitepreviously, such method got skipped.