Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add the ability to run multiple automation files

  • Loading branch information...
commit 2c245cb815afab5bf385ccfd2f17ffc46adb6354 1 parent 8816836
Jaymes Waters authored Bendyworks Pair committed
View
1  .gitignore
@@ -4,4 +4,5 @@ TravisCI.xcworkspace/xcuserdata/
build
automation/pusher_secret_key.txt
automation/results
+automation/*.js
instrumentscli*
View
26 Rakefile
@@ -8,9 +8,8 @@ task :clean do
end
task :coffeescript do
- test_files = 'automation/uiautomation.coffee'
- js_file = 'automation/uiautomation.js'
- system "coffee -b -p #{test_files} > #{js_file}"
+ test_files = 'automation/*.coffee'
+ system "coffee -b -c #{test_files}"
end
task :build do
@@ -33,12 +32,13 @@ task :build do
clean build"
end
-task :test => :coffeescript do
+def run_test_with_script path
+ project_dir = Dir.pwd
template = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Instruments/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate'
- app = '~/dev/ios/TravisCI/build/TravisCI.app'
+ app = File.join(project_dir, 'build', 'TravisCI.app')
variables = {
- 'UIASCRIPT' => '~/dev/ios/TravisCI/automation/uiautomation.js',
- 'UIARESULTSPATH' => '~/dev/ios/TravisCI/automation/results'
+ 'UIASCRIPT' => File.join(project_dir, 'automation', path),
+ 'UIARESULTSPATH' => File.join(project_dir, 'automation', 'results')
}.map{|key,val| "-e #{key} #{val}"}.join(' ')
cmd = "instruments -t #{template} #{app} #{variables}"
@@ -56,7 +56,19 @@ task :test => :coffeescript do
puts line
end
end
+end
+
+task :test_iphone do
+ run_test_with_script 'iphone.js'
+end
+task :test_ipad do
+ run_test_with_script 'ipad.js'
+end
+
+task :test => :coffeescript do
+ Rake::Task['test_iphone'].execute
+ Rake::Task['test_ipad'].execute
end
task :default => [:build, :test]
View
0  automation/ipad.coffee
No changes.
View
0  automation/uiautomation.coffee → automation/iphone.coffee
File renamed without changes
View
206 automation/uiautomation.js
@@ -1,206 +0,0 @@
-var assertElementPresent, build_list, first_log_line, givenISeeRepositoryList, job_detail, job_list, log, new_log_line, repo_list, target, thenIShouldSeeJobDetailView, thenIShouldSeeJobLogFullscreen, thenIShouldSeeTheJobLogFullscreen, thenIShouldSeeTheListOfBuilds, thenIShouldSeeTheListOfJobs, thenIShouldSeeTheUpdatedLiveJobLog, whenITapJobLog, whenITapTheBackButton, whenITapTheFirstBuild, whenITapTheFirstJob, whenITapTheFirstRepo, whenITapTheSecondRepo, whenPusherSendsAnUpdateAboutThatJob, window;
-
-assertElementPresent = function(el, el_name) {
- el_name = el_name != null ? el_name : {
- el_name: ''
- };
- if (el.isValid()) {
- return UIALogger.logPass("Element " + el_name + " is present");
- } else {
- return UIALogger.logFail("Element " + el_name + " is not present");
- }
-};
-
-whenPusherSendsAnUpdateAboutThatJob = function(target, job_id, new_log_line) {
- var args, host, path, result, timeout;
- path = "/Users/bendyworks/dev/ios/TravisCI/automation/pusher_event";
- args = ["job-" + job_id, "job:log", "{\"id\" : " + job_id + ", \"_log\" : \"" + new_log_line + "\"}"];
- timeout = 5;
- host = target.host();
- result = host.performTaskWithPathArgumentsTimeout(path, args, timeout);
- if (result.exitCode === 0) {
- return UIALogger.logPass("Pusher Scripted Called");
- } else {
- return UIALogger.logPass("Pusher Script had an error: " + result.stderr + " " + result.stdout);
- }
-};
-
-givenISeeRepositoryList = function(window) {
- var repository_list;
- repository_list = window.tableViews().firstWithName("Repositories");
- assertElementPresent(repository_list.cells(), "repository cells");
- return repository_list;
-};
-
-whenITapTheFirstRepo = function(repository_list) {
- var latest_repo;
- latest_repo = repository_list.cells()[0];
- return latest_repo.tap();
-};
-
-thenIShouldSeeTheListOfBuilds = function(window) {
- var build_list;
- build_list = window.tableViews().firstWithName("Builds");
- assertElementPresent(build_list.cells());
- return build_list;
-};
-
-whenITapTheFirstBuild = function(build_list) {
- var build_cell;
- build_cell = build_list.cells()[0];
- assertElementPresent(build_cell, "build_cell");
- return build_cell.tap();
-};
-
-thenIShouldSeeTheListOfJobs = function(window) {
- var job_list;
- job_list = window.tableViews().firstWithName("Jobs");
- assertElementPresent(job_list.cells(), "job list cells()");
- return job_list;
-};
-
-whenITapTheFirstJob = function(job_list) {
- var job_cell;
- job_cell = job_list.cells()[0];
- assertElementPresent(job_list.cells(), "first job cell");
- return job_cell.tap();
-};
-
-thenIShouldSeeJobDetailView = function(window) {
- var job_detail;
- job_detail = window.tableViews().firstWithName("Job Detail");
- assertElementPresent(job_detail.cells(), "job detail cells");
- return job_detail;
-};
-
-whenITapJobLog = function(job_detail) {
- var log_cell;
- log_cell = job_detail.cells().firstWithName("Logs");
- assertElementPresent(log_cell, "log_cell");
- return log_cell.tap();
-};
-
-thenIShouldSeeTheJobLogFullscreen = function(window) {
- var job_log_nav;
- job_log_nav = window.elements().firstWithName("Job Log");
- return assertElementPresent(job_log_nav, "Job Log Navigation Bar");
-};
-
-whenITapTheSecondRepo = function(repository_list) {
- var latest_repo;
- latest_repo = repository_list.cells()[1];
- return latest_repo.tap();
-};
-
-thenIShouldSeeJobLogFullscreen = function(window, first_log_line) {
- var log;
- log = window.textViews()[0];
- if (log.value() === first_log_line) {
- UIALogger.logPass("log displayed correctly");
- } else {
- UIALogger.logFail("log is not correct");
- }
- return log;
-};
-
-thenIShouldSeeTheUpdatedLiveJobLog = function(log, first_log_line, new_log_line) {
- var expected;
- expected = first_log_line + new_log_line;
- if (log.value() === expected) {
- return UIALogger.logPass("Live log displayed correctly");
- } else {
- return UIALogger.logFail("Live log is not correct, expected: " + expected + " got: " + (log.value()));
- }
-};
-
-whenITapTheBackButton = function(window) {
- return window.navigationBar().leftButton().tap();
-};
-
-target = UIATarget.localTarget();
-
-window = target.frontMostApp().mainWindow();
-
-repo_list = givenISeeRepositoryList(window);
-
-whenITapTheFirstRepo(repo_list);
-
-build_list = thenIShouldSeeTheListOfBuilds(window);
-
-whenITapTheFirstBuild(build_list);
-
-job_list = thenIShouldSeeTheListOfJobs(window);
-
-whenITapTheFirstJob(job_list);
-
-job_detail = thenIShouldSeeJobDetailView(window);
-
-whenITapJobLog(job_detail);
-
-thenIShouldSeeTheJobLogFullscreen(window);
-
-first_log_line = "log line one\n";
-
-log = thenIShouldSeeJobLogFullscreen(window, first_log_line);
-
-new_log_line = "pushed log line";
-
-whenPusherSendsAnUpdateAboutThatJob(target, "110", new_log_line);
-
-thenIShouldSeeTheUpdatedLiveJobLog(log, first_log_line, new_log_line);
-
-whenITapTheBackButton(window);
-
-whenITapTheBackButton(window);
-
-job_list = thenIShouldSeeTheListOfJobs(window);
-
-whenITapTheFirstJob(job_list);
-
-job_detail = thenIShouldSeeJobDetailView(window);
-
-whenITapJobLog(job_detail);
-
-thenIShouldSeeTheJobLogFullscreen(window);
-
-log = thenIShouldSeeJobLogFullscreen(window, first_log_line);
-
-new_log_line = "Another pushed log line";
-
-whenPusherSendsAnUpdateAboutThatJob(target, "110", new_log_line);
-
-thenIShouldSeeTheUpdatedLiveJobLog(log, first_log_line, new_log_line);
-
-whenITapTheBackButton(window);
-
-whenITapTheBackButton(window);
-
-whenITapTheBackButton(window);
-
-whenITapTheBackButton(window);
-
-repo_list = givenISeeRepositoryList(window);
-
-whenITapTheSecondRepo(repo_list);
-
-build_list = thenIShouldSeeTheListOfBuilds(window);
-
-whenITapTheFirstBuild(build_list);
-
-job_list = thenIShouldSeeTheListOfJobs(window);
-
-whenITapTheFirstJob(job_list);
-
-job_detail = thenIShouldSeeJobDetailView(window);
-
-whenITapJobLog(job_detail);
-
-first_log_line = "first log line\n";
-
-log = thenIShouldSeeJobLogFullscreen(window, first_log_line);
-
-new_log_line = "z second log line";
-
-whenPusherSendsAnUpdateAboutThatJob(target, "210", new_log_line);
-
-thenIShouldSeeTheUpdatedLiveJobLog(log, first_log_line, new_log_line);
Please sign in to comment.
Something went wrong with that request. Please try again.