[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()
|
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.io.File
|
||||||
import java.time.*
|
import java.time.*
|
||||||
|
import java.util.concurrent.*
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id "org.jetbrains.kotlin.js" version "<pluginMarkerVersion>"
|
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") {
|
tasks.create("testCleanTask") {
|
||||||
description = "check clean task behaviour"
|
description = "check clean task behaviour"
|
||||||
doLast {
|
doLast {
|
||||||
|
|||||||
+1
@@ -2,6 +2,7 @@ pluginManagement {
|
|||||||
repositories {
|
repositories {
|
||||||
maven { url '<mavenLocalUrl>' }
|
maven { url '<mavenLocalUrl>' }
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
|
mavenCentral()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user