Skip to content

Commit 1485aba

Browse files
committed
Run tests in travis-CI
Add android definitions to check if they will get downloaded Set the language to android Attempt starting the app Add a new redirection to the testapp-runner - a runOnly verb Disable the install prompt Enable the buildOnly- and runOnly- commands Fix the version of the packages Comment cleanup code. Workflow to be reworked Install android 23 to make the app build Build the test app with the @next android runtime Add @next ability. Build with it Specify oracle java version 8 Use switcher to switch to oraclejdk8 Switch to a single step so that build breaks on first failure Reorder attempting to use higher nodejs Attempt using node 5.10.1 Detect test failure Add detection for test failures Decrease verbosity Extract the test checkers to a separate script Unignore the build folder recursively. Add the fixed script Remove the redundant node-version messages Run the tests with Api level 21
1 parent 24d0db7 commit 1485aba

File tree

5 files changed

+66
-11
lines changed

5 files changed

+66
-11
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package/
1818
!css-value/**/*.*
1919
!fetch/**/*.*
2020
!apps/TelerikNEXT/lib/**/*.*
21-
!build/*.*
21+
!build/**/*.*
2222
CrossPlatformModules.sln.ide/
2323
*.suo
2424
CrossPlatformModules.suo

.travis.yml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
1-
language: node_js
1+
sudo: required
2+
dist: trusty
3+
language: android
24
node_js:
3-
4.2.3
5+
- 4.2.3
6+
jdk:
7+
- oraclejdk8
8+
android:
9+
components:
10+
- platform-tools
11+
- tools
12+
- build-tools-23.0.3
13+
- android-21
14+
- android-23
15+
- extra-android-support
16+
- extra-android-m2repository
17+
- sys-img-armeabi-v7a-android-21
18+
419
before_script:
20+
- nvm install 5.10.1
521
- npm install -g grunt-cli
622
- npm install
723
- (cd build/platform-declarations && npm install)
24+
- echo no | android create avd --force -n Arm21 -t android-21 -b armeabi-v7a -c 12M
25+
- emulator -avd Arm21 -no-skin -no-audio -no-window &
26+
- android-wait-for-emulator
827
script:
9-
- grunt default
10-
- (cd build/platform-declarations && grunt)
28+
- jdk_switcher use oraclejdk8
29+
- grunt default &&
30+
(cd build/platform-declarations && grunt) &&
31+
echo no | npm install nativescript -g > /dev/null &&
32+
grunt buildOnlyTestsApp --platform=Android --modulesPath=./bin/dist/tns-core-modules-2.0.0.tgz --runtimeVersion=next --emuPId=.*emulator.* --avd=Api21 --showEmu=false > /dev/null &&
33+
grunt runOnlyTestsApp --platform=Android --modulesPath=./bin/dist/tns-core-modules-2.0.0.tgz --emuPId=.*emulator.* --avd=Api21 --showEmu=false
34+
35+
- node ./build/travis-scripts/check-testrun-broken.js

build/run-testsapp.grunt.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = {
1414
emuAvdName: grunt.option("avd"),
1515
outFile: grunt.option("logFilePath"),
1616
runtimePath: grunt.option("runtimePath"),
17+
runtimeVersion: grunt.option("runtimeVersion"),
1718
showEmu: grunt.option("showEmu"),
1819
runAppOnly: grunt.option("runAppOnly"),
1920
pathToApp: grunt.option("pathToApp")
@@ -45,6 +46,7 @@ module.exports = {
4546
emuAvdName: args.emuAvdName,
4647
outFile: args.outFile || "./TestRunResult.txt",
4748
frameworkArgument: args.runtimePath ? " --frameworkPath=" + args.runtimePath : "",
49+
runtimeVersionArgument: args.runtimeVersion ? "@" + args.runtimeVersion : "",
4850
showEmu: args.showEmu || false,
4951
runAppOnly: args.runAppOnly || false,
5052

@@ -238,7 +240,7 @@ module.exports = {
238240
}
239241
},
240242
addPlatform: {
241-
command: "tns platform add " + localCfg.platform.toLowerCase() + " " + localCfg.frameworkArgument,
243+
command: "tns platform add " + localCfg.platform.toLowerCase() + localCfg.runtimeVersionArgument + " " + localCfg.frameworkArgument,
242244
options: {
243245
execOptions: {
244246
maxBuffer: Infinity,
@@ -286,7 +288,7 @@ module.exports = {
286288
]);
287289

288290
grunt.registerTask("cleanup", [
289-
getPlatformSpecificTask("exec:kill{platform}Emulator"),
291+
// getPlatformSpecificTask("exec:kill{platform}Emulator"),
290292
"clean:workingDir"
291293
]);
292294

@@ -310,9 +312,10 @@ module.exports = {
310312
"buildOnly"
311313

312314
]);
315+
grunt.registerTask("buildOnlyTestsApp", ["buildTestsApp"]);
313316

314317
grunt.registerTask("runOnly", [
315-
getPlatformSpecificTask("doPreUninstallApp{platform}"),
318+
// getPlatformSpecificTask("doPreUninstallApp{platform}"),
316319

317320
getPlatformSpecificTask("exec:uninstallExisting{platform}App"),
318321
getPlatformSpecificTask("exec:installNew{platform}App"),
@@ -321,13 +324,15 @@ module.exports = {
321324
]);
322325

323326
grunt.registerTask("runApp", [
324-
"cleanup",
325-
getPlatformSpecificTask("startEmulator{platform}"),
327+
// "cleanup",
328+
// getPlatformSpecificTask("startEmulator{platform}"),
326329
"runOnly",
327330
"cleanup"
328331

329332
]);
330333

334+
grunt.registerTask("runOnlyTestsApp", ["runApp"]);
335+
331336

332337
var tasksToExecute = ["runApp"];
333338
if (!localCfg.runAppOnly) {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env node
2+
var fsModule = require('fs');
3+
var resultsFile = 'TestRunResult.txt';
4+
var successMarker ='=== ALL TESTS COMPLETE ===';
5+
var passMarker = /=== ALL TESTS COMPLETE ===\s+[^\n]*OK,\s+0\s+failed/mg;
6+
7+
var messages = {
8+
crash: 'TEST RUN CRASHED!',
9+
runGood: 'Test run exited successfully',
10+
pass: 'NativeScript Cross-Platform Module Tests passed',
11+
fail: 'TEST FAILURES FOUND!'
12+
};
13+
14+
var results = fsModule.readFileSync(resultsFile, 'utf-8');
15+
16+
if (results.indexOf(successMarker) == -1) {
17+
console.log(messages.crash);
18+
process.exit(1);
19+
} else if (results.match(passMarker)) {
20+
console.log(messages.pass);
21+
process.exit(0);
22+
} else {
23+
console.log(messages.fail);
24+
process.exit(1);
25+
}

gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = function(grunt) {
88
require('time-grunt')(grunt);
99
}
1010

11-
if (grunt.cli.tasks.indexOf("testsapp") >= 0 || grunt.cli.tasks.indexOf("buildTestsApp")>= 0) {
11+
if (grunt.cli.tasks.indexOf("testsapp") >= 0 || grunt.cli.tasks.indexOf("buildOnlyTestsApp")>= 0 || grunt.cli.tasks.indexOf("runOnlyTestsApp")>= 0) {
1212
var tsTester = require("./build/run-testsapp.grunt.js");
1313
tsTester.run(grunt);
1414
return;

0 commit comments

Comments
 (0)