-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathXcodeUnitTestGUI.applescript
More file actions
169 lines (151 loc) · 5.1 KB
/
XcodeUnitTestGUI.applescript
File metadata and controls
169 lines (151 loc) · 5.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
--
-- XcodeUnitTestGUI.applescript
--
-- Xcode Unit Test GUI
-- Copyright (c) 2009 Jon Nall, STUNTAZ!!!
-- All rights reserved.
--
-- Permission is hereby granted, free of charge, to any person
-- obtaining a copy of this software and associated documentation
-- files (the "Software"), to deal in the Software without
-- restriction, including without limitation the rights to use,
-- copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the
-- Software is furnished to do so, subject to the following
-- conditions:
--
-- The above copyright notice and this permission notice shall be
-- included in all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-- OTHER DEALINGS IN THE SOFTWARE.
on getUnitTestTargets()
tell application "Xcode"
set theList to {}
set theProject to project of active project document
repeat with theTarget in targets of theProject
if (my isTargetUnitTest(theTarget) is 1) then
set theList to theList & {name of theTarget}
end if
end repeat
return theList
end tell
end getUnitTestTargets
on getUnitTestConfigs(theTargetName)
tell application "Xcode"
set theList to {}
set theTarget to my findTargetByName(theTargetName)
repeat with theBuildConf in build configurations of theTarget
set theList to theList & {name of theBuildConf}
end repeat
return theList
end tell
end getUnitTestConfigs
on getUnitTestTargetPath(theTargetName)
tell application "Xcode"
set theTarget to my findTargetByName(theTargetName)
set theProduct to product reference of theTarget
return full path of theProduct
end tell
end getUnitTestTargetPath
on getCurrentTarget()
tell application "Xcode"
set theTarget to active target of project of active project document
return name of theTarget
end tell
end getCurrentTarget
on setCurrentTarget(theTargetName)
tell application "Xcode"
set theTarget to my findTargetByName(theTargetName)
set active target of project of active project document to theTarget
end tell
end setCurrentTarget
on getCurrentBuildConfig()
tell application "Xcode"
return name of active build configuration type of project of active project document
end tell
end getCurrentBuildConfig
on setCurrentBuildConfig(theConfigName)
tell application "Xcode"
set theConf to my findBuildConfByName(theConfigName)
if theConf is null then
display dialog "Cannot find build configuration " & theConfigName & " in project"
end if
set active build configuration type of project of active project document to theConf
end tell
end setCurrentBuildConfig
on findTargetByName(theName)
tell application "Xcode"
set theProject to project of active project document
repeat with theTarget in targets of theProject
if (name of theTarget is theName) then
return theTarget
end if
end repeat
return null
end tell
end findTargetByName
on findBuildConfByName(theName)
tell application "Xcode"
repeat with theConf in build configurations of project of active project document
if name of theConf is theName then
return theConf
end if
end repeat
return null
end tell
end findBuildConfByName
on findBuildConfByNameInTarget(theName, theTarget)
tell application "Xcode"
repeat with theConf in build configurations of theTarget
if name of theConf is theName then
return theConf
end if
end repeat
return null
end tell
end findBuildConfByNameInTarget
on getActiveProjectName()
tell application "Xcode"
return name of project of active project document
end tell
end getActiveProjectName
on doBuild()
tell application "Xcode"
set theTranscript to build with transcript
return theTranscript
end tell
end doBuild
on isTargetUnitTest(theTarget)
tell application "Xcode"
set foundOCTest to 0
if target type of theTarget is "Bundle" then
repeat with theBuildConf in build configurations of theTarget
repeat with theSetting in build settings of theBuildConf
if name of theSetting is "WRAPPER_EXTENSION" and value of theSetting is "octest" then
set foundOCTest to 1
exit repeat
end if
end repeat -- iterate over build settings
end repeat -- iterate over build configs
end if -- execute if this target is a bundle
return foundOCTest
end tell
end isTargetUnitTest
on modifyBuildSetting(theTargetName, theBuildConfName, theSettingName, theSettingValue)
tell application "Xcode"
set theTarget to my findTargetByName(theTargetName)
set theBuildConf to my findBuildConfByNameInTarget(theBuildConfName, theTarget)
repeat with theSetting in build settings of theBuildConf
if name of theSetting is theSettingName then
set value of theSetting to theSettingValue
end if
end repeat
end tell
end modifyBuildSetting