Skip to content

Commit 90f9dfe

Browse files
authored
Merge pull request #928 from ellemouton/makeUnitTestHelpers
makefile: add unit test helpers
2 parents ebdc6ef + d6f184c commit 90f9dfe

File tree

6 files changed

+99
-31
lines changed

6 files changed

+99
-31
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -175,32 +175,19 @@ jobs:
175175
- name: run check
176176
run: make lint mod-check
177177

178-
########################
179-
# unit race tests
180-
########################
181-
unit-race:
182-
name: unit-race
183-
runs-on: ubuntu-latest
184-
steps:
185-
- name: git checkout
186-
uses: actions/checkout@v3
187-
with:
188-
fetch-depth: 0
189-
190-
- name: setup go ${{ env.GO_VERSION }}
191-
uses: ./.github/actions/setup-go
192-
with:
193-
go-version: '${{ env.GO_VERSION }}'
194-
195-
- name: run check
196-
run: make unit-race
197-
198178
########################
199179
# unit tests
200180
########################
201-
unit:
202-
name: unit tests
181+
unit-test:
182+
name: run unit tests
203183
runs-on: ubuntu-latest
184+
strategy:
185+
# Allow other tests in the matrix to continue if one fails.
186+
fail-fast: false
187+
matrix:
188+
unit_type:
189+
- unit-race
190+
- unit
204191
steps:
205192
- name: git checkout
206193
uses: actions/checkout@v3
@@ -212,8 +199,8 @@ jobs:
212199
with:
213200
go-version: '${{ env.GO_VERSION }}'
214201

215-
- name: run check
216-
run: make unit
202+
- name: run ${{ matrix.unit_type }}
203+
run: make ${{ matrix.unit_type }}
217204

218205
########################
219206
# integration tests

Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ XARGS := xargs -L 1
5757

5858
LINT = $(LINT_BIN) run -v
5959

60-
UNIT := $(GOLIST) | $(XARGS) env $(GOTEST)
61-
UNIT_RACE := $(UNIT) -race
62-
6360
include make/release_flags.mk
6461
include make/testing_flags.mk
6562

@@ -199,7 +196,7 @@ check: unit
199196
unit:
200197
@$(call print, "Running unit tests.")
201198
mkdir -p app/build && touch app/build/index.html
202-
$(UNIT) -tags="$(LND_RELEASE_TAGS)"
199+
$(UNIT)
203200

204201
unit-cover: $(GOACC_BIN)
205202
@$(call print, "Running unit coverage tests.")
@@ -208,7 +205,7 @@ unit-cover: $(GOACC_BIN)
208205
unit-race:
209206
@$(call print, "Running unit race tests.")
210207
mkdir -p app/build && touch app/build/index.html
211-
env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(UNIT_RACE) -tags="$(LND_RELEASE_TAGS)"
208+
env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(UNIT_RACE)
212209

213210
clean-itest:
214211
@$(call print, "Cleaning itest binaries.")
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Release Notes
2+
3+
- [Lightning Terminal](#lightning-terminal)
4+
- [Bug Fixes](#bug-fixes)
5+
- [Functional Changes/Additions](#functional-changesadditions)
6+
- [Technical and Architectural Updates](#technical-and-architectural-updates)
7+
- [Integrated Binary Updates](#integrated-binary-updates)
8+
- [LND](#lnd)
9+
- [Loop](#loop)
10+
- [Pool](#pool)
11+
- [Faraday](#faraday)
12+
- [Taproot Assets](#taproot-assets)
13+
- [Contributors](#contributors-alphabetical-order)
14+
15+
## Lightning Terminal
16+
17+
### Bug Fixes
18+
19+
### Functional Changes/Additions
20+
21+
### Technical and Architectural Updates
22+
23+
* [Add some Makefile
24+
helpers](https://github.com/lightninglabs/lightning-terminal/pull/928) that
25+
allow for more control over running unit tests.
26+
27+
## Integrated Binary Updates
28+
29+
### LND
30+
31+
### Loop
32+
33+
### Pool
34+
35+
### Faraday
36+
37+
### Taproot Assets
38+
39+
# Contributors (Alphabetical Order)
40+
41+
* Elle Mouton

make/compile_flags.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
COMPILE_TAGS = autopilotrpc signrpc walletrpc chainrpc invoicesrpc watchtowerrpc neutrinorpc peersrpc

make/release_flags.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
include make/compile_flags.mk
2+
13
# Create a globally-consistent, build-input identifier.
24
VERSION_TAG = $(shell git describe --abbrev=40 --broken --tags --always)
35
VERSION_CHECK = @$(call print, "Building master with date version tag")
@@ -21,7 +23,7 @@ linux-armv7 \
2123
linux-arm64 \
2224
windows-amd64
2325

24-
LND_RELEASE_TAGS = litd autopilotrpc signrpc walletrpc chainrpc invoicesrpc watchtowerrpc neutrinorpc peersrpc
26+
LND_RELEASE_TAGS = litd $(COMPILE_TAGS)
2527

2628
# By default we will build all systems. But with the 'sys' tag, a specific
2729
# system can be specified. This is useful to release for a subset of

make/testing_flags.mk

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,46 @@
1-
ITEST_FLAGS =
1+
include make/compile_flags.mk
2+
3+
ITEST_FLAGS =
4+
TEST_FLAGS =
5+
DEV_TAGS = dev
26

37
# Define the integration test.run filter if the icase argument was provided.
48
ifneq ($(icase),)
59
ITEST_FLAGS += -test.run="TestLightningTerminal/$(icase)"
610
endif
11+
12+
# If a specific unit test case is being targeted, construct test.run filter.
13+
ifneq ($(case),)
14+
TEST_FLAGS += -test.run=$(case)
15+
UNIT_TARGETED = yes
16+
endif
17+
18+
# If specific package is being unit tested, construct the full name of the
19+
# subpackage.
20+
ifneq ($(pkg),)
21+
UNITPKG := $(PKG)/$(pkg)
22+
COVER_PKG := $(PKG)/$(pkg)
23+
UNIT_TARGETED = yes
24+
GOLIST = echo '$(PKG)/$(pkg)'
25+
endif
26+
27+
# Add any additional tags that are passed in to make.
28+
ifneq ($(tags),)
29+
DEV_TAGS += ${tags}
30+
endif
31+
32+
# UNIT_TARGETED is undefined iff a specific package and/or unit test case is
33+
# not being targeted.
34+
UNIT_TARGETED ?= no
35+
36+
# If a specific package/test case was requested, run the unit test for the
37+
# targeted case. Otherwise, default to running all tests.
38+
ifeq ($(UNIT_TARGETED), yes)
39+
UNIT := $(GOTEST) -tags="$(DEV_TAGS) $(COMPILE_TAGS)" $(TEST_FLAGS) $(UNITPKG)
40+
endif
41+
42+
ifeq ($(UNIT_TARGETED), no)
43+
UNIT := $(GOLIST) | $(XARGS) env $(GOTEST) -tags="$(DEV_TAGS) $(COMPILE_TAGS)" $(TEST_FLAGS)
44+
endif
45+
46+
UNIT_RACE := $(UNIT) -race

0 commit comments

Comments
 (0)