[Gradle, JS] Add test on not updating Node.JS if it was downloaded
^KT-47845 fixed
This commit is contained in:
+12
@@ -978,4 +978,16 @@ class GeneralKotlin2JsGradlePluginIT : BaseGradleIT() {
|
||||
assertNoWarnings()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNodeJsAndYarnDownload() = with(transformProjectWithPluginsDsl("cleanTask")) {
|
||||
|
||||
build("checkDownloadedFolder") {
|
||||
assertSuccessful()
|
||||
}
|
||||
|
||||
build("checkIfLastModifiedNotNow", "--rerun-tasks") {
|
||||
assertSuccessful()
|
||||
}
|
||||
}
|
||||
}
|
||||
+23
@@ -2,6 +2,7 @@ import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsPlatform
|
||||
|
||||
import java.io.File
|
||||
import java.time.*
|
||||
import java.util.concurrent.*
|
||||
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.js" version "<pluginMarkerVersion>"
|
||||
@@ -29,6 +30,28 @@ tasks.create("checkDownloadedFolder") {
|
||||
}
|
||||
}
|
||||
|
||||
tasks.create("checkIfLastModifiedNotNow") {
|
||||
description = "check if last modified is not current date now"
|
||||
dependsOn "build"
|
||||
doLast {
|
||||
println("check downloaded folder existance")
|
||||
def downloadedFolder = new File(project.gradle.gradleUserHomeDir, nodeJsLocation)
|
||||
if (!downloadedFolder.exists() || !downloadedFolder.isDirectory()) {
|
||||
throw new InvalidUserDataException("Downloaded folder was not found")
|
||||
}
|
||||
|
||||
def now = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()
|
||||
|
||||
def lastModified = downloadedFolder.lastModified()
|
||||
def lastModified1 = lastModified + TimeUnit.DAYS.toMillis(1);
|
||||
def lastModified2 = lastModified - TimeUnit.DAYS.toMillis(1);
|
||||
|
||||
if (now < lastModified1 || now < lastModified2) {
|
||||
throw new InvalidUserDataException("Last modified date was updated")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.create("testCleanTask") {
|
||||
description = "check clean task behaviour"
|
||||
doLast {
|
||||
|
||||
+1
@@ -2,6 +2,7 @@ pluginManagement {
|
||||
repositories {
|
||||
maven { url '<mavenLocalUrl>' }
|
||||
gradlePluginPortal()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user