Skip to content

Commit

Permalink
Merge pull request paypal#2 from ifreecarve/be_cocoapod
Browse files Browse the repository at this point in the history
Gem complete
  • Loading branch information
kviksilver committed Apr 10, 2015
2 parents 66ea77c + a1edfc7 commit 3ac69cd
Show file tree
Hide file tree
Showing 28 changed files with 71 additions and 50 deletions.
12 changes: 5 additions & 7 deletions SampleApp/automationTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,17 @@
parserFactory.prepare({"b" => 'iPhone 5'}, # the default sim devie is iPhone 5
{}, # no extra parse flags are being defined
{}) # no argument processing overrides are being provided
parser = parserFactory.buildParser(options, 'asdq#xtoni#rvmw#bzl#Bfek#')
parser = parserFactory.buildParser(options, 'APDasdq#xtoni#rvmw#bzl#Bfek#')

optionStruct = parser.parse ARGV

# hard code the project-specific information we have
optionStruct.xcode.projectDir = File.expand_path(File.dirname(__FILE__)) # Xcode project file is in this directory
optionStruct.xcode.appName = 'AutomatorSampleApp'
optionStruct.xcode.workspaceFile = 'AutomatorSampleApp.xcworkspace'
optionStruct.xcode.workspace = 'AutomatorSampleApp.xcworkspace'
optionStruct.xcode.scheme = 'AutomatorSampleApp'
optionStruct.javascript.implementation = 'iPhone'
optionStruct.javascript.testPath = Illuminator::HostUtils.realpath('../SampleTests/tests/AllTests.js') # must be full path
optionStruct.javascript.testPath = Illuminator::HostUtils.realpath('SampleTests/tests/AllTests.js') # must be full path

workspace = Dir.pwd


success = Illuminator::runWithOptions optionStruct, workspace
success = Illuminator::runWithOptions optionStruct
exit 1 unless success
7 changes: 3 additions & 4 deletions SampleApp/rerunFailedTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
require 'illuminator'
require 'pathname'

workspace = Dir.pwd

# TODO: helpful message if file isn't supplied
# TODO: helpful message if file isn't supplied.
# ARGV[0] should be a path ending in IlluminatorRerunFailedTestsSettings.json

overrideOptions = lambda {|opts| opts}

success = Illuminator::.reRun(ARGV[0], workspace, overrideOptions)
success = Illuminator::reRun(ARGV[0], overrideOptions)

exit 1 unless success
14 changes: 8 additions & 6 deletions SampleApp/smokeTests.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
require 'bundler/setup'
require 'illuminator'

# Change directory to sample app and use that for the workspace
# Change directory to sample app and use that for the project dir
Dir.chdir File.expand_path(File.dirname(__FILE__))
workspace = Dir.pwd

allTestPath = '../SampleTests/tests/AllTests.js'
allTestPath = 'SampleTests/tests/AllTests.js'
allTestPath = Illuminator::HostUtils.realpath(allTestPath)

# Hard-coded options

options = Illuminator::Options.new
options.buildArtifactsDir = File.join(Dir.pwd, "buildArtifacts")
options.xcode.appName = 'AutomatorSampleApp'
options.xcode.scheme = 'AutomatorSampleApp'
options.xcode.workspaceFile = 'AutomatorSampleApp.xcworkspace'
options.xcode.workspace = 'AutomatorSampleApp.xcworkspace'
options.xcode.projectDir = Dir.pwd


options.illuminator.entryPoint = 'runTestsByTag'
options.illuminator.test.tags.any = ['smoke']
Expand All @@ -38,12 +40,12 @@
end

options.simulator.version = '8.1'
success8 = Illuminator::runWithOptions options, workspace
success8 = Illuminator::runWithOptions options

options.illuminator.clean.xcode = false
options.illuminator.clean.artifacts = false
options.illuminator.task.build = false
options.simulator.version = '7.1'
success7 = Illuminator::runWithOptions options, workspace
success7 = Illuminator::runWithOptions options

exit 1 unless success7 and success8
31 changes: 21 additions & 10 deletions gem/lib/illuminator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ def self.validateOptions(options)
puts "Specified simulator iOS version '#{version}' does not appear to be installed - options are #{versions}".red
noproblems = false
end

end

unless File.exists? options.javascript.testPath
puts "Could not find specified javascript test definitions file at '#{options.javascript.testPath}'".red
noproblems = false
end

if options.buildArtifactsDir.nil?
puts "Build artifacts directory was not specified!".red
noproblems = false
end

return noproblems
Expand All @@ -60,9 +71,10 @@ def self.validateOptions(options)



def self.runWithOptions(originalOptions, workspace)
def self.runWithOptions(originalOptions)

options = Options.new(originalOptions.to_h) # immediately create a copy of the options, because we may mangle them
BuildArtifacts.instance.setRoot options.buildArtifactsDir

hardwareID = options.illuminator.hardwareID
appName = options.xcode.appName
Expand Down Expand Up @@ -91,11 +103,11 @@ def self.runWithOptions(originalOptions, workspace)
options.instruments.appLocation = BuildArtifacts.instance.appLocation(appName) # assume app is here
else
builder = AutomationBuilder.new
builder.workspace = workspace
builder.doClean = options.illuminator.clean.xcode
builder.project = options.xcode.project
builder.scheme = options.xcode.scheme
builder.workspaceFile = options.xcode.workspaceFile
builder.projectDir = options.xcode.projectDir
builder.project = options.xcode.project
builder.scheme = options.xcode.scheme
builder.workspace = options.xcode.workspace
builder.doClean = options.illuminator.clean.xcode
unless options.xcode.environmentVars.nil?
options.xcode.environmentVars.each { |name, value| builder.addEnvironmentVariable(name, value) }
end
Expand All @@ -120,23 +132,22 @@ def self.runWithOptions(originalOptions, workspace)

# Initialize automation
runner = AutomationRunner.new
runner.workspace = workspace
runner.appName = appName
runner.appName = appName
runner.cleanup
return runner.runWithOptions(options)

end

# overrideOptions is a lambda function that acts on the options object
def self.reRun(configPath, workspace, overrideOptions = nil)
def self.reRun(configPath, overrideOptions = nil)

# load config from supplied path
jsonConfig = IO.read(configPath)

# process any overrides
options = overrideOptions.(IlluminatorOptions.new(JSON.parse(jsonConfig))) unless overrideOptions.nil?

return runWithOptions options, workspace
return runWithOptions options
end


Expand Down
20 changes: 14 additions & 6 deletions gem/lib/illuminator/argument-parsing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ def copyParsedOptionsInto(illuminatorOptions)

# load up known illuminatorOptions
# we only load non-nil options, just in case there was already something in the illuminatorOptions obj
illuminatorOptions.xcode.appName = @_options["appName"] unless @_options["appName"].nil?
illuminatorOptions.xcode.sdk = @_options["sdk"] unless @_options["sdk"].nil?
illuminatorOptions.xcode.scheme = @_options["scheme"] unless @_options["scheme"].nil?
illuminatorOptions.xcode.workspaceFile = @_options["workspaceFile"] unless @_options["workspaceFile"].nil?
illuminatorOptions.buildArtifactsDir = @_options["buildArtifacts"] unless @_options["buildArtifacts"].nil?

illuminatorOptions.xcode.appName = @_options["appName"] unless @_options["appName"].nil?
illuminatorOptions.xcode.sdk = @_options["sdk"] unless @_options["sdk"].nil?
illuminatorOptions.xcode.scheme = @_options["scheme"] unless @_options["scheme"].nil?
illuminatorOptions.xcode.workspace = @_options["xcodeWorkspace"] unless @_options["xcodeWorkspace"].nil?

illuminatorOptions.illuminator.entryPoint = @_options["entryPoint"] unless @_options["entryPoint"].nil?
illuminatorOptions.illuminator.test.randomSeed = @_options["randomSeed"].to_i unless @_options["randomSeed"].nil?
Expand Down Expand Up @@ -124,11 +126,13 @@ def initialize()

# build the list of how each parameter will be saved in the output
@letterMap = {
'A' => 'buildArtifacts',
'x' => 'entryPoint',
'p' => 'testPath',
'a' => 'appName',
'D' => 'xcodeProjectDir',
'P' => 'xcodeProject',
'W' => 'xcodeWorkspace',
'W' => 'xcodeWorkspace',
't' => 'tagsAny',
'o' => 'tagsAll',
'n' => 'tagsNone',
Expand Down Expand Up @@ -163,6 +167,8 @@ def initialize()
}

@defaultValues = {
# 'D' => Dir.pwd, # Since this effectively happens in xcode-builder, DON'T do it here too
'A' => File.join(Dir.pwd, "buildArtifacts"),
'b' => 'iPhone 5',
'z' => '8.2',
'q' => 'iphonesimulator',
Expand All @@ -183,11 +189,13 @@ def prepare(defaultValues = nil, letterMapUpdates = nil, letterProcessingUpdates
@letterProcessing = @letterProcessing.merge(letterProcessingUpdates) unless letterProcessingUpdates.nil?
@defaultValues = @defaultValues.merge defaultValues unless defaultValues.nil?

self.addSwitch('A', ['-A', '--buildArtifacts PATH', 'The directory in which to store build artifacts'])
self.addSwitch('x', ['-x', '--entryPoint LABEL', 'The execution entry point {runTestsByTag, runTestsByName, describe}'])
self.addSwitch('p', ['-p', '--testPath PATH', 'Path to js file with all tests imported'])
self.addSwitch('a', ['-a', '--appName APPNAME', "Name of the app to build / run"])
self.addSwitch('D', ['-D', '--xcodeProjectDirectory PATH', "Directory containing the Xcode project to build"])
self.addSwitch('P', ['-P', '--xcodeProject PROJECTNAME', "Project to build -- required if there are 2 in the same directory"])
self.addSwitch('W', ['-W', '--xcodeWorkspace WORKSPACENAME', "Workspace to build"])
self.addSwitch('W', ['-W', '--xcodeWorkspace WORKSPACENAME', "Workspace to build"])
self.addSwitch('t', ['-t', '--tags-any TAGSANY', 'Run tests with any of the given tags'])
self.addSwitch('o', ['-o', '--tags-all TAGSALL', 'Run tests with all of the given tags'])
self.addSwitch('n', ['-n', '--tags-none TAGSNONE', 'Run tests with none of the given tags'])
Expand Down
2 changes: 1 addition & 1 deletion gem/lib/illuminator/automation-builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def initialize


def buildForAutomation sdk, hardwareID
@xcconfig = "'#{File.dirname(__FILE__)}/../resources/BuildConfiguration.xcconfig'"
@xcconfig = "'#{File.dirname(__FILE__)}/../../resources/BuildConfiguration.xcconfig'"

preprocessorDefinitions = '$(value) UIAUTOMATION_BUILD=1'
if hardwareID.nil?
Expand Down
1 change: 0 additions & 1 deletion gem/lib/illuminator/automation-runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class AutomationRunner
include StopDetectorEventSink

attr_accessor :appName
attr_accessor :workspace
attr_accessor :appLocation

attr_reader :instrumentsRunner
Expand Down
6 changes: 3 additions & 3 deletions gem/lib/illuminator/build-artifacts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ class BuildArtifacts
include Singleton

def initialize
# use a default root directory location that's inside this project
@_root = File.join(File.dirname(__FILE__), "../../buildArtifacts")
@_root = nil
@artifactsHaveBeenCreated = false
end

def setRoot(dir)
if @_root != dir and @artifactsHaveBeenCreated
puts "Warning: changing BuildArtifacts root to '#{dir}' after creating artifacts in '#{@_root}'".red
@_root = dir
end
@_root = dir
end

def _setupAndUse(dir, skipSetup)
raise TypeError, "The buildArtifact root directory is nil; perhaps it was not set" if @_root.nil?
unless skipSetup or File.directory?(dir)
FileUtils.mkdir_p dir
@artifactsHaveBeenCreated = true
Expand Down
3 changes: 2 additions & 1 deletion gem/lib/illuminator/javascript-runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def assembleConfig
def writeConfiguration()
# instance variables required for renderTemplate
@saltinel = Digest::SHA1.hexdigest (Time.now.to_i.to_s + Socket.gethostname)
@illuminatorRoot = Illuminator::HostUtils.realpath(File.dirname(__FILE__))
@illuminatorRoot = Illuminator::HostUtils.realpath(File.join(File.dirname(__FILE__), "../../resources/js/"))
@illuminatorScripts = Illuminator::HostUtils.realpath(File.join(File.dirname(__FILE__), "../../resources/scripts/"))
@artifactsRoot = BuildArtifacts.instance.root
@illuminatorInstrumentsRoot = BuildArtifacts.instance.instruments
@environmentFile = BuildArtifacts.instance.illuminatorJsEnvironment
Expand Down
4 changes: 3 additions & 1 deletion gem/lib/illuminator/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def initialize(hash=nil)
self.javascript = RecursiveOpenStruct.new
self.illuminator = RecursiveOpenStruct.new
self.appSpecific = nil # all unknown options will go here
self.buildArtifactsDir = nil

self.illuminator.clean = RecursiveOpenStruct.new
self.illuminator.task = RecursiveOpenStruct.new
Expand All @@ -49,10 +50,11 @@ def initialize(hash=nil)
self.illuminator.test.retest = RecursiveOpenStruct.new

# name all the keys (just for visibiilty)
self.xcode.projectDir = nil
self.xcode.project = nil
self.xcode.appName = nil
self.xcode.sdk = nil
self.xcode.workspace = nil
self.xcode.workspace = nil
self.xcode.scheme = nil
self.xcode.environmentVars = nil

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
* (especially given that the config comes from a file)
*/
var IlluminatorRootDirectory = "<%= @illuminatorRoot %>";
var IlluminatorScriptsDirectory = "<%= @illuminatorScripts %>";
var IlluminatorBuildArtifactsDirectory = "<%= @artifactsRoot %>";
var IlluminatorInstrumentsOutputDirectory = "<%= @illuminatorInstrumentsRoot %>";
10 changes: 5 additions & 5 deletions gem/lib/illuminator/xcode-builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class XcodeBuilder
attr_accessor :sdk
attr_accessor :arch
attr_accessor :scheme
attr_accessor :projectDir
attr_accessor :workspace
attr_accessor :workspaceFile
attr_accessor :destination
attr_accessor :xcconfig
attr_accessor :doClean
Expand All @@ -23,7 +23,7 @@ class XcodeBuilder
def initialize
@parameters = Hash.new
@environmentVars = Hash.new
@workspace = nil
@projectDir = nil
@doClean = FALSE
@doTest = FALSE
@doBuild = TRUE
Expand All @@ -48,7 +48,7 @@ def _assembleConfig
'arch' => @arch,
'scheme' => @scheme,
'destination' => @destination,
'workspace' => @workspaceFile,
'workspace' => @workspace,
'xcconfig' => @xcconfig,
}

Expand Down Expand Up @@ -111,10 +111,10 @@ def build
directory = Dir.pwd
retval = nil
begin
Dir.chdir(@workspace) unless @workspace.nil?
Dir.chdir(@projectDir) unless @projectDir.nil?
retval = self._executeBuildCommand command
ensure
Dir.chdir(directory) unless @workspace.nil?
Dir.chdir(directory) unless @projectDir.nil?
end

retval
Expand Down
2 changes: 1 addition & 1 deletion gem/lib/illuminator/xcode-utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def self.removeExistingApps xcodeOutputDir
end

def self.killAllSimulatorProcesses
command = HostUtils.realpath(File.join(File.dirname(__FILE__), "../kill_all_sim_processes.sh"))
command = HostUtils.realpath(File.join(File.dirname(__FILE__), "../../resources/scripts/kill_all_sim_processes.sh"))
puts "Running #{command}"
puts `'#{command}'`
end
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/Bridge.js → gem/resources/js/Bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var debugBridge = false;

var taskArguments = [];

var scriptPath = IlluminatorRootDirectory + "/scripts/UIAutomationBridge.rb";
var scriptPath = IlluminatorScriptsDirectory + "/UIAutomationBridge.rb";
taskArguments.push(scriptPath);

taskArguments.push("--callUID=" + UID)
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/Extensions.js → gem/resources/js/Extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1623,7 +1623,7 @@ extendPrototype(UIAHost, {
* @return object
*/
readJSONFromPlistFile: function (path) {
var scriptPath = IlluminatorRootDirectory + "/scripts/plist_to_json.sh";
var scriptPath = IlluminatorScriptsDirectory + "/plist_to_json.sh";
UIALogger.logDebug("Running " + scriptPath + " '" + path + "'");

return this._guardedJSONParse(this.shellAsFunction(scriptPath, [path], 10));
Expand Down Expand Up @@ -1722,7 +1722,7 @@ extendPrototype(UIATarget, {
throw new IlluminatorSetupException("Can't set the hardware keyboard option for a non-simulated device");
}
var on = connected ? "1" : "0";
var scriptPath = IlluminatorRootDirectory + "/scripts/set_hardware_keyboard.applescript";
var scriptPath = IlluminatorScriptsDirectory + "/set_hardware_keyboard.applescript";

host().shellAsFunction("/usr/bin/osascript", [scriptPath, on], 5);
},
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminator.js → gem/resources/js/Illuminator.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function actionCompareScreenshotToMaster(parm) {

delay(delayCapture); // wait for any animations to settle

var diff_pngPath = IlluminatorRootDirectory + "/scripts/diff_png.sh";
var diff_pngPath = IlluminatorScriptsDirectory + "/diff_png.sh";
UIATarget.localTarget().captureScreenWithName(captureTitle);

var screenshotFile = captureTitle + ".png";
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 3ac69cd

Please sign in to comment.