Skip to content

Commit ff813e3

Browse files
authored
Merge pull request #865 from NativeScript/pete/include-tests-runtime-build
Update ASBG parser and ASBG generated classes tests to run on travis CI
2 parents 65f217d + eb69d4d commit ff813e3

File tree

5 files changed

+61
-13
lines changed

5 files changed

+61
-13
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ script:
5151
- echo no | android create avd --force -n $EMULATOR_NAME-$EMULATOR_API_LEVEL -t android-$EMULATOR_API_LEVEL --abi $ANDROID_ABI -c 12M
5252
- emulator -avd $EMULATOR_NAME-$EMULATOR_API_LEVEL -no-skin -no-audio -no-window &
5353
- android-wait-for-emulator
54+
- cd android-static-binding-generator
55+
- "npm install"
56+
- "node run-tests"
57+
- cd ..
58+
- "android-static-binding-generator/project/staticbindinggenerator/gradlew clean test --project-dir android-static-binding-generator/project/staticbindinggenerator/"
5459
- "cd test-app && ./gradlew runtest --stacktrace"
5560
- adb -e logcat -d 300
5661
- cd ..

android-static-binding-generator/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
"name": "static_analysis",
33
"version": "1.0.0",
44
"description": "",
5-
"main": "project/parse.js",
5+
"main": "project/parser",
66
"scripts": {
7-
"test": "jasmine JASMINE_CONFIG_PATH=jasmine.json"
7+
"test": "node run-tests.js"
88
},
9+
"repository": "https://github.com/NativeScript/android-runtime/",
910
"author": "",
1011
"license": "ISC",
1112
"dependencies": {
@@ -15,6 +16,7 @@
1516
"lazy": "^1.0.11"
1617
},
1718
"devDependencies": {
18-
"jasmine-node": "^1.14.5"
19+
"jasmine": "2.8.0",
20+
"jasmine-node": "1.14.5"
1921
}
2022
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
(function () {
2+
let { spawnSync, execSync } = require('child_process');
3+
4+
console.log("Installing JavaScript parser test dependencies.");
5+
6+
let npmInstallResult = execSync('npm install');
7+
8+
console.log(npmInstallResult.toString());
9+
10+
console.log("Executing JavaScript parser tests using Jasmine.");
11+
12+
const subprocess = spawnSync('node', ['./node_modules/jasmine/bin/jasmine.js', 'JASMINE_CONFIG_PATH=jasmine.json'], { cwd: __dirname });
13+
14+
let stdout = subprocess.stdout.toString();
15+
let stderr = subprocess.stderr.toString();
16+
let code = subprocess.status;
17+
let err = subprocess.error;
18+
19+
if (code !== 0) {
20+
console.log("Tests runner exited with a non-zero code.");
21+
22+
let errorString = stdout;
23+
24+
if (err) {
25+
errorString = err;
26+
}
27+
28+
if (stderr) {
29+
errorString = stderr;
30+
}
31+
32+
throw new Error(errorString);
33+
}
34+
35+
console.log(stdout);
36+
}());

android-static-binding-generator/tests/specs/ast-parser-tests.spec.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
'use strict';
2-
3-
var exec = require("child_process").exec,
1+
const exec = require("child_process").exec,
42
path = require("path"),
53
fs = require("fs"),
64
prefix = path.resolve(__dirname, "../cases/"),
75
interfaceNames = path.resolve(__dirname, "../interfaces-names.txt"),
86
gradleTraverse = path.resolve(__dirname, "../../project"),
97
gradleTaskName = "traverseJsFilesArgs",
10-
parser = path.resolve(__dirname, "../../project/parser/js_parser.js");
8+
parser = path.resolve(__dirname, "../../project/parser/js_parser.js"),
9+
gradleExecutable = path.resolve(__dirname, "../../project/staticbindinggenerator/gradlew");
1110

1211
function execGradle(inputPath, bindingsOutput, jsFilesInput, callback) {
13-
exec("gradle -p " + gradleTraverse + " " + gradleTaskName + " -Ptest -PjsCodeDir=\"" + inputPath + "\" -PbindingsFilePath=\"" + bindingsOutput + "\" -PinterfaceNamesFilePath=\"" + interfaceNames + "\" -PjsParserPath=\"" + parser + "\" -PjsFilesParameter=\"" + jsFilesInput + "\"", callback);
12+
exec(`${gradleExecutable} -p ${gradleTraverse} ${gradleTaskName} -Ptest -PjsCodeDir="${inputPath}" -PbindingsFilePath="${bindingsOutput}" -PinterfaceNamesFilePath="${interfaceNames}" -PjsParserPath="${parser}" -PjsFilesParameter="${jsFilesInput}"`, callback);
1413
}
1514

1615
function logExecResult(stdout, stderr) {
@@ -35,9 +34,11 @@ function clearOutput(bindingsOutput, jsFilesInput) {
3534
}
3635

3736
describe("parser/js_parser tests", function () {
37+
beforeAll(() => {
38+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 20 * 1000; // give enough time to start the gradle daemon
39+
});
3840

39-
describe("js_parser tests", function () {
40-
41+
describe("Traversal tests", function () {
4142
it("Analyse files only in the correct folder structure", function (done) {
4243

4344
let input = path.normalize(prefix + "/mini_app/app"),
@@ -213,7 +214,6 @@ describe("parser/js_parser tests", function () {
213214
console.error(`exec error: ${error}`);
214215
return;
215216
}
216-
217217
logExecResult(stdout, stderr)
218218

219219
let bindingsContent = fs.readFileSync(output, "utf-8").toString().trim().split('\n');

build.gradle

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,16 @@ task generateStaticBindingGeneratorJar(type: Exec) {
219219
doFirst {
220220
workingDir "$rootDir/android-static-binding-generator/project/staticbindinggenerator"
221221

222+
223+
def commandArgs = ["assemble"]
224+
222225
if (isWinOs) {
223-
commandLine "cmd", "/c", "gradlew", "assemble"
226+
commandLine "cmd", "/c", "gradlew"
224227
} else {
225-
commandLine "./gradlew", "assemble"
228+
commandLine "./gradlew"
226229
}
230+
231+
args commandArgs
227232
}
228233

229234
}

0 commit comments

Comments
 (0)