mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
Validate and assign the rest of the parameters. Check for android ones only. Add just small notes to the article
This commit is contained in:
@ -5,24 +5,37 @@ module.exports = {
|
|||||||
|
|
||||||
//Construct and validate the arguments
|
//Construct and validate the arguments
|
||||||
var args = {
|
var args = {
|
||||||
platform: grunt.option("platform")
|
platform: grunt.option("platform"),
|
||||||
tnsPath: grunt.option("tnsPath")
|
tnsPath: grunt.option("tnsPath"),
|
||||||
emulatorProcessIdentifier: grunt.option("emuPId")
|
emulatorProcessIdentifier: grunt.option("emuPId"),
|
||||||
emuAvdName: grunt.option("avdNameToStart")
|
emuAvdName: grunt.option("avd"),
|
||||||
outFile: grunt.option("logFilePath")
|
outFile: grunt.option("logFilePath"),
|
||||||
androidRuntimePath: grunt.option("androidRuntimePath")
|
androidRuntimePath: grunt.option("androidRuntimePath"),
|
||||||
|
showEmu: grunt.option("showEmu")
|
||||||
};
|
};
|
||||||
|
|
||||||
(function validateInput(){
|
(function validateInput(){
|
||||||
if (!(/^(Android|iOS)$/).test(args.platform)) { throw new Error("Invalid target platform specified! Use --platform=Android|iOS"); }
|
if (!(/^(Android|iOS)$/).test(args.platform)) {
|
||||||
|
throw new Error("Invalid target platform specified! Use --platform=Android|iOS");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.platform === "Android") {
|
||||||
|
if (!args.emulatorProcessIdentifier) {
|
||||||
|
throw new Error("Please, specify an identifier of the emulator process so that it can be stopped (--emuPId=...). Too many emulators started might cause machine overload");
|
||||||
|
}
|
||||||
|
if (!args.emuAvdName) {
|
||||||
|
throw new Error("Please, specify the name of the AVD to start (--avd=...).");
|
||||||
|
}
|
||||||
|
}
|
||||||
}());
|
}());
|
||||||
|
|
||||||
var localCfg = {
|
var localCfg = {
|
||||||
tnsPath: "tns",
|
tnsPath: args.tnsPath || "tns",
|
||||||
emulatorProcessIdentifier:".*emulator64-x86",
|
emulatorProcessIdentifier: args.emulatorProcessIdentifier,
|
||||||
emuAvdName:"Api19",
|
emuAvdName: args.emuAvdName,
|
||||||
outfile:"./TestRunResult.txt",
|
outfile: args.outFile || "./TestRunResult.txt",
|
||||||
androidFrameworkArgument: " --frameworkPath=/Users/erjan/tns-android.tgz",
|
androidFrameworkArgument: args.androidRuntimePath ? " --frameworkPath=" + args.androidRuntimePath : "",
|
||||||
|
showEmu: args.showEmu || false,
|
||||||
|
|
||||||
workingDir:".testsapprun",
|
workingDir:".testsapprun",
|
||||||
testsAppName:"TestsApp",
|
testsAppName:"TestsApp",
|
||||||
@ -91,7 +104,7 @@ module.exports = {
|
|||||||
exitCode: [0, 1]
|
exitCode: [0, 1]
|
||||||
},
|
},
|
||||||
startAndroidEmulator: {
|
startAndroidEmulator: {
|
||||||
cmd: "emulator -avd " + localCfg.emuAvdName + " -no-audio -no-window &",
|
cmd: "emulator -avd " + localCfg.emuAvdName + " -no-audio " + (args.showEmu ? "" : "-no-window") + "&",
|
||||||
stdout: true
|
stdout: true
|
||||||
},
|
},
|
||||||
createApp: {
|
createApp: {
|
||||||
|
@ -22,8 +22,10 @@ the following steps:
|
|||||||
- Android/iOS setup
|
- Android/iOS setup
|
||||||
- expect
|
- expect
|
||||||
|
|
||||||
|
# Arguments:
|
||||||
|
|
||||||
# Sample run:
|
# Sample run:
|
||||||
```
|
```
|
||||||
grunt testsapp --platform=Android [--tnsPath="tns"] --emuPId=".*emulator64-x86"
|
grunt testsapp --platform=Android [--tnsPath="tns"] --emuPId=".*emulator64-x86"
|
||||||
--emuAvdName="Api19" [--logFilePath="./TestRunResult.txt"] [--androidRuntimePath="./tns-android.tgz"]
|
--avd="Api19" [--logFilePath="./TestRunResult.txt"] [--androidRuntimePath="./tns-android.tgz"] --showEmu=true
|
||||||
```
|
```
|
||||||
|
Reference in New Issue
Block a user