Skip to content

Commit 47b185f

Browse files
committed
Add capability to run specific unit test(s)
Prior to this changeset, running "make unit-tests" will execute go tests for all Fabric packages. This changeset adds the ability to selectively run go tests for specified packages while still using the build environment (which is useful to emulate what is run in CI). To do this, the following changes were made: - Added TEST_PKGS environment variable to unit-tests/run.sh. If not set, you default to running tests for all packages - Modified unit-test/docker-compose.yaml to pass TEST_PKGS into the Docker build env TEST_PKGS expects a space-delimited list of qualified Go pkg URLs like you would pass to the go list command. To use the new feature, export / set TEST_PKGS prior to running make unit-tests : export TEST_PKGS=\ "github.com/hyperledger/fabric/core/comm/... \ github.com/hyperledger/fabric/gossip/..." make unit-tests *latest patch uses a shorter syntax in run.sh Fixes FAB-1455 Change-Id: I5d889f3f25ad3b628c463202939638ba6906d85f Signed-off-by: Gari Singh <[email protected]>
1 parent 2a123fe commit 47b185f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

unit-test/docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ unit-tests:
1616
- UNIT_TEST_PEER_IP=vp
1717
- GO_LDFLAGS
1818
- OUTPUT
19+
- TEST_PKGS=${TEST_PKGS}
1920
volumes:
2021
- /var/run/docker.sock:/var/run/docker.sock
2122
- ${GOPATH}/src/github.com/hyperledger/fabric:/opt/gopath/src/github.com/hyperledger/fabric

unit-test/run.sh

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
set -e
44
ARCH=`uname -m`
55

6-
echo -n "Obtaining list of tests to run.."
6+
#check to see if TEST_PKGS is set else use default (all packages)
7+
TEST_PKGS=${TEST_PKGS:-github.com/hyperledger/fabric/...}
8+
echo -n "Obtaining list of tests to run for the following packages: ${TEST_PKGS}"
9+
710
# Some examples don't play nice with `go test`
8-
PKGS=`go list github.com/hyperledger/fabric/... 2> /dev/null | \
11+
PKGS=`go list ${TEST_PKGS} 2> /dev/null | \
912
grep -v /vendor/ | \
1013
grep -v /build/ | \
1114
grep -v /examples/chaincode/chaintool/ | \

0 commit comments

Comments
 (0)