From 9e6ce564a03ae924d9f8731f64aed61b1b08eb9c Mon Sep 17 00:00:00 2001 From: Erjan Gavalji Date: Mon, 2 Nov 2015 13:18:15 +0200 Subject: [PATCH] Add runOnly command --- build/run-testsapp.grunt.js | 82 +++++++++++++++++++++++++------------ gruntfile.js | 2 +- run.sh | 9 ++++ 3 files changed, 65 insertions(+), 28 deletions(-) create mode 100755 run.sh diff --git a/build/run-testsapp.grunt.js b/build/run-testsapp.grunt.js index 049481b29..ac5c0419c 100644 --- a/build/run-testsapp.grunt.js +++ b/build/run-testsapp.grunt.js @@ -14,7 +14,9 @@ module.exports = { emuAvdName: grunt.option("avd"), outFile: grunt.option("logFilePath"), runtimePath: grunt.option("runtimePath"), - showEmu: grunt.option("showEmu") + showEmu: grunt.option("showEmu"), + runAppOnly: grunt.option("runAppOnly"), + pathToApp: grunt.option("pathToApp") }; (function validateInput(){ @@ -30,6 +32,10 @@ module.exports = { throw new Error("Please, specify the name of the AVD to start (--avd=...)."); } } + + if (args.runAppOnly && !args.pathToApp) { + throw new Error("runAppOnly called, but no path to application specified. Please, add the path via the (--pathToApp=...) parameter."); + } }()); var localCfg = { @@ -40,6 +46,7 @@ module.exports = { outFile: args.outFile || "./TestRunResult.txt", frameworkArgument: args.runtimePath ? " --frameworkPath=" + args.runtimePath : "", showEmu: args.showEmu || false, + runAppOnly: args.runAppOnly || false, workingDir:".testsapprun", testsAppName:"TestsApp", @@ -54,6 +61,10 @@ module.exports = { platform: args.platform } + if (localCfg.runAppOnly) { + localCfg.pathToApp = localCfg.pathToApk = args.pathToApp; + } + grunt.initConfig({ clean: { workingDir: { @@ -260,40 +271,57 @@ module.exports = { "copy:simulatorLog" ]); - grunt.registerTask("doPostPlatformAddAndroid", [ + grunt.registerTask("doPreUninstallAppAndroid", [ "exec:restartAdb" ]); - grunt.registerTask("doPostPlatformAddiOS", [ + grunt.registerTask("doPreUninstallAppiOS", [ "clean:simulatorLog" ]); - grunt.registerTask("testsapp", [ - "clean:workingDir", - "mkdir:workingDir", - getPlatformSpecificTask("exec:kill{platform}Emulator"), - getPlatformSpecificTask("startEmulator{platform}"), + grunt.registerTask("buildTestsApp", [ + "clean:workingDir", + "mkdir:workingDir", + getPlatformSpecificTask("exec:kill{platform}Emulator"), + getPlatformSpecificTask("startEmulator{platform}"), - "exec:createApp", - "clean:originalAppDir", - "copy:testsAppToRunDir", - "clean:modules", - "untar:modules", - "copy:modulesToDir", - "clean:tempExtractedModules", + "exec:createApp", + "clean:originalAppDir", + "copy:testsAppToRunDir", + "clean:modules", + "untar:modules", + "copy:modulesToDir", + "clean:tempExtractedModules", - "exec:addPlatform", - getPlatformSpecificTask("copy:add{platform}Permissions"), - "shell:buildApp", - getPlatformSpecificTask("doPostPlatformAdd{platform}"), - - getPlatformSpecificTask("exec:uninstallExisting{platform}App"), - getPlatformSpecificTask("exec:installNew{platform}App"), - getPlatformSpecificTask("exec:start{platform}App"), - getPlatformSpecificTask("collectLog{platform}"), - - getPlatformSpecificTask("exec:kill{platform}Emulator"), - "clean:workingDir" + "exec:addPlatform", + getPlatformSpecificTask("copy:add{platform}Permissions"), + "shell:buildApp", ]); + + grunt.registerTask("runApp", [ + getPlatformSpecificTask("doPreUninstallApp{platform}"), + + getPlatformSpecificTask("exec:uninstallExisting{platform}App"), + getPlatformSpecificTask("exec:installNew{platform}App"), + getPlatformSpecificTask("exec:start{platform}App"), + getPlatformSpecificTask("collectLog{platform}"), + + ]); + + grunt.registerTask("cleanup", [ + getPlatformSpecificTask("exec:kill{platform}Emulator"), + "clean:workingDir" + ]); + + var tasksToExecute = ["runApp"]; + if (!localCfg.runAppOnly) { + tasksToExecute = [ + "buildTestsApp", + "runApp", + "cleanup" + ]; + } + + grunt.registerTask("testsapp", tasksToExecute); } } diff --git a/gruntfile.js b/gruntfile.js index b584ab7b9..ea3771fb7 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -1,6 +1,6 @@ module.exports = function(grunt) { - if (grunt.cli.tasks.indexOf("testsapp") >= 0) { + if (grunt.cli.tasks.indexOf("testsapp") || grunt.cli.tasks.indexOf("buildtestsapp")>= 0) { var tsTester = require("./build/run-testsapp.grunt.js"); tsTester.run(grunt); } else { diff --git a/run.sh b/run.sh new file mode 100755 index 000000000..4adee5a70 --- /dev/null +++ b/run.sh @@ -0,0 +1,9 @@ +#! /bin/bash + +#grunt testsapp --verbose --platform=Android --emuPId=".*emulator64-x86" --avd="Api19" --logFilePath="./TestRunResult.txt" --runtimePath="/Users/erjan/tns-android.tgz" --showEmu=true --modulesPath=/Volumes/distributions/DailyBuilds/NativeScript/tns-modules/Stable/tns-core-modules.tgz + +#grunt testsapp --verbose --platform=iOS --logFilePath="./TestRunResult.txt" --runtimePath="/Users/erjan/tns-ios.tgz" --showEmu=true --modulesPath=/Volumes/distributions/DailyBuilds/NativeScript/tns-modules/Stable/tns-core-modules.tgz --avd="'iPhone 6 (9.0) ['" + +grunt buildTestsApp --verbose --platform=iOS --logFilePath="./TestRunResult.txt" --runtimePath="/Users/erjan/tns-ios.tgz" --showEmu=true --modulesPath=/Volumes/distributions/DailyBuilds/NativeScript/tns-modules/Stable/tns-core-modules.tgz --avd="'iPhone 6 (9.0) ['" + +#grunt testsapp --verbose --platform=iOS --runAppOnly --logFilePath="./TestRunResult.txt" --runtimePath="/Users/erjan/tns-ios.tgz" --showEmu=true --modulesPath=/Volumes/distributions/DailyBuilds/NativeScript/tns-modules/Stable/tns-core-modules.tgz --avd="'iPhone 6 (9.0) ['"