-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: add command to compile all test files #7364
Conversation
test-build-check will compile and use go cache mechanism to check if ALL files compiles without running any test. ref: 7362
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a tad unnecesary. Go's cache is enabled by default, and so it must be in order to use go modules
. Plus make test-all
already runs all tests and avoid re-execution by leveraging Go's internal cache.
On the other hand, subsequent run of
And we can optimize it way more if we will use |
not sure how much time it would take to go and run |
Untrue. It does.
...bring no advantages and the Makefile rule execution is faster just because it does not run all tests. |
As it's noted in the make task, that's the whole goal to not execute any test and only do a compilation. |
Then |
I already mentioned it -> save some time. If I'm doing some small refactoring, especially in a core package, I don't want to wait 6-10min each time to re-execute all tests. I firstly will like to check that everything compile and then after fixing compilation issues, I would run tests. |
You have to. Just compiling your tests is not enough. Your editor (with the right settings, e.g. build tags) can handle everything for you.
Again, your editor does it for you. Adding a tests-compilation target in the Makefile that fundamentally does nothing is pointless. |
|
Please re-read my comment above.
6min vs 18sec is saving a time. I did it few times today and it helped me and saved my time a lot (BTW: it has noting to do with running a particular test). Anyway, if it's only for me then I will add it to private scripts and update |
It is not, especially if the compiler has to recompile regardless of whether you had compiled before. Again, try dig into your go tests cache and you will see it yourself - different
That sounds like an eminently wise choice. |
Bump - can we close this for now please? |
I'm using |
I drop here a replacement of the proposed patch, which would cause tests to be effectively cached and not rebuilt (provided that one uses exactly the same tags in its build configuration): diff --git a/Makefile b/Makefile
index bd667b1c0..0ee675b1d 100644
--- a/Makefile
+++ b/Makefile
@@ -218,6 +218,7 @@ test-all: test-unit test-ledger-mock test-race test-cover
TEST_PACKAGES=./...
TEST_TARGETS := test-unit test-unit-amino test-unit-proto test-ledger-mock test-race test-ledger test-race
+CHECK_TEST_TARGETS := check-test-unit check-test-unit-amino check-test-unit-proto check-test-ledger-mock check-test-race check-test-ledger check-test-race
# Test runs-specific rules. To add a new test target, just add
# a new rule, customise ARGS or TEST_PACKAGES ad libitum, and
@@ -230,13 +231,22 @@ test-ledger-mock: ARGS=-tags='ledger test_ledger_mock norace'
test-race: ARGS=-race -tags='cgo ledger test_ledger_mock'
test-race: TEST_PACKAGES=$(PACKAGES_NOSIMULATION)
+check-test-unit: test-unit
+check-test-unit-amino: test-unit-amino
+check-test-ledger: test-ledger
+check-test-ledger-mock: test-ledger-mock
+check-test-race: test-race
+
$(TEST_TARGETS): run-tests
+$(CHECK_TEST_TARGETS): run-tests
+$(CHECK_TEST_TARGETS): EXTRA_ARGS=-run=none
+
run-tests:
ifneq (,$(shell which tparse 2>/dev/null))
- go test -mod=readonly -json $(ARGS) $(TEST_PACKAGES) | tparse
+ go test -mod=readonly -json $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES) | tparse
else
- go test -mod=readonly $(ARGS) $(TEST_PACKAGES)
+ go test -mod=readonly $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES)
endif
.PHONY: run-tests test test-all $(TEST_TARGETS) |
looks good. Do you want to commit it here? |
BTW: we only really need to build all tests, we don't need to split them in multiple categories. |
If you build all tests with the same flags, cache won't work when you run For what concerns me, this could be closed and my patch should be adopted. @robert-zaremba feel free to close this yourself. Thanks! |
OK. @alessio - so you prefer to close this and make a new PR with your patch? That works for me. Do you want me to do it? |
I don't believe it brings much benefit, I will hardly use it. But if you want and need it, feel free to either amend this PR or open a new one and I'll approve it 👍 |
@alessio , I've updated the PR. Added only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK
CHECK_TEST_TARGETS := test-unit test-unit-amino | ||
check-test-unit: test-unit | ||
check-test-unit-amino: test-unit-amino | ||
$(CHECK_TEST_TARGETS): EXTRA_ARGS=-run=none |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this suppose to be inserted on make test
? I cant find any updates in the contributing on how to run tests?
cosmos-sdk on marko/remove_toTM2 [!?] via 🐹 v1.15.3 on ☁️ markobaricevic3778@gmail.com
❯ make test
go test -mod=readonly -tags='cgo ledger test_ledger_mock norace' -run=none ./...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It introduces new jobs, but it doesn't change a way how you run tests. The new jobs are to compile and not runing any test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but the old command to run tests doesn't run tests, so it does change how you run tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marbar3778 fix is here - mind opening a PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$(TEST_TARGETS): run-tests | ||
|
||
# check-* compiles and collects tests without running them | ||
# note: go test -c doesn't support multiple packages yet (https://github.com/golang/go/issues/15513) | ||
CHECK_TEST_TARGETS := test-unit test-unit-amino |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the offendling line @marbar3778, this should be:
CHECK_TEST_TARGETS := check-test-unit check-test-unit-amino
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right. Sorry didn't notice. Wrong copy-paste 🤕
test-build-check will compile and use go cache mechanism to
check if ALL files compiles without running any test.
ref: #7362
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes