Skip to content

Commit 30bbe62

Browse files
committed
Fixes CI.
1 parent 6f00016 commit 30bbe62

File tree

2 files changed

+150
-148
lines changed

2 files changed

+150
-148
lines changed

Tests/XCTest+Extensions.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import Foundation
1010
import XCTest
1111
import RxDataSources
1212

13-
func XCAssertEqual<S: AnimatableSectionModelType where S: Equatable>(_ lhs: [S], _ rhs: [S], file: StaticString = #file, line: UInt = #line) {
13+
func XCAssertEqual<S: AnimatableSectionModelType>(_ lhs: [S], _ rhs: [S], file: StaticString = #file, line: UInt = #line)
14+
where S: Equatable {
1415
let areEqual = lhs == rhs
1516
if !areEqual {
1617
printSectionModelDifferences(lhs, rhs)
@@ -19,18 +20,18 @@ func XCAssertEqual<S: AnimatableSectionModelType where S: Equatable>(_ lhs: [S],
1920
XCTAssertTrue(areEqual, file: file, line: line)
2021
}
2122

22-
struct EquatableArray<Element: Equatable> : Equatable {
23+
fileprivate struct EquatableArray<Element: Equatable> : Equatable {
2324
let elements: [Element]
2425
init(_ elements: [Element]) {
2526
self.elements = elements
2627
}
2728
}
2829

29-
func == <E: Equatable>(lhs: EquatableArray<E>, rhs: EquatableArray<E>) -> Bool {
30+
fileprivate func == <E: Equatable>(lhs: EquatableArray<E>, rhs: EquatableArray<E>) -> Bool {
3031
return lhs.elements == rhs.elements
3132
}
3233

33-
func printSequenceDifferences<E>(_ lhs: [E], _ rhs: [E], _ equal: (E, E) -> Bool) {
34+
fileprivate func printSequenceDifferences<E>(_ lhs: [E], _ rhs: [E], _ equal: (E, E) -> Bool) {
3435
print("Differences in sequence:")
3536
for (index, elements) in zip(lhs, rhs).enumerated() {
3637
let l = elements.0
@@ -50,7 +51,8 @@ func printSequenceDifferences<E>(_ lhs: [E], _ rhs: [E], _ equal: (E, E) -> Bool
5051
}
5152
}
5253

53-
func printSectionModelDifferences<S: AnimatableSectionModelType where S: Equatable>(_ lhs: [S], _ rhs: [S]) {
54+
fileprivate func printSectionModelDifferences<S: AnimatableSectionModelType>(_ lhs: [S], _ rhs: [S])
55+
where S: Equatable {
5456
print("Differences in sections:")
5557
for (index, elements) in zip(lhs, rhs).enumerated() {
5658
let l = elements.0

scripts/common.sh

Lines changed: 143 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -21,148 +21,148 @@ BOLDWHITE="\033[1m\033[37m"
2121

2222
# make sure all tests are passing
2323

24-
#if [ `xcrun simctl list runtimes | grep com.apple.CoreSimulator.SimRuntime.iOS-10-1 | wc -l` -eq 1 ]; then
25-
# DEFAULT_IOS_SIMULATOR=RxSwiftTest/iPhone-6/iOS/10.1
26-
#else
27-
# DEFAULT_IOS_SIMULATOR=RxSwiftTest/iPhone-6/iOS/10.0
28-
#fi
29-
#
30-
#if [ `xcrun simctl list runtimes | grep com.apple.CoreSimulator.SimRuntime.watchOS-3-1 | wc -l` -eq 1 ]; then
31-
# DEFAULT_WATCHOS_SIMULATOR=RxSwiftTest/Apple-Watch-38mm/watchOS/3.1
32-
#else
33-
# DEFAULT_WATCHOS_SIMULATOR=RxSwiftTest/Apple-Watch-38mm/watchOS/3.0
34-
#fi
35-
#
36-
#if [ `xcrun simctl list runtimes | grep com.apple.CoreSimulator.SimRuntime.tvOS-10-1 | wc -l` -eq 1 ]; then
37-
# DEFAULT_TVOS_SIMULATOR=RxSwiftTest/Apple-TV-1080p/tvOS/10.1
38-
#else
39-
# DEFAULT_TVOS_SIMULATOR=RxSwiftTest/Apple-TV-1080p/tvOS/10.0
40-
#fi
41-
#RUN_SIMULATOR_BY_NAME=0
42-
#
43-
#function runtime_available() {
44-
# if [ `xcrun simctl list runtimes | grep "${1}" | wc -l` -eq 1 ]; then
45-
# return 0
46-
# else
47-
# return 1
48-
# fi
49-
#}
24+
if [ `xcrun simctl list runtimes | grep com.apple.CoreSimulator.SimRuntime.iOS-10-1 | wc -l` -eq 1 ]; then
25+
DEFAULT_IOS_SIMULATOR=RxSwiftTest/iPhone-6/iOS/10.1
26+
else
27+
DEFAULT_IOS_SIMULATOR=RxSwiftTest/iPhone-6/iOS/10.0
28+
fi
29+
30+
if [ `xcrun simctl list runtimes | grep com.apple.CoreSimulator.SimRuntime.watchOS-3-1 | wc -l` -eq 1 ]; then
31+
DEFAULT_WATCHOS_SIMULATOR=RxSwiftTest/Apple-Watch-38mm/watchOS/3.1
32+
else
33+
DEFAULT_WATCHOS_SIMULATOR=RxSwiftTest/Apple-Watch-38mm/watchOS/3.0
34+
fi
35+
36+
if [ `xcrun simctl list runtimes | grep com.apple.CoreSimulator.SimRuntime.tvOS-10-1 | wc -l` -eq 1 ]; then
37+
DEFAULT_TVOS_SIMULATOR=RxSwiftTest/Apple-TV-1080p/tvOS/10.1
38+
else
39+
DEFAULT_TVOS_SIMULATOR=RxSwiftTest/Apple-TV-1080p/tvOS/10.0
40+
fi
41+
RUN_SIMULATOR_BY_NAME=0
42+
43+
function runtime_available() {
44+
if [ `xcrun simctl list runtimes | grep "${1}" | wc -l` -eq 1 ]; then
45+
return 0
46+
else
47+
return 1
48+
fi
49+
}
5050

5151
# used to check simulator name
52-
#function contains() {
53-
# string="$1"
54-
# substring="$2"
55-
# if [[ $string == *"$substring"* ]]
56-
# then
57-
# return 0 # $substring is in $string
58-
# else
59-
# return 1 # $substring is not in $string
60-
# fi
61-
#}
62-
#
63-
#function simulator_ids() {
64-
# SIMULATOR=$1
65-
# xcrun simctl list | grep "${SIMULATOR}" | cut -d "(" -f 2 | cut -d ")" -f 1 | sort | uniq
66-
#}
67-
#
68-
#function simulator_available() {
69-
# SIMULATOR=$1
70-
# if [ `simulator_ids "${SIMULATOR}" | wc -l` -eq 0 ]; then
71-
# return -1
72-
# elif [ `simulator_ids "${SIMULATOR}" | wc -l` -gt 1 ]; then
73-
# echo "Multiple simulators ${SIMULATOR} found"
74-
# xcrun simctl list | grep "${SIMULATOR}"
75-
# exit -1
76-
# elif [ `xcrun simctl list | grep "${SIMULATOR}" | grep "unavailable" | wc -l` -gt 0 ]; then
77-
# xcrun simctl list | grep "${SIMULATOR}" | grep "unavailable"
78-
# exit -1
79-
# else
80-
# return 0
81-
# fi
82-
#}
83-
#
84-
#function is_real_device() {
85-
# contains "$1" "’s "
86-
#}
87-
#
88-
#function ensure_simulator_available() {
89-
# SIMULATOR=$1
90-
#
91-
# if simulator_available "${SIMULATOR}"; then
92-
# echo "${SIMULATOR} exists"
93-
# return
94-
# fi
95-
#
96-
# DEVICE=`echo "${SIMULATOR}" | cut -d "/" -f 2`
97-
# OS=`echo "${SIMULATOR}" | cut -d "/" -f 3`
98-
# VERSION_SUFFIX=`echo "${SIMULATOR}" | cut -d "/" -f 4 | sed -e "s/\./-/"`
99-
#
100-
# RUNTIME="com.apple.CoreSimulator.SimRuntime.${OS}-${VERSION_SUFFIX}"
101-
#
102-
# echo "Creating new simulator with runtime=${RUNTIME}"
103-
# xcrun simctl create "${SIMULATOR}" "com.apple.CoreSimulator.SimDeviceType.${DEVICE}" "${RUNTIME}"
104-
#
105-
# SIMULATOR_ID=`simulator_ids "${SIMULATOR}"`
106-
# echo "Warming up ${SIMULATOR_ID} ..."
107-
# open -a "Simulator" --args -CurrentDeviceUDID "${SIMULATOR_ID}"
108-
# sleep 120
109-
#}
110-
#
111-
#BUILD_DIRECTORY=build
112-
#
113-
#function rx() {
114-
# action RxDataSources.xcworkspace "$1" "$2" "$3" "$4"
115-
#}
116-
#
117-
#function action() {
118-
# WORKSPACE=$1
119-
# SCHEME=$2
120-
# CONFIGURATION=$3
121-
# SIMULATOR=$4
122-
# ACTION=$5
123-
#
124-
# echo
125-
# printf "${GREEN}${ACTION} ${BOLDCYAN}$SCHEME - $CONFIGURATION ($SIMULATOR)${RESET}\n"
126-
# echo
127-
#
128-
# DESTINATION=""
129-
# if [ "${SIMULATOR}" != "" ]; then
130-
# #if it's a real device
131-
# if is_real_device "${SIMULATOR}"; then
132-
# DESTINATION='name='${SIMULATOR}
133-
# #else it's just a simulator
134-
# else
135-
# OS=`echo $SIMULATOR | cut -d '/' -f 3`
136-
# if [ "${RUN_SIMULATOR_BY_NAME}" -eq 1 ]; then
137-
# SIMULATOR_NAME=`echo $SIMULATOR | cut -d '/' -f 1`
138-
# DESTINATION='platform='$OS' Simulator,name='$SIMULATOR_NAME''
139-
# else
140-
# ensure_simulator_available "${SIMULATOR}"
141-
# SIMULATOR_GUID=`simulator_ids "${SIMULATOR}"`
142-
# DESTINATION='platform='$OS' Simulator,OS='$OS',id='$SIMULATOR_GUID''
143-
# fi
144-
# echo "Running on ${DESTINATION}"
145-
# fi
146-
# else
147-
# DESTINATION='platform=macOS,arch=x86_64'
148-
# fi
149-
#
150-
# set -x
151-
# killall Simulator || true
152-
# xcodebuild -workspace "${WORKSPACE}" \
153-
# -scheme "${SCHEME}" \
154-
# -configuration "${CONFIGURATION}" \
155-
# -derivedDataPath "${BUILD_DIRECTORY}" \
156-
# -destination "$DESTINATION" \
157-
# $ACTION | tee build/last-build-output.txt | xcpretty -c
158-
# exitIfLastStatusWasUnsuccessful
159-
# set +x
160-
#}
161-
#
162-
#function exitIfLastStatusWasUnsuccessful() {
163-
# STATUS=${PIPESTATUS[0]}
164-
# if [ $STATUS -ne 0 ]; then
165-
# echo $STATUS
166-
# exit $STATUS
167-
# fi
168-
#}
52+
function contains() {
53+
string="$1"
54+
substring="$2"
55+
if [[ $string == *"$substring"* ]]
56+
then
57+
return 0 # $substring is in $string
58+
else
59+
return 1 # $substring is not in $string
60+
fi
61+
}
62+
63+
function simulator_ids() {
64+
SIMULATOR=$1
65+
xcrun simctl list | grep "${SIMULATOR}" | cut -d "(" -f 2 | cut -d ")" -f 1 | sort | uniq
66+
}
67+
68+
function simulator_available() {
69+
SIMULATOR=$1
70+
if [ `simulator_ids "${SIMULATOR}" | wc -l` -eq 0 ]; then
71+
return -1
72+
elif [ `simulator_ids "${SIMULATOR}" | wc -l` -gt 1 ]; then
73+
echo "Multiple simulators ${SIMULATOR} found"
74+
xcrun simctl list | grep "${SIMULATOR}"
75+
exit -1
76+
elif [ `xcrun simctl list | grep "${SIMULATOR}" | grep "unavailable" | wc -l` -gt 0 ]; then
77+
xcrun simctl list | grep "${SIMULATOR}" | grep "unavailable"
78+
exit -1
79+
else
80+
return 0
81+
fi
82+
}
83+
84+
function is_real_device() {
85+
contains "$1" "’s "
86+
}
87+
88+
function ensure_simulator_available() {
89+
SIMULATOR=$1
90+
91+
if simulator_available "${SIMULATOR}"; then
92+
echo "${SIMULATOR} exists"
93+
return
94+
fi
95+
96+
DEVICE=`echo "${SIMULATOR}" | cut -d "/" -f 2`
97+
OS=`echo "${SIMULATOR}" | cut -d "/" -f 3`
98+
VERSION_SUFFIX=`echo "${SIMULATOR}" | cut -d "/" -f 4 | sed -e "s/\./-/"`
99+
100+
RUNTIME="com.apple.CoreSimulator.SimRuntime.${OS}-${VERSION_SUFFIX}"
101+
102+
echo "Creating new simulator with runtime=${RUNTIME}"
103+
xcrun simctl create "${SIMULATOR}" "com.apple.CoreSimulator.SimDeviceType.${DEVICE}" "${RUNTIME}"
104+
105+
SIMULATOR_ID=`simulator_ids "${SIMULATOR}"`
106+
echo "Warming up ${SIMULATOR_ID} ..."
107+
open -a "Simulator" --args -CurrentDeviceUDID "${SIMULATOR_ID}"
108+
sleep 120
109+
}
110+
111+
BUILD_DIRECTORY=build
112+
113+
function rx() {
114+
action RxDataSources.xcworkspace "$1" "$2" "$3" "$4"
115+
}
116+
117+
function action() {
118+
WORKSPACE=$1
119+
SCHEME=$2
120+
CONFIGURATION=$3
121+
SIMULATOR=$4
122+
ACTION=$5
123+
124+
echo
125+
printf "${GREEN}${ACTION} ${BOLDCYAN}$SCHEME - $CONFIGURATION ($SIMULATOR)${RESET}\n"
126+
echo
127+
128+
DESTINATION=""
129+
if [ "${SIMULATOR}" != "" ]; then
130+
#if it's a real device
131+
if is_real_device "${SIMULATOR}"; then
132+
DESTINATION='name='${SIMULATOR}
133+
#else it's just a simulator
134+
else
135+
OS=`echo $SIMULATOR | cut -d '/' -f 3`
136+
if [ "${RUN_SIMULATOR_BY_NAME}" -eq 1 ]; then
137+
SIMULATOR_NAME=`echo $SIMULATOR | cut -d '/' -f 1`
138+
DESTINATION='platform='$OS' Simulator,name='$SIMULATOR_NAME''
139+
else
140+
ensure_simulator_available "${SIMULATOR}"
141+
SIMULATOR_GUID=`simulator_ids "${SIMULATOR}"`
142+
DESTINATION='platform='$OS' Simulator,OS='$OS',id='$SIMULATOR_GUID''
143+
fi
144+
echo "Running on ${DESTINATION}"
145+
fi
146+
else
147+
DESTINATION='platform=macOS,arch=x86_64'
148+
fi
149+
150+
set -x
151+
killall Simulator || true
152+
xcodebuild -workspace "${WORKSPACE}" \
153+
-scheme "${SCHEME}" \
154+
-configuration "${CONFIGURATION}" \
155+
-derivedDataPath "${BUILD_DIRECTORY}" \
156+
-destination "$DESTINATION" \
157+
$ACTION | tee build/last-build-output.txt | xcpretty -c
158+
exitIfLastStatusWasUnsuccessful
159+
set +x
160+
}
161+
162+
function exitIfLastStatusWasUnsuccessful() {
163+
STATUS=${PIPESTATUS[0]}
164+
if [ $STATUS -ne 0 ]; then
165+
echo $STATUS
166+
exit $STATUS
167+
fi
168+
}

0 commit comments

Comments
 (0)