Skip to content

Commit d69cf36

Browse files
committed
added grunt automatization
added needed node module
1 parent 1bd2b8a commit d69cf36

File tree

5 files changed

+112
-2
lines changed

5 files changed

+112
-2
lines changed

gruntfile.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,11 @@ module.exports = function(grunt) {
195195
},
196196
runMetadataGenerator: {
197197
cmd: "./node_modules/.bin/generate-metadata " + localCfg.libsDir + " ./dist/framework/assets/metadata"
198-
}
198+
},
199+
runTests: {
200+
cmd: "npm install && grunt --verbose",
201+
cwd: "./test-app"
202+
}
199203
}
200204
});
201205

@@ -206,7 +210,7 @@ module.exports = function(grunt) {
206210
grunt.loadNpmTasks("grunt-replace");
207211

208212
grunt.registerTask("generateRuntime", [
209-
"exec:generateRuntime"
213+
"exec:generateRuntime"
210214
]);
211215

212216
grunt.registerTask("generateMetadata", [
@@ -230,6 +234,10 @@ module.exports = function(grunt) {
230234
return [];
231235
}
232236
})());
237+
238+
grunt.registerTask("runTests", [
239+
"exec:runTests"
240+
]);
233241

234242
grunt.registerTask("default", [
235243
"clean:build",

test-app/ant.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
key.store.password=aaaaaa
2+
key.alias.password=aaaaaa
3+
key.store=./custom_sign.keystore
4+
key.alias=aaaa-alias

test-app/custom_sign.keystore

2.19 KB
Binary file not shown.

test-app/gruntfile.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
//runs test app on device
2+
3+
module.exports = function(grunt) {
4+
5+
var pathModule = require("path");
6+
7+
var args = {
8+
buildVersion: grunt.option("build-version") || "0.0.1",
9+
commitVersion: grunt.option("commit-version") || process.env.GIT_COMMIT || ""
10+
};
11+
12+
var localCfg = {
13+
rootDir: ".",
14+
outDir: "./dist",
15+
commitVersion: args.commitVersion,
16+
};
17+
18+
localCfg.jniDir = pathModule.join(localCfg.rootDir, "/jni"),
19+
localCfg.runtimeVersionHFile = pathModule.join(localCfg.rootDir, "/jni/Version.h"),
20+
localCfg.applicationMkFile = pathModule.join(localCfg.rootDir, "/jni/Application.mk"),
21+
22+
grunt.initConfig({
23+
wait: {
24+
forDelay: {
25+
options: {
26+
delay: 20000
27+
}
28+
}
29+
},
30+
clean: {
31+
build: {
32+
src: [localCfg.outDir]
33+
}
34+
},
35+
mkdir: {
36+
build: {
37+
options: {
38+
create: [localCfg.outDir]
39+
}
40+
}
41+
},
42+
exec: {
43+
createTestAppBuildFile: {
44+
cmd: "android update project --path ."
45+
},
46+
runAntCleanRelease: {
47+
cmd: "ant release"
48+
},
49+
installApkOnDevice: {
50+
cmd: "adb install -r NativeScriptActivity-release.apk",
51+
cwd: "./bin"
52+
},
53+
startInstalledApk: {
54+
cmd: "adb shell am start -n com.tns.android_runtime_testapp/com.tns.NativeScriptActivity -a android.intent.action.MAIN -c android.intent.category.LAUNCHER",
55+
cwd: "./bin"
56+
},
57+
copyResultToDist: {
58+
cmd: "adb pull /sdcard/android_unit_test_results.xml",
59+
cwd: localCfg.outDir
60+
}
61+
}
62+
});
63+
64+
grunt.loadNpmTasks("grunt-contrib-clean");
65+
grunt.loadNpmTasks("grunt-contrib-copy");
66+
grunt.loadNpmTasks("grunt-mkdir");
67+
grunt.loadNpmTasks("grunt-exec");
68+
grunt.loadNpmTasks("grunt-replace");
69+
grunt.loadNpmTasks('grunt-wait');
70+
71+
grunt.registerTask("default", [
72+
"clean:build",
73+
"mkdir:build",
74+
"exec:createTestAppBuildFile",
75+
"exec:runAntCleanRelease",
76+
"exec:installApkOnDevice",
77+
"exec:startInstalledApk",
78+
"wait:forDelay",
79+
"exec:copyResultToDist"
80+
]);
81+
82+
}

test-app/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "tns-test-app",
3+
"description": "NativeScript test app",
4+
"files": [
5+
"**/*.*"
6+
],
7+
"devDependencies": {
8+
"grunt": "0.4.5",
9+
"grunt-contrib-clean": "0.5.0",
10+
"grunt-contrib-copy": "0.5.0",
11+
"grunt-exec": "0.4.6",
12+
"grunt-mkdir": "0.1.2",
13+
"grunt-replace": "0.7.9",
14+
"grunt-wait": "^0.1.0"
15+
}
16+
}

0 commit comments

Comments
 (0)