Files
kotlin-fork/libraries/tools/kotlin-gradle-plugin-integration-tests
Sergey Igushkin d83d3304a5 KT-38221: Stdlib by default; KT-40225 Single dependency on kotlin-test
* Add a DSL property `kotlin.coreLibrariesVersion` that is used as the
  default version for all org.jetbrains.kotlin dependencies instead of
  the plugin version used previously – the pluging version is the
  default now.

* Support omitting the `kotlin-stdlib-*` dependencies in all kinds of
  projects. For the JVM source sets, choose the stdlib module by
  checking the jvmTarget in the compilations – if all compilations
  target 8+ then use `kotlin-stdlib-jdk8`.

* Support adding a single dependency on the fake module
  `kotlin-test-multiplatform` that is later expanded into the
  appropriate dependencies on `kotlin-test-*` modules. For JVM source
  sets, detect the test framework by inspecting the test tasks.

* (minor) Fix _executionSource not updated in KotlinJvmTestRun

* (minor) Lazily query `kotlinUsageContext`'s dependency-related
  properties to avoid freezing the configurations

Issue #KT-38221 Fixed
Issue #KT-40225 Fixed
2020-07-14 14:47:13 +04:00
..

Gradle Plugin Integration Tests

This module contains integration tests for libraries/tools/kotlin-gradle-plugin (and the subplugins mentioned there).

How to run

There are three Gradle tasks that run the tests:

  • Run all tests with the oldest possible Gradle version for each test:

    ./gradlew :kotlin-gradle-plugin-integration-tests:test
    
  • Run with the new Gradle release, choose only the tests that support this Gradle version:

    ./gradlew :kotlin-gradle-plugin-integration-tests:testAdvanceGradleVersion
    
  • Run the incremental compilation tests generated from the JPS ones

    ./gradlew :kotlin-gradle-plugin-integration-tests:testFromJps
    

The tests that use the Gradle plugins DSL (PluginsDslIT) also require the Gradle plugin marker artifacts to be installed:

./gradlew -Pdeploy_version=1.2-test :kotlin-gradle-plugin:plugin-marker:install :kotlin-noarg:plugin-marker:install :kotlin-allopen:plugin-marker:install
./gradlew -Pdeploy_version=1.2-test :kotlin-gradle-plugin-integration-tests:test

If you want to run only one test class, you need to set flag --tests with value of test class, which you want to run

  ./gradlew :kotlin-gradle-plugin-integration-tests:test --tests <class-name-with-package>

How to work with the tests

When you create a new test, figure out which Gradle versions it is supposed to run on. Then, when you instantiate a test project, specify one of:

  • project("someProjectName", GradleVersionRequired.None) or just project("someProjectName") the test can run on the whole range of the supported Gradle versions;
  • project("someProjectName", GradleVersionRequired.AtLeast("X.Y")) the test is supposed to run on Gradle version X.Y and newer (e.g. it tests integration with a Gradle feature that was released in version X.Y);
  • project("someProjectName", GradleVersionRequired.Exact("X.Y")) the test is supposed to run only with Gradle version X.Y (e.g. it tests a workaround for that version or records some special behavior that is not reproducible with newer versions).

⚠️ When your tests target multiple Gradle versions, make sure they pass when run with both tasks test and testAdvanceGradleVersion (see above). In the IDE, you can modify a test run configuration to use a Gradle task other than test.

You can check a Gradle version that the test runs with using Project.testGradleVersionAtLeast("X.Y") and Project.testGradleVersionBelow("X.Y").

Since Gradle output layouts differ from version to version, you can access classes and resources output directories using the functions that adapt to the Gradle version that is used for each test: