xctasks 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5d0e8565d04149c6de73c61d731fb0472c24d37
4
- data.tar.gz: 84bff82ae95bdb2b2a2b1f0f67465fd412783aab
3
+ metadata.gz: 8def5c8a26145c94427549a366caab5948f7b9ea
4
+ data.tar.gz: 2c7b17dbe330e73a1dd968fd2849bf20007a19fd
5
5
  SHA512:
6
- metadata.gz: 10038f24a8ed42d632c5a72b07a0b57a198aeea624b1f501001eb11aa55f346610d0fc800d0fda550eae13404f3ab058b4a160c5d1a5c750d358744dcb65ef56
7
- data.tar.gz: f67207b2a07fc77b22a9f656d1371af67f98e591ab34a28ba65617e09187f92d443084ab071ecb17faec396a8a3bce41ead65f47ab8e934985becee9c6d0945c
6
+ metadata.gz: 14f9d086b5cd23e8f9d1c9860b805e88fdd8775d1ece4276a76cb8c8e226a70d0e5a9b7cf9b7b41cbb285ac7780f672b8b04946eaac705b5503454815103d876
7
+ data.tar.gz: 9c04c2b49bdf955958b479c8ea1f9b732963c1016d28180508254a38c01263aca0f80bc1a7f71534d3ac3b33c9c3444aa9b9e427897b753090b078fe419ec977
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # XCTasks Changelog
2
2
 
3
+ ## v0.5.0
4
+
5
+ * Added support for working with projects as well as workspaces. Compliments of [kylef](https://github.com/kylef).
6
+
3
7
  ## v0.4.1
4
8
 
5
9
  * Reworked output redirection into an optional feature.
@@ -100,7 +100,8 @@ module XCTasks
100
100
  class Configuration
101
101
  SETTINGS = [:workspace, :schemes_dir, :sdk, :runner, :xctool_path,
102
102
  :xcodebuild_path, :settings, :destinations, :actions,
103
- :scheme, :ios_versions, :output_log, :env, :redirect_stderr]
103
+ :scheme, :ios_versions, :output_log, :env, :redirect_stderr,
104
+ :project]
104
105
  HELPERS = [:destination, :xctool?, :xcpretty?, :xcodebuild?]
105
106
 
106
107
  # Configures delegations to pass through configuration accessor when extended
@@ -235,19 +236,21 @@ module XCTasks
235
236
  end
236
237
 
237
238
  def run_tests(options = {})
238
- ios_version = options[:ios_version]
239
+ ios_version = options[:ios_version]
239
240
  XCTasks::Command.run(%q{killall "iPhone Simulator"}, false) if sdk == :iphonesimulator
240
241
 
242
+ target = workspace ? "-workspace #{workspace}" : "-project #{project}"
243
+
241
244
  output_log_command = output_log ? "| tee -a #{output_log}" : nil
242
245
  redirect_suffix = redirect_stderr ? "2> #{redirect_stderr}" : nil
243
246
  success = if xctool?
244
247
  actions_arg << " -freshSimulator" if ios_version
245
- Command.run(["#{xctool_path} -workspace #{workspace} -scheme '#{scheme}' -sdk #{sdk}#{ios_version}", destination_arg, actions_arg, settings_arg, redirect_suffix, output_log_command].grep(String).join(' '))
248
+ Command.run(["#{xctool_path} #{target} -scheme '#{scheme}' -sdk #{sdk}#{ios_version}", destination_arg, actions_arg, settings_arg, redirect_suffix, output_log_command].grep(String).join(' '))
246
249
  elsif xcodebuild?
247
- Command.run(["#{xcodebuild_path} -workspace #{workspace} -scheme '#{scheme}' -sdk #{sdk}#{ios_version}", destination_arg, actions_arg, settings_arg, redirect_suffix, output_log_command].grep(String).join(' '))
250
+ Command.run(["#{xcodebuild_path} #{target} -scheme '#{scheme}' -sdk #{sdk}#{ios_version}", destination_arg, actions_arg, settings_arg, redirect_suffix, output_log_command].grep(String).join(' '))
248
251
  elsif xcpretty?
249
252
  xcpretty_bin = runner.is_a?(String) ? runner : "xcpretty -c"
250
- Command.run(["#{xcodebuild_path} -workspace #{workspace} -scheme '#{scheme}' -sdk #{sdk}#{ios_version}", destination_arg, actions_arg, settings_arg, redirect_suffix, output_log_command, "| #{xcpretty_bin} ; exit ${PIPESTATUS[0]}"].grep(String).join(' '))
253
+ Command.run(["#{xcodebuild_path} #{target} -scheme '#{scheme}' -sdk #{sdk}#{ios_version}", destination_arg, actions_arg, settings_arg, redirect_suffix, output_log_command, "| #{xcpretty_bin} ; exit ${PIPESTATUS[0]}"].grep(String).join(' '))
251
254
  end
252
255
 
253
256
  XCTasks::TestReport.instance.add_result(self, options, success)
@@ -275,7 +278,7 @@ module XCTasks
275
278
 
276
279
  def write_environment_variables_to_scheme
277
280
  if env.any?
278
- path = "#{workspace}/xcshareddata/xcschemes/#{scheme}.xcscheme"
281
+ path = "#{workspace || project}/xcshareddata/xcschemes/#{scheme}.xcscheme"
279
282
  doc = Nokogiri::XML(File.read(path))
280
283
  testable_node = doc.at('TestAction')
281
284
  env_variables_node = Nokogiri::XML::Node.new "EnvironmentVariables", doc
@@ -305,7 +308,7 @@ module XCTasks
305
308
  @prepare_dependency = namespace_name.kind_of?(Hash) ? namespace_name.values.first : nil
306
309
 
307
310
  yield self if block_given?
308
- raise ConfigurationError, "A workspace must be configured" unless workspace
311
+ raise ConfigurationError, "A workspace or project must be configured" unless workspace || project
309
312
  raise ConfigurationError, "At least one subtask must be configured" if subtasks.empty?
310
313
  define_rake_tasks
311
314
  end
@@ -327,12 +330,17 @@ module XCTasks
327
330
  def define_rake_tasks
328
331
  namespace self.namespace_name do
329
332
  task (prepare_dependency ? { prepare: prepare_dependency} : :prepare ) do
330
- fail "No such workspace: #{workspace}" unless File.exists?(workspace)
333
+ if workspace
334
+ fail "No such workspace: #{workspace}" unless File.exists?(workspace)
335
+ else
336
+ fail "No such project: #{project}" unless File.exists?(project)
337
+ end
338
+
331
339
  fail "Invalid schemes directory: #{schemes_dir}" unless schemes_dir.nil? || File.exists?(schemes_dir)
332
340
  File.truncate(output_log, 0) if output_log && File.exists?(output_log)
333
341
  if schemes_dir
334
- FileUtils::Verbose.mkdir_p "#{workspace}/xcshareddata/xcschemes"
335
- FileUtils::Verbose.cp Dir.glob("#{schemes_dir}/*.xcscheme"), "#{workspace}/xcshareddata/xcschemes"
342
+ FileUtils::Verbose.mkdir_p "#{workspace || project}/xcshareddata/xcschemes"
343
+ FileUtils::Verbose.cp Dir.glob("#{schemes_dir}/*.xcscheme"), "#{workspace || project}/xcshareddata/xcschemes"
336
344
  end
337
345
  subtasks.each { |subtask| subtask.prepare }
338
346
  end
@@ -1,3 +1,3 @@
1
1
  module XCTasks
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -19,6 +19,7 @@ describe XCTasks::TestTask do
19
19
 
20
20
  Dir.mktmpdir.tap do |path|
21
21
  FileUtils.mkdir_p(path + '/LayerKit.xcworkspace/xcshareddata/xcschemes')
22
+ FileUtils.mkdir_p(path + '/LayerKit.xcodeproj/xcshareddata/xcschemes')
22
23
  FileUtils.mkdir_p(path + '/Tests/Schemes')
23
24
  Dir.chdir(path)
24
25
  end
@@ -44,6 +45,21 @@ describe XCTasks::TestTask do
44
45
  end
45
46
  end
46
47
 
48
+ context "when the given project does not exist" do
49
+ let!(:task) do
50
+ XCTasks::TestTask.new do |t|
51
+ t.project = 'Invalid.xcodeproj'
52
+ t.schemes_dir = 'Tests/Schemes'
53
+ t.runner = :xcpretty
54
+ t.subtasks = { unit: 'Unit Tests', functional: 'Functional Tests' }
55
+ end
56
+ end
57
+
58
+ it "fails" do
59
+ expect { subject.invoke }.to raise_error(RuntimeError, "No such project: Invalid.xcodeproj")
60
+ end
61
+ end
62
+
47
63
  context "when the given schemes_dir is nil" do
48
64
  let!(:task) do
49
65
  XCTasks::TestTask.new do |t|
@@ -75,7 +91,37 @@ describe XCTasks::TestTask do
75
91
  end
76
92
  end
77
93
 
78
- describe 'simple task' do
94
+ describe 'simple task with a project' do
95
+ let!(:task) do
96
+ XCTasks::TestTask.new do |t|
97
+ t.project = 'LayerKit.xcodeproj'
98
+ t.schemes_dir = 'Tests/Schemes'
99
+ t.runner = :xcpretty
100
+ t.redirect_stderr = true
101
+ t.subtasks = { unit: 'Unit Tests' }
102
+ end
103
+ end
104
+
105
+ it "configures the project" do
106
+ task.project.should == 'LayerKit.xcodeproj'
107
+ end
108
+
109
+ describe 'tasks' do
110
+ describe 'spec:unit' do
111
+ subject { Rake.application['test:unit'] }
112
+
113
+ it "executes the appropriate commands" do
114
+ subject.invoke
115
+ @commands.should == ["mkdir -p LayerKit.xcodeproj/xcshareddata/xcschemes",
116
+ "cp [] LayerKit.xcodeproj/xcshareddata/xcschemes",
117
+ "killall \"iPhone Simulator\"",
118
+ "/usr/bin/xcodebuild -project LayerKit.xcodeproj -scheme 'Unit Tests' -sdk iphonesimulator clean build test 2> /dev/null | xcpretty -c ; exit ${PIPESTATUS[0]}"]
119
+ end
120
+ end
121
+ end
122
+ end
123
+
124
+ describe 'simple task with a workspace' do
79
125
  let!(:task) do
80
126
  XCTasks::TestTask.new do |t|
81
127
  t.workspace = 'LayerKit.xcworkspace'
@@ -197,6 +243,31 @@ describe XCTasks::TestTask do
197
243
  end
198
244
  end
199
245
 
246
+ describe 'task with a project with environment variables' do
247
+ let!(:task) do
248
+ XCTasks::TestTask.new do |t|
249
+ t.project = 'LayerKit.xcodeproj'
250
+ t.schemes_dir = 'Tests/Schemes'
251
+ t.runner = 'xcpretty -s'
252
+ t.output_log = 'output.log'
253
+ t.env["LAYER_TEST_HOST"] = "10.66.0.35"
254
+ t.subtasks = { unit: 'Unit Tests' }
255
+ end
256
+ end
257
+
258
+ subject { Rake.application['test:unit'] }
259
+
260
+ it "writes the environment variables into the scheme" do
261
+ FileUtils.cp File.dirname(__FILE__) + '/Unit Tests.xcscheme', "LayerKit.xcodeproj/xcshareddata/xcschemes/"
262
+ subject.invoke
263
+ doc = Nokogiri::XML File.read("LayerKit.xcodeproj/xcshareddata/xcschemes/Unit Tests.xcscheme")
264
+ node = doc.at('TestAction/EnvironmentVariables/EnvironmentVariable')
265
+ expect(node).not_to be_nil
266
+ attributes = node.attributes.inject({}) { |hash, pair| hash[pair[0]] = pair[1].to_s; hash }
267
+ attributes.should == {"key"=>"LAYER_TEST_HOST", "value"=>"10.66.0.35", "isEnabled"=>"YES"}
268
+ end
269
+ end
270
+
200
271
  describe 'advanced task' do
201
272
  let!(:task) do
202
273
  XCTasks::TestTask.new do |t|
@@ -345,13 +416,14 @@ describe XCTasks::TestTask do
345
416
  end
346
417
  end
347
418
 
348
- context "when a workspace is not configured" do
419
+ context "when a workspace or project is not configured" do
349
420
  it "raises an exception" do
350
421
  expect do
351
422
  XCTasks::TestTask.new do |t|
352
423
  t.workspace = nil
424
+ t.project = nil
353
425
  end
354
- end.to raise_error(XCTasks::TestTask::ConfigurationError, "A workspace must be configured")
426
+ end.to raise_error(XCTasks::TestTask::ConfigurationError, "A workspace or project must be configured")
355
427
  end
356
428
  end
357
429
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xctasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Watters
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-27 00:00:00.000000000 Z
11
+ date: 2015-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake