[Test] `assertValueAgnosticEqualsToFile` in `testJsonReports`
Fix the test-data accordingly
diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt
index 2e6a4b0..b9e645e 100644
--- a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt
+++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt
@@ -1025,29 +1025,11 @@
withSystemProperty("kotlin.build.report.json.output_dir",reportDir.absolutePath) {
buildAllModules()
}
- assertEquals(1, reportDir.listFiles().size)
- //Unfortunately, NumberAgnosticSanitizer is not enough
- val expected = workDir.resolve("expectedReport.json").readText()
- .replace("{", "\\{")
- .replace("}", "\\}")
- .replace("[", "\\[")
- .replace("]", "\\]")
- .replace("\$KSecondPath\$", workDir.resolve("src/kotlin/KSecond.kt").absolutePath)
- .replace("\$BUILD_ID\$", "[a-zA-Z0-9_-]+")
- .replace("\$TIME\$", "[0-9]+")
- .replace("\$HOST\$", ".*")
+ val expectedJsonTemplate = originalProjectDir.resolve("expectedReport.json")
+ val actualJson = reportDir.listFiles()!!.single().readText()
- val jsonReport = reportDir.listFiles().first().readText()
- val matches = Regex(expected).find(jsonReport)
- assertNotNull(
- """
- Build report:
- $jsonReport
- does not fit the expected pattern:
- $expected
- """.trimIndent(), matches
- )
+ KotlinTestUtils.assertValueAgnosticEqualsToFile(expectedJsonTemplate, actualJson)
}
private fun BuildResult.checkErrors() {
diff --git a/jps/jps-plugin/testData/general/JsonReports/expectedReport.json b/jps/jps-plugin/testData/general/JsonReports/expectedReport.json
index 30407fb..1329022 100644
--- a/jps/jps-plugin/testData/general/JsonReports/expectedReport.json
+++ b/jps/jps-plugin/testData/general/JsonReports/expectedReport.json
@@ -3,14 +3,14 @@
"projectName": "kotlinProject",
"taskName": "kotlinProject",
"taskResult": "NOTHING_DONE",
- "startTimeMs": $TIME$,
- "durationMs": $TIME$,
+ "startTimeMs": $UINT$,
+ "durationMs": $UINT$,
"tags": [],
"changes": [],
- "buildUuid": "$BUILD_ID$",
+ "buildUuid": $QUOTEDSTRING$,
"kotlinVersion": "kotlin_version",
- "hostName": "$HOST$",
- "finishTime": $TIME$,
+ "hostName": $QUOTEDSTRING$,
+ "finishTime": $UINT$,
"compilerArguments": [],
"nonIncrementalAttributes": [],
"buildTimesMetrics": {},
@@ -26,20 +26,20 @@
"projectName": "kotlinProject",
"taskName": "kotlinProject",
"taskResult": "CHUNK_REBUILD_REQUIRED",
- "startTimeMs": $TIME$,
- "durationMs": $TIME$,
+ "startTimeMs": $UINT$,
+ "durationMs": $UINT$,
"tags": [],
"changes": [
- "$KSecondPath$"
+ $QUOTEDSTRING$
],
- "buildUuid": "$BUILD_ID$",
+ "buildUuid": $QUOTEDSTRING$,
"kotlinVersion": "kotlin_version",
- "hostName": "$HOST$",
- "finishTime": $TIME$,
+ "hostName": $QUOTEDSTRING$,
+ "finishTime": $UINT$,
"compilerArguments": [],
"nonIncrementalAttributes": [],
"buildTimesMetrics": {
- "JPS_ITERATION": $TIME$
+ "JPS_ITERATION": $UINT$
},
"performanceMetrics": {},
"gcTimeMetrics": {},
@@ -53,21 +53,21 @@
"projectName": "kotlinProject",
"taskName": "kotlinProject",
"taskResult": "OK",
- "startTimeMs": $TIME$,
- "durationMs": $TIME$,
+ "startTimeMs": $UINT$,
+ "durationMs": $UINT$,
"tags": [],
"changes": [
- "$KSecondPath$"
+ $QUOTEDSTRING$
],
- "buildUuid": "$BUILD_ID$",
+ "buildUuid": $QUOTEDSTRING$,
"kotlinVersion": "kotlin_version",
"kotlinLanguageVersion": "2.2",
- "hostName": "$HOST$",
- "finishTime": $TIME$,
+ "hostName": $QUOTEDSTRING$,
+ "finishTime": $UINT$,
"compilerArguments": [],
"nonIncrementalAttributes": [],
"buildTimesMetrics": {
- "JPS_ITERATION": $TIME$
+ "JPS_ITERATION": $UINT$
},
"performanceMetrics": {},
"gcTimeMetrics": {},