Skip to content

Commit

Permalink
Merge pull request #928 from ellemouton/makeUnitTestHelpers
Browse files Browse the repository at this point in the history
makefile: add unit test helpers
  • Loading branch information
ellemouton authored Jan 7, 2025
2 parents ebdc6ef + d6f184c commit 90f9dfe
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 31 deletions.
35 changes: 11 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,32 +175,19 @@ jobs:
- name: run check
run: make lint mod-check

########################
# unit race tests
########################
unit-race:
name: unit-race
runs-on: ubuntu-latest
steps:
- name: git checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: setup go ${{ env.GO_VERSION }}
uses: ./.github/actions/setup-go
with:
go-version: '${{ env.GO_VERSION }}'

- name: run check
run: make unit-race

########################
# unit tests
########################
unit:
name: unit tests
unit-test:
name: run unit tests
runs-on: ubuntu-latest
strategy:
# Allow other tests in the matrix to continue if one fails.
fail-fast: false
matrix:
unit_type:
- unit-race
- unit
steps:
- name: git checkout
uses: actions/checkout@v3
Expand All @@ -212,8 +199,8 @@ jobs:
with:
go-version: '${{ env.GO_VERSION }}'

- name: run check
run: make unit
- name: run ${{ matrix.unit_type }}
run: make ${{ matrix.unit_type }}

########################
# integration tests
Expand Down
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ XARGS := xargs -L 1

LINT = $(LINT_BIN) run -v

UNIT := $(GOLIST) | $(XARGS) env $(GOTEST)
UNIT_RACE := $(UNIT) -race

include make/release_flags.mk
include make/testing_flags.mk

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

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

clean-itest:
@$(call print, "Cleaning itest binaries.")
Expand Down
41 changes: 41 additions & 0 deletions docs/release-notes/release-notes-0.14.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Release Notes

- [Lightning Terminal](#lightning-terminal)
- [Bug Fixes](#bug-fixes)
- [Functional Changes/Additions](#functional-changesadditions)
- [Technical and Architectural Updates](#technical-and-architectural-updates)
- [Integrated Binary Updates](#integrated-binary-updates)
- [LND](#lnd)
- [Loop](#loop)
- [Pool](#pool)
- [Faraday](#faraday)
- [Taproot Assets](#taproot-assets)
- [Contributors](#contributors-alphabetical-order)

## Lightning Terminal

### Bug Fixes

### Functional Changes/Additions

### Technical and Architectural Updates

* [Add some Makefile
helpers](https://github.com/lightninglabs/lightning-terminal/pull/928) that
allow for more control over running unit tests.

## Integrated Binary Updates

### LND

### Loop

### Pool

### Faraday

### Taproot Assets

# Contributors (Alphabetical Order)

* Elle Mouton
1 change: 1 addition & 0 deletions make/compile_flags.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
COMPILE_TAGS = autopilotrpc signrpc walletrpc chainrpc invoicesrpc watchtowerrpc neutrinorpc peersrpc
4 changes: 3 additions & 1 deletion make/release_flags.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include make/compile_flags.mk

# Create a globally-consistent, build-input identifier.
VERSION_TAG = $(shell git describe --abbrev=40 --broken --tags --always)
VERSION_CHECK = @$(call print, "Building master with date version tag")
Expand All @@ -21,7 +23,7 @@ linux-armv7 \
linux-arm64 \
windows-amd64

LND_RELEASE_TAGS = litd autopilotrpc signrpc walletrpc chainrpc invoicesrpc watchtowerrpc neutrinorpc peersrpc
LND_RELEASE_TAGS = litd $(COMPILE_TAGS)

# By default we will build all systems. But with the 'sys' tag, a specific
# system can be specified. This is useful to release for a subset of
Expand Down
42 changes: 41 additions & 1 deletion make/testing_flags.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
ITEST_FLAGS =
include make/compile_flags.mk

ITEST_FLAGS =
TEST_FLAGS =
DEV_TAGS = dev

# Define the integration test.run filter if the icase argument was provided.
ifneq ($(icase),)
ITEST_FLAGS += -test.run="TestLightningTerminal/$(icase)"
endif

# If a specific unit test case is being targeted, construct test.run filter.
ifneq ($(case),)
TEST_FLAGS += -test.run=$(case)
UNIT_TARGETED = yes
endif

# If specific package is being unit tested, construct the full name of the
# subpackage.
ifneq ($(pkg),)
UNITPKG := $(PKG)/$(pkg)
COVER_PKG := $(PKG)/$(pkg)
UNIT_TARGETED = yes
GOLIST = echo '$(PKG)/$(pkg)'
endif

# Add any additional tags that are passed in to make.
ifneq ($(tags),)
DEV_TAGS += ${tags}
endif

# UNIT_TARGETED is undefined iff a specific package and/or unit test case is
# not being targeted.
UNIT_TARGETED ?= no

# If a specific package/test case was requested, run the unit test for the
# targeted case. Otherwise, default to running all tests.
ifeq ($(UNIT_TARGETED), yes)
UNIT := $(GOTEST) -tags="$(DEV_TAGS) $(COMPILE_TAGS)" $(TEST_FLAGS) $(UNITPKG)
endif

ifeq ($(UNIT_TARGETED), no)
UNIT := $(GOLIST) | $(XARGS) env $(GOTEST) -tags="$(DEV_TAGS) $(COMPILE_TAGS)" $(TEST_FLAGS)
endif

UNIT_RACE := $(UNIT) -race

0 comments on commit 90f9dfe

Please sign in to comment.