Skip the UI tests on Travis by directly editing BGMApp's Xcode scheme.

Skipping them by overriding runTest didn't work and this is the only other way
I can think of. xcodebuild's -skip-testing option would work, but only with
recent versions of Xcode.
This commit is contained in:
Kyle Neideck 2017-02-19 20:25:54 +11:00
parent 7b32b6ef66
commit 87af15d290
No known key found for this signature in database
GPG key ID: CAA8D9B8E39EC18C
3 changed files with 51 additions and 13 deletions

View file

@ -48,6 +48,8 @@ script:
- ls -la "/Library/LaunchDaemons/com.bearisdriving.BGM.XPCHelper.plist"
# Close BGMApp (which the install script opened).
- osascript -e 'tell application "Background Music" to quit'
# Skip the UI tests until Travis has support for them.
- BGMApp/BGMAppTests/UITests/travis-skip.py
# Run the tests.
- xcodebuild -workspace BGM.xcworkspace -scheme 'Background Music Device' test
- xcodebuild -workspace BGM.xcworkspace -scheme 'Background Music' test

View file

@ -46,19 +46,6 @@
XCUIElement* prefs;
}
- (void) runTest {
// We can't run the tests on Travis because Xcode needs permission to use the Accessibility API
// to control BGMApp. There's no way to set that up programmatically without disabling SIP and
// Travis doesn't support that.
//
// See https://github.com/travis-ci/travis-ci/issues/5819
if (NSProcessInfo.processInfo.environment[@"TRAVIS"]) {
NSLog(@"Skipping the UI tests because Travis CI doesn't support UI testing.");
} else {
[super runTest];
}
}
- (void) setUp {
[super setUp];

View file

@ -0,0 +1,49 @@
#!/usr/bin/python2.7
# This file is part of Background Music.
#
# Background Music is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of the
# License, or (at your option) any later version.
#
# Background Music is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Background Music. If not, see <http://www.gnu.org/licenses/>.
#
# travis-skip.py
# BGMAppUITests
#
# Copyright © 2017 Kyle Neideck
#
# Skip the UI tests in Travis builds because they aren't supported.
#
# We can't run the tests on Travis because Xcode needs permission to use the Accessibility API
# to control BGMApp. There's no way to set that up programmatically without disabling SIP and
# Travis doesn't support that.
#
# See https://github.com/travis-ci/travis-ci/issues/5819
#
# TODO: Figure out a better way to do this.
#
import xml.etree.ElementTree as ET
SCHEME_FILE = "BGMApp/BGMApp.xcodeproj/xcshareddata/xcschemes/Background Music.xcscheme"
UI_REF_XPATH = ".//BuildableReference[@BlueprintName='BGMAppUITests']/.."
# Parse the Xcode scheme.
tree = ET.parse(SCHEME_FILE)
# Set the TestableReference for the UI tests to skipped.
tree.getroot().findall(UI_REF_XPATH)[0].set("skipped", "YES")
# Save the scheme.
tree.write(SCHEME_FILE)