zerg_xcode 0.3.5 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.project +17 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +30 -0
- data/Rakefile +50 -23
- data/VERSION +1 -0
- data/lib/zerg_xcode/file_format/archiver.rb +0 -24
- data/lib/zerg_xcode/file_format/id_generator.rb +30 -0
- data/lib/zerg_xcode/file_format/lexer.rb +113 -56
- data/lib/zerg_xcode/file_format/parser.rb +28 -34
- data/lib/zerg_xcode/file_format/scan_buffer.rb +46 -0
- data/lib/zerg_xcode/objects/pbx_project.rb +1 -1
- data/lib/zerg_xcode/objects/xcode_object.rb +2 -1
- data/lib/zerg_xcode/{file_format/paths.rb → paths.rb} +5 -6
- data/lib/zerg_xcode/shortcuts.rb +2 -2
- data/lib/zerg_xcode.rb +7 -1
- data/spec/archiver_spec.rb +83 -0
- data/spec/builder/runner_spec.rb +27 -0
- data/spec/builder/sdk_spec.rb +11 -0
- data/spec/encoder_spec.rb +17 -0
- data/{test → spec}/fixtures/ClosedLib/ClosedLib.xcodeproj/project.pbxproj +0 -0
- data/{test → spec}/fixtures/ClosedLib/ClosedLib_Prefix.pch +0 -0
- data/{test → spec}/fixtures/ClosedLib/ClosedNative.c +0 -0
- data/{test → spec}/fixtures/ClosedLib/ClosedNative.h +0 -0
- data/{test → spec}/fixtures/FlatTestApp/FlatTestApp.xcodeproj/project.pbxproj +0 -0
- data/{test → spec}/fixtures/TestApp/TestApp.xcodeproj/project.pbxproj +0 -0
- data/{test → spec}/fixtures/TestApp30.xcodeproj/project.pbxproj +0 -0
- data/{test → spec}/fixtures/TestLib30.xcodeproj/project.pbxproj +0 -0
- data/{test → spec}/fixtures/ZergSupport.xcodeproj/project.pbxproj +0 -0
- data/{test → spec}/fixtures/project.pbxproj +0 -0
- data/{test → spec}/fixtures/project.pbxproj.compat +0 -0
- data/spec/id_generator_spec.rb +38 -0
- data/spec/lexer_spec.rb +111 -0
- data/spec/parser_spec.rb +34 -0
- data/spec/paths_spec.rb +75 -0
- data/spec/shortcuts_spec.rb +24 -0
- data/test/objects/pbx_build_file_test.rb +3 -3
- data/test/objects/pbx_build_phase_test.rb +1 -1
- data/test/objects/pbx_container_item_proxy_test.rb +1 -1
- data/test/objects/pbx_group_test.rb +1 -1
- data/test/objects/pbx_native_target_test.rb +2 -2
- data/test/objects/pbx_project_test.rb +9 -9
- data/test/objects/pbx_target_dependency_test.rb +1 -1
- data/test/objects/xc_configuration_list_test.rb +1 -1
- data/test/plugins/addlibrary_test.rb +2 -2
- data/test/plugins/core/core_test.rb +1 -1
- data/test/plugins/import_test.rb +71 -71
- data/test/plugins/irb_test.rb +3 -3
- data/test/plugins/ls_test.rb +3 -3
- data/test/plugins/lstargets_test.rb +3 -3
- data/test/plugins/retarget_test.rb +2 -2
- data/zerg_xcode.gemspec +112 -17
- metadata +115 -113
- data/test/builder/runner_test.rb +0 -35
- data/test/builder/sdk_test.rb +0 -17
- data/test/file_format/archiver_test.rb +0 -74
- data/test/file_format/encoder_test.rb +0 -15
- data/test/file_format/lexer_test.rb +0 -60
- data/test/file_format/parser_test.rb +0 -49
- data/test/file_format/path_test.rb +0 -47
- data/test/shortcuts_test.rb +0 -22
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'zerg_xcode'
|
2
|
+
|
3
|
+
describe ZergXcode::Archiver do
|
4
|
+
Parser = ZergXcode::Parser
|
5
|
+
Archiver = ZergXcode::Archiver
|
6
|
+
XcodeObject = ZergXcode::XcodeObject
|
7
|
+
|
8
|
+
let(:archived_hash) do
|
9
|
+
{ "archiveVersion" => '1',
|
10
|
+
"rootObject" => '49',
|
11
|
+
"classes" => {},
|
12
|
+
"objectVersion" => '45',
|
13
|
+
"objects" => {
|
14
|
+
"49" => { :sub1 => "39", :sub2 => "42" },
|
15
|
+
"39" => { :array => ["a", "b", "c"], :string => "s" },
|
16
|
+
"42" => { :hash => { :k => "v", :k2 => "v2" }, :sub1 => "39" }
|
17
|
+
}
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:sub1) do
|
22
|
+
sub1 = XcodeObject.new :array => ['a', 'b', 'c'], :string => 's'
|
23
|
+
sub1.archive_id = '39'
|
24
|
+
sub1
|
25
|
+
end
|
26
|
+
|
27
|
+
let(:sub2) do
|
28
|
+
sub2 = XcodeObject.new :hash => { :k => 'v', :k2 => 'v2' }, :sub1 => sub1
|
29
|
+
sub2.archive_id = '42'
|
30
|
+
sub2
|
31
|
+
end
|
32
|
+
|
33
|
+
let(:root) do
|
34
|
+
root = XcodeObject.new :sub1 => sub1, :sub2 => sub2
|
35
|
+
root.archive_id = '49'
|
36
|
+
root.version = 45
|
37
|
+
root
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when archiving' do
|
41
|
+
it 'produces the expected hash for a sample object graph' do
|
42
|
+
Archiver.archive_to_hash(root).should == archived_hash
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when unarchiving' do
|
47
|
+
let(:pbxdata) {File.read 'spec/fixtures/project.pbxproj'}
|
48
|
+
|
49
|
+
context 'from a hash' do
|
50
|
+
it 'produces the expected object graph' do
|
51
|
+
unarchived_root = Archiver.unarchive_hash archived_hash
|
52
|
+
unarchived_root[:sub1][:s].should == sub1[:s]
|
53
|
+
unarchived_root[:sub1][:array].should == sub1[:array]
|
54
|
+
unarchived_root[:sub2][:hash].should == sub2[:hash]
|
55
|
+
unarchived_root[:sub2][:sub1].should == unarchived_root[:sub1]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'from our fixture' do
|
60
|
+
it 'does not raise an error' do
|
61
|
+
lambda {Archiver.unarchive pbxdata}.should_not raise_error
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'produces a project with a valid product path' do
|
65
|
+
project = Archiver.unarchive pbxdata
|
66
|
+
project['targets'][0]['productReference']['path'].should == 'TestApp.app'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
describe 'archiving then unarchiving our fixture' do
|
73
|
+
let(:pbxdata) {File.read 'spec/fixtures/project.pbxproj'}
|
74
|
+
|
75
|
+
it "should produce the same hash" do
|
76
|
+
golden_hash = Parser.parse pbxdata
|
77
|
+
project = Archiver.unarchive pbxdata
|
78
|
+
dupdata = Archiver.archive project
|
79
|
+
Parser.parse(dupdata).should == golden_hash
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'zerg_xcode'
|
2
|
+
|
3
|
+
describe ZergXcode::Builder::Runner do
|
4
|
+
before do
|
5
|
+
@project = ZergXcode.load 'spec/fixtures/ClosedLib'
|
6
|
+
@configuration = 'Release'
|
7
|
+
@sdk = ZergXcode::Builder::Sdk.all.
|
8
|
+
detect { |s| /i(?:OS|Phone) .*$/ =~ s[:name] }
|
9
|
+
@golden_build_path = 'spec/fixtures/ClosedLib/build/Release-iphoneos'
|
10
|
+
@product = @golden_build_path + '/libClosedLib.a'
|
11
|
+
ZergXcode::Builder::Runner.clean(@project, @sdk, @configuration)
|
12
|
+
end
|
13
|
+
|
14
|
+
after do
|
15
|
+
ZergXcode::Builder::Runner.clean @project, @sdk, @configuration
|
16
|
+
end
|
17
|
+
|
18
|
+
it "builds and cleans the project" do
|
19
|
+
build_path = ZergXcode::Builder::Runner.build @project, @sdk, @configuration
|
20
|
+
build_path.should be_true
|
21
|
+
build_path.should == @golden_build_path
|
22
|
+
File.exist?(@product).should be_true
|
23
|
+
|
24
|
+
ZergXcode::Builder::Runner.clean(@project, @sdk, @configuration).should be_true
|
25
|
+
File.exist?(@product).should be_false
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'zerg_xcode'
|
2
|
+
|
3
|
+
describe ZergXcode::Builder::Sdk do
|
4
|
+
describe '::all' do
|
5
|
+
it "should find a Mac OS SDK" do
|
6
|
+
all_sdks = ZergXcode::Builder::Sdk.all
|
7
|
+
macsdk = all_sdks.detect{|sdk| sdk[:arg] =~ /^macosx[0-9\.]+$/}
|
8
|
+
macsdk.should_not be_nil
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'zerg_xcode'
|
2
|
+
|
3
|
+
describe ZergXcode::Encoder do
|
4
|
+
|
5
|
+
describe 'encoded and reparsed project' do
|
6
|
+
|
7
|
+
let(:fixture_contents) {File.read 'spec/fixtures/project.pbxproj'}
|
8
|
+
let(:original_parsed_project) {ZergXcode::Parser.parse(fixture_contents)}
|
9
|
+
let(:reencoded_project) {ZergXcode::Encoder.encode(original_parsed_project)}
|
10
|
+
subject {ZergXcode::Parser.parse(reencoded_project)}
|
11
|
+
|
12
|
+
it 'should be identical to the originally parsed project' do
|
13
|
+
should == original_parsed_project
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'zerg_xcode'
|
2
|
+
|
3
|
+
describe ZergXcode::IdGenerator do
|
4
|
+
|
5
|
+
let(:object_a) do
|
6
|
+
o = ZergXcode::XcodeObject.new :foo => 'bar'
|
7
|
+
o.archive_id = '49'
|
8
|
+
o
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:object_b) do
|
12
|
+
o = ZergXcode::XcodeObject.new :foo => 'bar'
|
13
|
+
o.archive_id = '49'
|
14
|
+
o
|
15
|
+
end
|
16
|
+
|
17
|
+
context "when given an object with id '49'" do
|
18
|
+
|
19
|
+
it "should return '49'" do
|
20
|
+
subject.id_for(object_a).should == '49'
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
# This seems a little odd, but is how I found it. If given the
|
26
|
+
# same object twice, it will generate a new ID the second time.
|
27
|
+
context "when given a second object with id '49'" do
|
28
|
+
before do
|
29
|
+
subject.id_for(object_a)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should not return '49'" do
|
33
|
+
subject.id_for(object_b).should_not == '49'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
data/spec/lexer_spec.rb
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'zerg_xcode'
|
2
|
+
|
3
|
+
RSpec::Matchers.define :produce_token do |expected|
|
4
|
+
match do |actual|
|
5
|
+
actual.send(:scan_token) == expected
|
6
|
+
end
|
7
|
+
failure_message_for_should do |actual|
|
8
|
+
"expected Lexer to leave #{expected.dump} unconsumed instead of #{unconsumed(actual).dump}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
RSpec::Matchers.define :leave_unconsumed do |expected|
|
13
|
+
def unconsumed(actual)
|
14
|
+
actual.instance_variable_get(:@scan_buffer).unconsumed
|
15
|
+
end
|
16
|
+
match do |actual|
|
17
|
+
actual.send(:scan_token)
|
18
|
+
unconsumed(actual) == expected
|
19
|
+
end
|
20
|
+
failure_message_for_should do |actual|
|
21
|
+
"expected Lexer to leave #{expected.dump} unconsumed instead of #{unconsumed(actual).dump}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe ZergXcode::Lexer do
|
26
|
+
|
27
|
+
context "when scanning '// !$*UTF8*$!\\n{'" do
|
28
|
+
subject {ZergXcode::Lexer.new("// !$*UTF8*$!\n{")}
|
29
|
+
it {should produce_token('{')}
|
30
|
+
it {should leave_unconsumed("")}
|
31
|
+
end
|
32
|
+
|
33
|
+
context "when scanning '\"hello \\\"\\r\\n\\t\\\\\\'$(SRCROOT)\\\"\"'" do
|
34
|
+
subject {ZergXcode::Lexer.new("\"hello \\\"\\r\\n\\t\\\\\\'$(SRCROOT)\\\"\" {")}
|
35
|
+
it {should produce_token(["hello \"\r\n\t\\'$(SRCROOT)\""])}
|
36
|
+
it {should leave_unconsumed(" {")}
|
37
|
+
end
|
38
|
+
|
39
|
+
context "when scanning ' /* comment 1 */\\t\\n/* comment 2 */ ={'" do
|
40
|
+
subject {ZergXcode::Lexer.new(" /* comment 1 */\t\n/* comment 2 */ ={")}
|
41
|
+
it {should produce_token('=')}
|
42
|
+
it {should leave_unconsumed("{")}
|
43
|
+
end
|
44
|
+
|
45
|
+
context "when scanning ' \\t/* hello */\\n\\t'" do
|
46
|
+
subject {ZergXcode::Lexer.new(" \t/* hello */\n\t")}
|
47
|
+
it {should produce_token(nil)}
|
48
|
+
it {should leave_unconsumed("")}
|
49
|
+
end
|
50
|
+
|
51
|
+
context "when scanning '(x'" do
|
52
|
+
subject {ZergXcode::Lexer.new("(x")}
|
53
|
+
it {should produce_token('(')}
|
54
|
+
it {should leave_unconsumed("x")}
|
55
|
+
end
|
56
|
+
|
57
|
+
context "when scanning ')x'" do
|
58
|
+
subject {ZergXcode::Lexer.new(")x")}
|
59
|
+
it {should produce_token(')')}
|
60
|
+
it {should leave_unconsumed("x")}
|
61
|
+
end
|
62
|
+
|
63
|
+
context "when scanning '{x'" do
|
64
|
+
subject {ZergXcode::Lexer.new("{x")}
|
65
|
+
it {should produce_token('{')}
|
66
|
+
it {should leave_unconsumed("x")}
|
67
|
+
end
|
68
|
+
|
69
|
+
context "when scanning '}x'" do
|
70
|
+
subject {ZergXcode::Lexer.new("}x")}
|
71
|
+
it {should produce_token('}')}
|
72
|
+
it {should leave_unconsumed("x")}
|
73
|
+
end
|
74
|
+
|
75
|
+
context "when scanning '=x'" do
|
76
|
+
subject {ZergXcode::Lexer.new("=x")}
|
77
|
+
it {should produce_token('=')}
|
78
|
+
it {should leave_unconsumed("x")}
|
79
|
+
end
|
80
|
+
|
81
|
+
context "when scanning ';x'" do
|
82
|
+
subject {ZergXcode::Lexer.new(";x")}
|
83
|
+
it {should produce_token(';')}
|
84
|
+
it {should leave_unconsumed("x")}
|
85
|
+
end
|
86
|
+
|
87
|
+
context "when scanning ',x'" do
|
88
|
+
subject {ZergXcode::Lexer.new(",x")}
|
89
|
+
it {should produce_token(',')}
|
90
|
+
it {should leave_unconsumed("x")}
|
91
|
+
end
|
92
|
+
|
93
|
+
context "when scanning 'archiveVersion ='" do
|
94
|
+
subject {ZergXcode::Lexer.new("archiveVersion =")}
|
95
|
+
it {should produce_token(["archiveVersion"])}
|
96
|
+
it {should leave_unconsumed(" =")}
|
97
|
+
end
|
98
|
+
|
99
|
+
context "when scanning '{ foo = \"hello\", bar };'" do
|
100
|
+
subject {ZergXcode::Lexer.tokenize("{ foo = \"hello\", bar };")}
|
101
|
+
it {should == ['{',
|
102
|
+
["foo"],
|
103
|
+
'=',
|
104
|
+
["hello"],
|
105
|
+
',',
|
106
|
+
["bar"],
|
107
|
+
'}',
|
108
|
+
';']}
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
data/spec/parser_spec.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'zerg_xcode'
|
2
|
+
|
3
|
+
describe ZergXcode::Parser do
|
4
|
+
context "when parsing '{ archiveVersion = 1 /* foo */; objectVersion = 45; }'" do
|
5
|
+
subject {ZergXcode::Parser.parse("{ archiveVersion = 1 /* foo */; objectVersion = 45; }")}
|
6
|
+
it {should be_a(Hash)}
|
7
|
+
it {should == {'archiveVersion' => '1', 'objectVersion' => '45'}}
|
8
|
+
end
|
9
|
+
|
10
|
+
context "when parsing '( 2342 /* foo */, 789 /* bar */, )'" do
|
11
|
+
subject {ZergXcode::Parser.parse("( 2342 /* foo */, 789 /* bar */, )")}
|
12
|
+
it {should be_an(Array)}
|
13
|
+
it {should == ["2342", "789"]}
|
14
|
+
end
|
15
|
+
|
16
|
+
context "when parsing '{ foo = ( 42, \"seven and nine\" ); }'" do
|
17
|
+
subject {ZergXcode::Parser.parse("{ foo = ( 42, \"seven and nine\" ); }")}
|
18
|
+
it {should be_a(Hash)}
|
19
|
+
it {should == {'foo' => ['42', 'seven and nine']}}
|
20
|
+
end
|
21
|
+
|
22
|
+
context "when parsing '( { foo = 42; bar = 79; }, 42, )'" do
|
23
|
+
subject {ZergXcode::Parser.parse("( { foo = 42; bar = 79; }, 42, )")}
|
24
|
+
it {should be_an(Array)}
|
25
|
+
it {should == [{'foo' => '42', 'bar' => '79'}, '42']}
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should parse our sample fixture" do
|
29
|
+
pbxdata = File.read 'spec/fixtures/project.pbxproj'
|
30
|
+
proj = ZergXcode::Parser.parse pbxdata
|
31
|
+
proj['rootObject'].should == '29B97313FDCFA39411CA2CEA'
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/spec/paths_spec.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# Author:: Victor Costan
|
2
|
+
# Copyright:: Copyright (C) 2009 Zergling.Net
|
3
|
+
# License:: MIT
|
4
|
+
|
5
|
+
require 'zerg_xcode'
|
6
|
+
|
7
|
+
describe ZergXcode::Paths do
|
8
|
+
|
9
|
+
include ZergXcode::Paths
|
10
|
+
|
11
|
+
describe '#project_file_at' do
|
12
|
+
context "when given 'spec/fixtures/ZergSupport'" do
|
13
|
+
subject {project_file_at('spec/fixtures/ZergSupport')}
|
14
|
+
it {should == 'spec/fixtures/ZergSupport.xcodeproj/project.pbxproj'}
|
15
|
+
end
|
16
|
+
|
17
|
+
context "when given 'spec/fixtures/ZergSupport.xcodeproj'" do
|
18
|
+
subject {project_file_at('spec/fixtures/ZergSupport.xcodeproj')}
|
19
|
+
it {should == 'spec/fixtures/ZergSupport.xcodeproj/project.pbxproj'}
|
20
|
+
end
|
21
|
+
|
22
|
+
context "when given 'spec/fixtures'" do
|
23
|
+
subject {project_file_at('spec/fixtures')}
|
24
|
+
it {should == 'spec/fixtures/project.pbxproj'}
|
25
|
+
end
|
26
|
+
|
27
|
+
context "when given 'spec'" do
|
28
|
+
subject {project_file_at('spec')}
|
29
|
+
it {should == 'spec/fixtures/project.pbxproj'}
|
30
|
+
end
|
31
|
+
|
32
|
+
context "when given 'spec/fixtures/TestApp'" do
|
33
|
+
subject {project_file_at('spec/fixtures/TestApp')}
|
34
|
+
it {should == 'spec/fixtures/TestApp/TestApp.xcodeproj/project.pbxproj'}
|
35
|
+
end
|
36
|
+
|
37
|
+
context "when given 'spec/fixtures/TestApp/TestApp.xcodeproj'" do
|
38
|
+
subject {project_file_at('spec/fixtures/TestApp/TestApp.xcodeproj')}
|
39
|
+
it {should == 'spec/fixtures/TestApp/TestApp.xcodeproj/project.pbxproj'}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#project_root_at' do
|
44
|
+
context "when given 'spec/fixtures/ZergSupport'" do
|
45
|
+
subject {project_root_at('spec/fixtures/ZergSupport')}
|
46
|
+
it {should == 'spec/fixtures'}
|
47
|
+
end
|
48
|
+
|
49
|
+
context "when given 'spec/fixtures/ZergSupport.xcodeproj'" do
|
50
|
+
subject {project_root_at('spec/fixtures/ZergSupport.xcodeproj')}
|
51
|
+
it {should == 'spec/fixtures'}
|
52
|
+
end
|
53
|
+
|
54
|
+
context "when given 'spec/fixtures'" do
|
55
|
+
subject {project_root_at('spec/fixtures')}
|
56
|
+
it {should == 'spec'}
|
57
|
+
end
|
58
|
+
|
59
|
+
context "when given 'spec'" do
|
60
|
+
subject {project_root_at('spec')}
|
61
|
+
it {should == 'spec'}
|
62
|
+
end
|
63
|
+
|
64
|
+
context "when given 'spec/fixtures/TestApp'" do
|
65
|
+
subject {project_root_at('spec/fixtures/TestApp')}
|
66
|
+
it {should == 'spec/fixtures/TestApp'}
|
67
|
+
end
|
68
|
+
|
69
|
+
context "when given 'spec/fixtures/TestApp/TestApp.xcodeproj'" do
|
70
|
+
subject {project_root_at('spec/fixtures/TestApp/TestApp.xcodeproj')}
|
71
|
+
it {should == 'spec/fixtures/TestApp'}
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'zerg_xcode'
|
2
|
+
|
3
|
+
describe ZergXcode do
|
4
|
+
|
5
|
+
context "when loading a file" do
|
6
|
+
subject {ZergXcode.load 'spec/fixtures/ZergSupport'}
|
7
|
+
|
8
|
+
it "should find the targets" do
|
9
|
+
targets = subject['targets'].map{ |target| target['name'] }.sort
|
10
|
+
targets.should == ['ZergSupport', 'ZergTestSupport', 'ZergSupportTests'].sort
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should set the project's source filename" do
|
14
|
+
subject.source_filename.should == 'spec/fixtures/ZergSupport.xcodeproj/project.pbxproj'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when finding plugins" do
|
19
|
+
it "should return the correct class" do
|
20
|
+
ZergXcode.plugin('ls').should be_a(ZergXcode::Plugins::Ls)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -9,7 +9,7 @@ class PBXBuildFileTest < Test::Unit::TestCase
|
|
9
9
|
PBXBuildFile = ZergXcode::Objects::PBXBuildFile
|
10
10
|
|
11
11
|
def setup
|
12
|
-
@target = ZergXcode.load('
|
12
|
+
@target = ZergXcode.load('spec/fixtures/project.pbxproj')['targets'].first
|
13
13
|
@sources_phase = @target['buildPhases'][1]
|
14
14
|
@build_file = @sources_phase['files'].first
|
15
15
|
end
|
@@ -19,7 +19,7 @@ class PBXBuildFileTest < Test::Unit::TestCase
|
|
19
19
|
assert_equal 'main.m', @build_file.filename
|
20
20
|
assert_equal 'sourcecode.c.objc', @build_file.file_type
|
21
21
|
|
22
|
-
big_project = ZergXcode.load('
|
22
|
+
big_project = ZergXcode.load('spec/fixtures/ZergSupport')
|
23
23
|
big_project['targets'].map { |t| t.all_files }.flatten.each do |file|
|
24
24
|
assert_not_nil file[:build_object].file_type,
|
25
25
|
"No file type for #{file[:build_object].inspect}"
|
@@ -27,7 +27,7 @@ class PBXBuildFileTest < Test::Unit::TestCase
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def test_guessed_build_phase_type
|
30
|
-
big_project = ZergXcode.load('
|
30
|
+
big_project = ZergXcode.load('spec/fixtures/ZergSupport')
|
31
31
|
|
32
32
|
phases = @target['buildPhases'] +
|
33
33
|
big_project['targets'].map { |t| t['buildPhases'] }.flatten
|
@@ -9,7 +9,7 @@ class PBXBuildPhaseTest < Test::Unit::TestCase
|
|
9
9
|
PBXBuildPhase = ZergXcode::Objects::PBXBuildPhase
|
10
10
|
|
11
11
|
def setup
|
12
|
-
@target = ZergXcode.load('
|
12
|
+
@target = ZergXcode.load('spec/fixtures/project.pbxproj')['targets'].first
|
13
13
|
@sources_phase = @target['buildPhases'][1]
|
14
14
|
end
|
15
15
|
|
@@ -10,7 +10,7 @@ class PBXContainerItemProxyTest < Test::Unit::TestCase
|
|
10
10
|
|
11
11
|
def setup
|
12
12
|
@project = ZergXcode.load(
|
13
|
-
'
|
13
|
+
'spec/fixtures/ZergSupport.xcodeproj/project.pbxproj')
|
14
14
|
@proxy = @project['targets'][2]['dependencies'].first['targetProxy']
|
15
15
|
@target = @project['targets'][1]
|
16
16
|
end
|
@@ -23,7 +23,7 @@ class PBXNativeTargetTest < Test::Unit::TestCase
|
|
23
23
|
"System/Library/Frameworks/CoreGraphics.framework"],
|
24
24
|
]
|
25
25
|
|
26
|
-
project = ZergXcode.load('
|
26
|
+
project = ZergXcode.load('spec/fixtures/project.pbxproj')
|
27
27
|
assert_equal PBXNativeTarget, project['targets'].first.class
|
28
28
|
files = project['targets'].first.all_files
|
29
29
|
file_list = files.map do |file|
|
@@ -31,4 +31,4 @@ class PBXNativeTargetTest < Test::Unit::TestCase
|
|
31
31
|
end
|
32
32
|
assert_equal golden_list.sort, file_list.sort
|
33
33
|
end
|
34
|
-
end
|
34
|
+
end
|
@@ -32,7 +32,7 @@ class PBXProjectTest < Test::Unit::TestCase
|
|
32
32
|
["BUILT_PRODUCTS_DIR/TestApp.app", nil],
|
33
33
|
]
|
34
34
|
|
35
|
-
project = ZergXcode.load('
|
35
|
+
project = ZergXcode.load('spec/fixtures/project.pbxproj')
|
36
36
|
assert_equal PBXProject, project.class
|
37
37
|
files = project.all_files
|
38
38
|
file_list = files.map { |f| [f[:path], f[:object]['lastKnownFileType']] }
|
@@ -49,7 +49,7 @@ class PBXProjectTest < Test::Unit::TestCase
|
|
49
49
|
["./ZergSupport/TestSupport/GTM/GTMDefines.h", "sourcecode.c.h"],
|
50
50
|
["./ZergSupport/WebSupport/ZNHttpRequest.m", "sourcecode.c.objc"],
|
51
51
|
]
|
52
|
-
files = ZergXcode.load('
|
52
|
+
files = ZergXcode.load('spec/fixtures/ZergSupport').all_files
|
53
53
|
file_list = files.map { |f| [f[:path], f[:object]['lastKnownFileType']] }
|
54
54
|
golden_entries.each do |entry|
|
55
55
|
assert file_list.include?(entry), "Missing #{entry.inspect}"
|
@@ -57,32 +57,32 @@ class PBXProjectTest < Test::Unit::TestCase
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def test_save
|
60
|
-
project = ZergXcode.load('
|
60
|
+
project = ZergXcode.load('spec/fixtures')
|
61
61
|
flexmock(ZergXcode).should_receive(:dump).
|
62
|
-
with(project, '
|
62
|
+
with(project, 'spec/fixtures/project.pbxproj').
|
63
63
|
and_return(nil)
|
64
64
|
project.save!
|
65
65
|
end
|
66
66
|
|
67
67
|
def test_root_path
|
68
|
-
project = ZergXcode.load('
|
69
|
-
assert_equal '
|
68
|
+
project = ZergXcode.load('spec/fixtures/ZergSupport.xcodeproj')
|
69
|
+
assert_equal 'spec/fixtures', project.root_path
|
70
70
|
end
|
71
71
|
|
72
72
|
def test_copy_metadata
|
73
|
-
project = ZergXcode.load('
|
73
|
+
project = ZergXcode.load('spec/fixtures/ZergSupport.xcodeproj')
|
74
74
|
clone = ZergXcode::XcodeObject.from project
|
75
75
|
|
76
76
|
assert_equal project.source_filename, clone.source_filename
|
77
77
|
end
|
78
78
|
|
79
79
|
def test_xref_name
|
80
|
-
project = ZergXcode.load('
|
80
|
+
project = ZergXcode.load('spec/fixtures/project.pbxproj')
|
81
81
|
assert_equal 'PBXProject', project.xref_name
|
82
82
|
end
|
83
83
|
|
84
84
|
def test_find_group_named
|
85
|
-
project = ZergXcode.load('
|
85
|
+
project = ZergXcode.load('spec/fixtures/project.pbxproj')
|
86
86
|
found_group = project.find_group_named("Classes")
|
87
87
|
assert_not_nil found_group
|
88
88
|
assert_equal PBXGroup, found_group.class
|
@@ -10,7 +10,7 @@ class PBXTargetDependencyTest < Test::Unit::TestCase
|
|
10
10
|
|
11
11
|
def setup
|
12
12
|
@project = ZergXcode.load(
|
13
|
-
'
|
13
|
+
'spec/fixtures/ZergSupport.xcodeproj/project.pbxproj')
|
14
14
|
@dependency = @project['targets'][2]['dependencies'].first
|
15
15
|
@target = @project['targets'][1]
|
16
16
|
end
|
@@ -9,7 +9,7 @@ class XCConfigurationListTest < Test::Unit::TestCase
|
|
9
9
|
XCConfigurationList = ZergXcode::Objects::XCConfigurationList
|
10
10
|
|
11
11
|
def test_xref_name
|
12
|
-
proj = ZergXcode.load '
|
12
|
+
proj = ZergXcode.load 'spec/fixtures/project.pbxproj'
|
13
13
|
list = proj['buildConfigurationList']
|
14
14
|
assert_equal XCConfigurationList, list.class
|
15
15
|
assert_equal 'XCConfigurationList', list.xref_name
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
require 'zerg_xcode'
|
6
6
|
require 'test/unit'
|
7
|
-
require '
|
7
|
+
require 'plugins/helper.rb'
|
8
8
|
|
9
9
|
module Plugins; end
|
10
10
|
|
@@ -14,7 +14,7 @@ class Plugins::AddlibraryTest < Test::Unit::TestCase
|
|
14
14
|
def setup
|
15
15
|
super
|
16
16
|
@plugin = ZergXcode.plugin 'addlibrary'
|
17
|
-
@project = ZergXcode.load '
|
17
|
+
@project = ZergXcode.load 'spec/fixtures/ZergSupport'
|
18
18
|
|
19
19
|
@lib, @test_lib, @test_app = *@project['targets']
|
20
20
|
end
|