Skip to content
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

Merged
merged 12 commits into from
Mar 22, 2024

Conversation

adam-enko
Copy link
Contributor

@adam-enko adam-enko commented Mar 8, 2024

Summary

  • 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

Usage

  • ./gradlew test runs descriptor-compatible tests.
    (Additionally, test tasks will trigger testDescriptors tasks.)
  • ./gradlew testDescriptors runs descriptor-compatible tests (this is an alias of test, because it's easier to read).
  • ./gradlew testSymbols runs symbols-compatible tests.

Benefits

  • Using JVM Test Suites unifies common test configuration for each of the test/descriptorsTest/symbolsTest tasks, so custom tasks aren't required
  • Avoiding custom tasks will help with Configuration Cache compliance.
  • Tagged tests are run in separate tasks, so the same tests aren't run multiple times with different tasks.
  • Remove deprecated behaviour - see Build Scan warning "Relying on the convention for Test.classpath in custom Test tasks has been deprecated."

- 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
@adam-enko adam-enko added the infrastructure Everything related to builds tools, CI configurations and project tooling label Mar 8, 2024
@adam-enko adam-enko self-assigned this Mar 11, 2024
@adam-enko adam-enko marked this pull request as ready for review March 11, 2024 13:30
@adam-enko
Copy link
Contributor Author

Hi @vmishenev 👋, I've added you as a reviewer since you created this convention plugin.

useJUnitPlatform {
excludeTags.addAll(descriptorTags + symbolsTags)
}
classpath += descriptorsTestImplementationResolver.incoming.files

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 ?

Copy link
Contributor Author

@adam-enko adam-enko Mar 12, 2024

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.

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!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, thanks!

Copy link
Contributor

@whyoleg whyoleg Mar 13, 2024

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 K1
  • descriptorsTest will run only marked for descriptors tests with K1
  • symbolsTest 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 excluding OnlySymbols with K1 runtime
  • symbolsTest will run ALL tests excluding OnlyDescriptors with K2 runtime
  • test will just run both symbolsTest and descriptorsTest, but don't run ALL tests one more time

Does it help?

Copy link
Member

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 excluding OnlySymbols with K1 runtime
  • symbolsTest will run ALL tests excluding OnlyDescriptors with K2 runtime

Copy link
Contributor

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 K1
  • symbolsTest - runs test with K2
  • test - configured the same as descriptorsTest, so runs tests with K1 + runs symbolsTest - so when running test 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
image

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

Copy link
Contributor Author

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

Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Member

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.

./gradlew test --stacktrace --no-daemon --no-parallel

# Conflicts:
#	build-logic/settings.gradle.kts
useJUnitPlatform {
excludeTags.addAll(descriptorTags + symbolsTags)
}
classpath += descriptorsTestImplementationResolver.incoming.files
Copy link
Contributor

@whyoleg whyoleg Mar 13, 2024

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 K1
  • descriptorsTest will run only marked for descriptors tests with K1
  • symbolsTest 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 excluding OnlySymbols with K1 runtime
  • symbolsTest will run ALL tests excluding OnlyDescriptors with K2 runtime
  • test will just run both symbolsTest and descriptorsTest, but don't run ALL tests one more time

Does it help?

@adam-enko adam-enko requested a review from whyoleg March 15, 2024 12:37
build-logic/src/main/kotlin/dokkabuild.test-k2.gradle.kts Outdated Show resolved Hide resolved
useJUnitPlatform {
excludeTags.addAll(descriptorTags + symbolsTags)
}
classpath += descriptorsTestImplementationResolver.incoming.files
Copy link
Contributor

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?

@adam-enko adam-enko merged commit 1ed0186 into master Mar 22, 2024
12 checks passed
@adam-enko adam-enko deleted the build-logic/update-test-k2 branch March 22, 2024 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure Everything related to builds tools, CI configurations and project tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants