-
Notifications
You must be signed in to change notification settings - Fork 393
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
Update test-k2 convention to use test suites #3524
Conversation
- use jvm-test-suites to create create separate targets for descriptor and symbols tests - update Configurations to use newer Gradle guidelines for declarable/resolvable configurations
Hi @vmishenev 👋, I've added you as a reviewer since you created this convention plugin. |
useJUnitPlatform { | ||
excludeTags.addAll(descriptorTags + symbolsTags) | ||
} | ||
classpath += descriptorsTestImplementationResolver.incoming.files |
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 is not clear to me why we have the same configuration as for descriptorsTest
?
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.
Good question. Basically, Dokka needs to analyse source code.
- For K1 source code, it uses a descriptor-based implementation.
- And for K2, symbols-based implementation.
The Dokka subprojects don't use these implementations directly, they need to be provided at runtime. So, to run the tests, Dokka needs one implementation or the other. Dokka is still being converted to K2, so at the moment K1 is the default. Hence, the K1 descriptor-based analyser is used for 'regular' unit tests.
Does that help?
Correct me if I'm wrong please Dokka team!
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 makes sense, thanks!
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.
So, overall the idea is to run ALL tests with both K1 and K2 analysis. + there are some tests where behaviour differs (because f.e K1 or K2 analysis has some bugs), so for this cases we have annotations like OnlyDescriptors
/OnlySymbols
And AFAIU, approach in this PR is not what we want. If im not wrong now we have 3 test tasks:
test
will run ALL tests excluding marked with annotation using K1descriptorsTest
will run only marked for descriptors tests with K1symbolsTest
will run only marked for symbols tests with K2
So I believe it's not what we want.
I don't know how flexible are test-suites but finally we want to have two separate tasks to run analysis for K1 and K2, f.e:
descriptorsTest
will run ALL tests excludingOnlySymbols
with K1 runtimesymbolsTest
will run ALL tests excludingOnlyDescriptors
with K2 runtimetest
will just run bothsymbolsTest
anddescriptorsTest
, but don't run ALL tests one more time
Does it help?
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.
symbolsTest will run ALL tests excluding OnlySymbols with K1 runtime
descriptorsTest will run ALL tests excluding OnlyDescriptors with K2 runtime
it seems @whyoleg mixed up symbolsTest
and descriptorsTest
The correct order is
descriptorsTest
will run ALL tests excludingOnlySymbols
with K1 runtimesymbolsTest
will run ALL tests excludingOnlyDescriptors
with K2 runtime
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.
So, on master we have:
descriptorsTest
- runs tests with K1symbolsTest
- runs test with K2test
- configured the same asdescriptorsTest
, so runs tests with K1 + runssymbolsTest
- so when runningtest
you will be able to run tests both with K1 and K2
I see that descriptorsTest isn't added to check or test, so it won't always run
But, you can run it from IDEA gutter - so f.e I can run tests for some class/method with K1 only, or with K2 only
Ideally, I think, it will be fine that test
will not run any tests by itself, but just run dependent tasks (for K1 and K2), but I'm not sure, that it's possible to make compatible with both CLI and IDE, so current approach (from master) should be a good compromise
Does it help to understand the idea better? May be Vadim has something additional to say here
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.
Thanks for explaining! So the idea is to provide a more descriptive name, even if test
and descriptorsTest
are both the same, under the hood?
Ideally, I think, it will be fine that
test
will not run any tests by itself, but just run dependent tasks (for K1 and K2), but I'm not sure, that it's possible to make compatible with both CLI and IDE, so current approach (from master) should be a good compromise
Yeah, that makes sense. It's what I tried to do in the original PR, but JUnit and/or Gradle doesn't like having a test tasks that don't do anything (which is very important, because if a bug means no tests run then you don't want the test task to succeed!)
Anyway, I've reverted the behaviour to master, so it should work the same.
And here's a summary of the discussed options:
Task | uses | master | initial PR | test-runs-nothing proposal | test-runs-no-tags proposal |
---|---|---|---|---|---|
test | descriptors | !K2 | !K1 && !K2 | nothing | !K1 && !K2 |
descriptorTest | descriptors | !K2 | K1 | !K2 | !K2 |
symbolTest | symbols | !K1 | K2 | !K1 | !K1 |
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.
may be we can then add comment the reason why test
task is configured that way? So it's just an alias to descriptor tests, to avoid future confusions?
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.
aside from comment, it would be good to actualise PR description
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 have a question. Will the test
task run the symbols tests as well?
Our CI (TeamCity/GH Actions) is set to run only the test
task, e.g.
dokka/.github/workflows/tests-smoke.yml
Line 35 in ed3ab96
./gradlew test --stacktrace --no-daemon --no-parallel |
# Conflicts: # build-logic/settings.gradle.kts
useJUnitPlatform { | ||
excludeTags.addAll(descriptorTags + symbolsTags) | ||
} | ||
classpath += descriptorsTestImplementationResolver.incoming.files |
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.
So, overall the idea is to run ALL tests with both K1 and K2 analysis. + there are some tests where behaviour differs (because f.e K1 or K2 analysis has some bugs), so for this cases we have annotations like OnlyDescriptors
/OnlySymbols
And AFAIU, approach in this PR is not what we want. If im not wrong now we have 3 test tasks:
test
will run ALL tests excluding marked with annotation using K1descriptorsTest
will run only marked for descriptors tests with K1symbolsTest
will run only marked for symbols tests with K2
So I believe it's not what we want.
I don't know how flexible are test-suites but finally we want to have two separate tasks to run analysis for K1 and K2, f.e:
descriptorsTest
will run ALL tests excludingOnlySymbols
with K1 runtimesymbolsTest
will run ALL tests excludingOnlyDescriptors
with K2 runtimetest
will just run bothsymbolsTest
anddescriptorsTest
, but don't run ALL tests one more time
Does it help?
- add comments to clarify K1 vs K2 analysis
useJUnitPlatform { | ||
excludeTags.addAll(descriptorTags + symbolsTags) | ||
} | ||
classpath += descriptorsTestImplementationResolver.incoming.files |
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.
may be we can then add comment the reason why test
task is configured that way? So it's just an alias to descriptor tests, to avoid future confusions?
Summary
Usage
./gradlew test
runs descriptor-compatible tests.(Additionally,
test
tasks will triggertestDescriptors
tasks.)./gradlew testDescriptors
runs descriptor-compatible tests (this is an alias oftest
, because it's easier to read)../gradlew testSymbols
runs symbols-compatible tests.Benefits