github.com/cockroachdb/pebble@v0.0.0-20231214172447-ab4952c5f87b/Makefile (about)

     1  GO := go
     2  PKG := ./...
     3  GOFLAGS :=
     4  STRESSFLAGS :=
     5  TAGS := invariants
     6  TESTS := .
     7  COVER_PROFILE := coverprofile.out
     8  
     9  .PHONY: all
    10  all:
    11  	@echo usage:
    12  	@echo "  make test"
    13  	@echo "  make testrace"
    14  	@echo "  make stress"
    15  	@echo "  make stressrace"
    16  	@echo "  make stressmeta"
    17  	@echo "  make crossversion-meta"
    18  	@echo "  make testcoverage"
    19  	@echo "  make mod-update"
    20  	@echo "  make generate"
    21  	@echo "  make generate-test-data"
    22  	@echo "  make clean"
    23  
    24  override testflags :=
    25  .PHONY: test
    26  test:
    27  	${GO} test -tags '$(TAGS)' ${testflags} -run ${TESTS} ${PKG}
    28  
    29  .PHONY: testcoverage
    30  testcoverage:
    31  	${GO} test -tags '$(TAGS)' ${testflags} -run ${TESTS} ${PKG} -coverprofile ${COVER_PROFILE}
    32  
    33  .PHONY: testrace
    34  testrace: testflags += -race -timeout 20m
    35  testrace: test
    36  
    37  testasan: testflags += -asan -timeout 20m
    38  testasan: test
    39  
    40  testmsan: export CC=clang
    41  testmsan: testflags += -msan -timeout 20m
    42  testmsan: test
    43  
    44  .PHONY: testobjiotracing
    45  testobjiotracing:
    46  	${GO} test -tags '$(TAGS) pebble_obj_io_tracing' ${testflags} -run ${TESTS} ./objstorage/objstorageprovider/objiotracing
    47  
    48  .PHONY: lint
    49  lint:
    50  	${GO} test -tags '$(TAGS)' ${testflags} -run ${TESTS} ./internal/lint
    51  
    52  .PHONY: stress stressrace
    53  stressrace: testflags += -race
    54  stress stressrace: testflags += -exec 'stress ${STRESSFLAGS}' -timeout 0 -test.v
    55  stress stressrace: test
    56  
    57  .PHONY: stressmeta
    58  stressmeta: override PKG = ./internal/metamorphic
    59  stressmeta: override STRESSFLAGS += -p 1
    60  stressmeta: override TESTS = TestMeta$$
    61  stressmeta: stress
    62  
    63  .PHONY: crossversion-meta
    64  crossversion-meta:
    65  	$(eval LATEST_RELEASE := $(shell git fetch origin && git branch -r --list '*/crl-release-*' | grep -o 'crl-release-.*$$' | sort | tail -1))
    66  	git checkout ${LATEST_RELEASE}; \
    67  		${GO} test -c ./internal/metamorphic -o './internal/metamorphic/crossversion/${LATEST_RELEASE}.test'; \
    68  		git checkout -; \
    69  		${GO} test -c ./internal/metamorphic -o './internal/metamorphic/crossversion/head.test'; \
    70  		${GO} test -tags '$(TAGS)' ${testflags} -v -run 'TestMetaCrossVersion' ./internal/metamorphic/crossversion --version '${LATEST_RELEASE},${LATEST_RELEASE},${LATEST_RELEASE}.test' --version 'HEAD,HEAD,./head.test'
    71  
    72  .PHONY: stress-crossversion
    73  stress-crossversion:
    74  	STRESS=1 ./scripts/run-crossversion-meta.sh crl-release-21.2 crl-release-22.1 crl-release-22.2 crl-release-23.1 master
    75  
    76  .PHONY: generate
    77  generate:
    78  	${GO} generate ${PKG}
    79  
    80  generate:
    81  
    82  # Note that the output of generate-test-data is not deterministic. This should
    83  # only be run manually as needed.
    84  .PHONY: generate-test-data
    85  generate-test-data:
    86  	${GO} run -tags make_incorrect_manifests ./tool/make_incorrect_manifests.go
    87  	${GO} run -tags make_test_find_db ./tool/make_test_find_db.go
    88  	${GO} run -tags make_test_sstables ./tool/make_test_sstables.go
    89  	${GO} run -tags make_test_remotecat ./tool/make_test_remotecat.go
    90  
    91  mod-update:
    92  	${GO} get -u
    93  	${GO} mod tidy
    94  
    95  .PHONY: clean
    96  clean:
    97  	rm -f $(patsubst %,%.test,$(notdir $(shell go list ${PKG})))
    98  
    99  git_dirty := $(shell git status -s)
   100  
   101  .PHONY: git-clean-check
   102  git-clean-check:
   103  ifneq ($(git_dirty),)
   104  	@echo "Git repository is dirty!"
   105  	@false
   106  else
   107  	@echo "Git repository is clean."
   108  endif
   109  
   110  .PHONY: mod-tidy-check
   111  mod-tidy-check:
   112  ifneq ($(git_dirty),)
   113  	$(error mod-tidy-check must be invoked on a clean repository)
   114  endif
   115  	@${GO} mod tidy
   116  	$(MAKE) git-clean-check
   117  
   118  # TODO(radu): switch back to @latest once bogus doc changes are
   119  # addressed; see https://github.com/cockroachdb/crlfmt/pull/44
   120  .PHONY: format
   121  format:
   122  	go install github.com/cockroachdb/crlfmt@44a36ec7 && crlfmt -w -tab 2 .
   123  
   124  .PHONY: format-check
   125  format-check:
   126  ifneq ($(git_dirty),)
   127  	$(error format-check must be invoked on a clean repository)
   128  endif
   129  	$(MAKE) format
   130  	git diff
   131  	$(MAKE) git-clean-check