@@ -7,19 +7,36 @@ class TestRunningValidator < Pod::Validator
7
7
TEST_TARGET = 'Tests'
8
8
9
9
attr_accessor :test_files
10
+ attr_accessor :ios_simulator
11
+ attr_accessor :tvos_simulator
12
+
13
+ def initialize ( spec_or_path , source_urls )
14
+ super ( spec_or_path , source_urls )
15
+ self . ios_simulator = :oldest
16
+ self . tvos_simulator = :oldest
17
+ end
10
18
11
19
def create_app_project
12
- super . tap do
13
- project = Xcodeproj ::Project . open ( validation_dir + "#{ APP_TARGET } .xcodeproj" )
14
- create_test_target ( project )
15
- end
20
+ super
21
+ project = Xcodeproj ::Project . open ( validation_dir + "#{ APP_TARGET } .xcodeproj" )
22
+ create_test_target ( project )
23
+ project . save
24
+ end
25
+
26
+ def add_app_project_import
27
+ super
28
+ project = Xcodeproj ::Project . open ( validation_dir + 'App.xcodeproj' )
29
+ group = project . new_group ( TEST_TARGET )
30
+ test_target = project . targets . last
31
+ test_target . add_file_references ( test_files . map { |file | group . new_file ( file ) } )
32
+ add_swift_version ( test_target )
33
+ project . save
16
34
end
17
35
18
36
def install_pod
19
- super . tap do
20
- if local?
21
- FileUtils . ln_s file . dirname , validation_dir + "Pods/#{ spec . name } "
22
- end
37
+ super
38
+ if local?
39
+ FileUtils . ln_s file . dirname , validation_dir + "Pods/#{ spec . name } "
23
40
end
24
41
end
25
42
@@ -39,11 +56,7 @@ def build_pod
39
56
private
40
57
def create_test_target ( project )
41
58
test_target = project . new_target ( :unit_test_bundle , TEST_TARGET , consumer . platform_name , deployment_target )
42
- group = project . new_group ( TEST_TARGET )
43
- test_target . add_file_references ( test_files . map { |file | group . new_file ( file ) } )
44
- project . save
45
59
create_test_scheme ( project , test_target )
46
- project
47
60
end
48
61
49
62
def create_test_scheme ( project , test_target )
@@ -63,21 +76,27 @@ def add_test_target(pod_file)
63
76
end
64
77
65
78
def run_tests
66
- command = %W( clean test -workspace #{ APP_TARGET } .xcworkspace -scheme #{ TEST_TARGET } -configuration Debug )
79
+ command = [
80
+ 'clean' , 'test' ,
81
+ '-workspace' , File . join ( validation_dir , "#{ APP_TARGET } .xcworkspace" ) ,
82
+ '-scheme' , TEST_TARGET ,
83
+ '-configuration' , 'Debug'
84
+ ]
67
85
case consumer . platform_name
68
86
when :ios
69
87
command += %w( CODE_SIGN_IDENTITY=- -sdk iphonesimulator )
70
- command += Fourflusher ::SimControl . new . destination ( 'iPhone 4s ', deployment_target )
88
+ command += Fourflusher ::SimControl . new . destination ( ios_simulator , 'iOS ', deployment_target )
71
89
when :osx
72
90
command += %w( LD_RUNPATH_SEARCH_PATHS=@loader_path/../Frameworks )
73
91
when :tvos
74
92
command += %w( CODE_SIGN_IDENTITY=- -sdk appletvsimulator )
75
- command += Fourflusher ::SimControl . new . destination ( 'Apple TV 1080p ', deployment_target )
93
+ command += Fourflusher ::SimControl . new . destination ( tvos_simulator , 'tvOS ', deployment_target )
76
94
else
77
95
return # skip watchos
78
96
end
79
97
80
- output , status = Dir . chdir ( validation_dir ) { _xcodebuild ( command ) }
98
+ output , status = _xcodebuild ( command )
99
+
81
100
unless status . success?
82
101
message = 'Returned an unsuccessful exit code.'
83
102
if config . verbose?
@@ -87,5 +106,6 @@ def run_tests
87
106
end
88
107
error ( 'xcodebuild' , message )
89
108
end
109
+ output
90
110
end
91
111
end
0 commit comments