Skip to content

Commit a7d980a

Browse files
committed
JS: use Mocha + NodeJs instead of Karma + PhantomJs to run stdlib tests (again)
1 parent a3f8816 commit a7d980a

File tree

2 files changed

+32
-24
lines changed

2 files changed

+32
-24
lines changed

compiler/tests/org/jetbrains/kotlin/code/CodeConformanceTest.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class CodeConformanceTest : TestCase() {
3434
"js/js.translator/testData/node_modules",
3535
"libraries/kotlin.test/js/it/.gradle",
3636
"libraries/kotlin.test/js/it/node_modules",
37-
"libraries/stdlib/js/node_modules",
37+
"libraries/stdlib/js/.gradle",
38+
"libraries/stdlib/js/build",
3839
"libraries/reflect/build",
3940
"libraries/tools/binary-compatibility-validator/src/main/kotlin/org.jetbrains.kotlin.tools",
4041
"dependencies",
@@ -59,6 +60,7 @@ class CodeConformanceTest : TestCase() {
5960
"js/js.translator/testData/node_modules",
6061
"libraries/stdlib/common/build",
6162
"libraries/stdlib/common/target",
63+
"libraries/stdlib/js/.gradle",
6264
"libraries/stdlib/js/build",
6365
"libraries/kotlin.test/js/it/.gradle",
6466
"libraries/kotlin.test/js/it/node_modules",

libraries/stdlib/js/build.gradle

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'com.craigburke.karma' version '1.4.4'
2+
id "com.moowork.node" version "1.2.0"
33
}
44

55
description = 'Kotlin Standard Library for JS'
@@ -162,7 +162,7 @@ compileExperimentalKotlin2Js {
162162
compileTestKotlin2Js {
163163
dependsOn preprocessSourcesTest
164164
kotlinOptions {
165-
moduleKind = "plain"
165+
moduleKind = "umd"
166166
}
167167
}
168168

@@ -301,33 +301,39 @@ dist {
301301
}
302302
}
303303

304+
task populateNodeModules(type: Copy, dependsOn: [compileJs, compileTestKotlin2Js]) {
305+
from jsOutputFile
306+
from kotlinTestJsOutputFile
304307

305-
karma {
306-
308+
into "${buildDir}/node_modules"
309+
}
307310

308-
frameworks = ['qunit']
309-
browsers = ['PhantomJS']
311+
node {
312+
download = true
313+
version = '8.9.4' // The default 6.9.1 has buggy hyperbolic functions implementation
314+
nodeModulesDir = buildDir
315+
}
310316

311-
if (project.hasProperty("teamcity")) {
312-
reporters = ['teamcity']
313-
}
317+
task installMocha(type: NpmTask, dependsOn: [populateNodeModules]) {
318+
args = ['install', 'mocha']
319+
}
314320

315-
profile('default') {
316-
libraryBases = ['']
317-
libraryFiles = [jsOutputFile, kotlinTestJsOutputFile]
321+
task installTeamcityReporter(type: NpmTask, dependsOn: [populateNodeModules]) {
322+
args = ['install', 'mocha-teamcity-reporter']
323+
}
324+
325+
task runMocha(type: NodeTask, dependsOn: [compileTestKotlin2Js, populateNodeModules, installMocha]) {
326+
script = file("${buildDir}/node_modules/mocha/bin/mocha")
327+
args = [jsTestOutputFile]
318328

319-
sourceBases = []
320-
sourceFiles = []
329+
if (project.hasProperty("teamcity")) {
330+
dependsOn installTeamcityReporter
331+
args = ['--reporter', 'mocha-teamcity-reporter'] + args
321332

322-
testBases = ['']
323-
testFiles = [jsTestOutputFile, kotlinTestJsTestOutputFile]
333+
execOverrides {
334+
it.ignoreExitValue = true
335+
}
324336
}
325337
}
326338

327-
karmaGenerateConfig.outputs.upToDateWhen { false }
328-
karmaRun {
329-
ignoreExitValue = Boolean.valueOf(ignoreTestFailures)
330-
dependsOn testClasses
331-
dependsOn tasks.getByPath(':kotlin-test:kotlin-test-js:testClasses')
332-
}
333-
clean.dependsOn karmaClean
339+
test.dependsOn runMocha

0 commit comments

Comments
 (0)