Google+ Followers

Monday, 2 March 2015

Expect script to compile Titanium project and add calabash framework to it using ticalabash

Expect script is bit advanced version of shell script
Where terminal can wait for the result of the previous command and execute the next query based on the output of the previous result.
Take a look at this amazing blog for expect script examples - http://www.thegeekstuff.com/2010/10/expect-examples/

TiCalabash is a package which can be used to add calabash to Titanium project and execute tests. - https://github.com/appersonlabs/TiCalabash


Below shell script does the following sequence of steps 

  1. Cleans Project
  2. Builds project
  3. Adds calabash-ios framework to code and creates -cal scheme
  4. compile the project with calabash framework added



#!/usr/bin/expect
#!/bin/sh

set arg1 [lindex $argv 0]

set timeout 20
spawn ti clean
expect {
    "Project cleaned successfully" { puts "STEP 1 DONE" }
    timeout { puts "failed to find text"; exit 1 }
}


if { $arg1 == "phone" } {
 spawn ti build -p ios -b;
 puts "expect.exp - Phone build"
} elseif { $arg1 == "tablet" } {
 spawn ti build -p ios -Y ipad -b --retina;
 puts "expect.exp - Tablet build"
}

set timeout 400
expect {
    "Initiating Xcode pre-compile" { puts "STEP 2 DONE" }
    timeout { puts "*** FAILED TO FIND - Initiating Xcode pre-compile "; exit 1 }
}

expect {
    "Project built successfully" { puts "STEP 3 DONE" }
    timeout { puts "*** FAILED TO FIND - Project built successfully "; exit 1 }
}

set timeout 20
spawn ti calabash —platform=iphone
expect "Please answer yes (y) or no (n)"  { send "n\r" }

set timeout 200
expect {
    "Default target:" { send "\r" }
    timeout { puts "failed to find text"; exit 1 }
}

expect {
    "Setup done" { puts "STEP 4 DONE" }
 timeout { puts "failed to find text: Setup done"; exit 1}
}


expect {
 "** BUILD SUCCEEDED **" {}
 timeout { puts "failed to find text"; exit 1 }
}

2 comments:


  1. I’ve been browsing on-line greater than three hours today, but I never discovered any attention-grabbing article like yours. It is beautiful worth sufficient for me. Personally, if all webmasters and bloggers made good content material as you did, the net will be a lot more helpful than ever before.
    iOS Training in Chennai
    Android Training in Chennai
    php Training in Chennai

    ReplyDelete
  2. I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.
    Mobile App Development Company

    ReplyDelete