From e6dc134803dd33bb7cc16738ace1f3e914dfd048 Mon Sep 17 00:00:00 2001 From: temrich Date: Mon, 4 Feb 2019 11:49:44 -0800 Subject: [PATCH] Adds a test_host for executing Promises tests on real iOS devices. (#95) * Updates Bazel Apple rules to 0.13.0 and xctestrunner to 0.2.6. * Updates Travis before_install steps to manually download Bazel rather than rely on Homebrew. Update to Bazel 0.22.0. * Adds Tulsi support. * Adds a test_host for executing Promises tests on a real iOS device. --- .travis.yml | 13 ++-- BUILD | 34 +++++++++- Promises.tulsiproj/Configs/Promises.tulsigen | 68 ++++++++++++++++++++ Promises.tulsiproj/project.tulsiconf | 14 ++++ Promises.xcodeproj/TestHost_Info.plist | 21 ++++++ Tests/TestHost/AppDelegate.swift | 25 +++++++ WORKSPACE | 4 +- 7 files changed, 168 insertions(+), 11 deletions(-) create mode 100644 Promises.tulsiproj/Configs/Promises.tulsigen create mode 100644 Promises.tulsiproj/project.tulsiconf create mode 100644 Promises.xcodeproj/TestHost_Info.plist create mode 100644 Tests/TestHost/AppDelegate.swift diff --git a/.travis.yml b/.travis.yml index 2a54e90..719893a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,13 +2,14 @@ os: osx osx_image: xcode10.1 language: objective-c install: true -addons: - homebrew: - taps: homebrew/cask-versions - casks: java8 before_install: - - brew update - - brew install bazel + - bazel_version=0.22.0 + - bazel_script=/tmp/bazel.sh + - curl -L https://github.com/bazelbuild/bazel/releases/download/$bazel_version/bazel-$bazel_version-installer-darwin-x86_64.sh -o $bazel_script + - chmod +x $bazel_script + - sh $bazel_script --user + - export PATH="$PATH:$HOME/bin" script: - bazel shutdown + - bazel version - bazel test Tests --nokeep_state_after_build --spawn_strategy=standalone --genrule_strategy=standalone --test_strategy=standalone --noshow_progress --noshow_loading_progress --verbose_failures --test_verbose_timeout_warnings --test_output=errors diff --git a/BUILD b/BUILD index 466fd28..93b7098 100644 --- a/BUILD +++ b/BUILD @@ -4,7 +4,7 @@ licenses(["notice"]) # Apache 2.0 exports_files(["LICENSE"]) -load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test") +load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application", "ios_unit_test") load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") OBJC_COPTS = [ @@ -19,6 +19,8 @@ SWIFT_COPTS = [ "-wmo", ] +MINIMUM_OS_VERSION = "8.0" + swift_library( name = "Promises", srcs = glob([ @@ -83,8 +85,8 @@ objc_library( ios_unit_test( name = "Tests", - minimum_os_version = "8.0", - test_host = "@build_bazel_rules_apple//apple/testing/default_host/ios", + minimum_os_version = MINIMUM_OS_VERSION, + test_host = ":TestHostApp", deps = [ ":FBLPromisesInteroperabilityTests", ":FBLPromisesPerformanceTests", @@ -95,6 +97,32 @@ ios_unit_test( ], ) +ios_application( + name = "TestHostApp", + testonly = 1, + bundle_id = "com.google.promises.TestHost", + families = [ + "iphone", + "ipad", + ], + infoplists = [ + "Promises.xcodeproj/TestHost_Info.plist", + ], + minimum_os_version = MINIMUM_OS_VERSION, + deps = [ + ":TestHost", + ], +) + +swift_library( + name = "TestHost", + testonly = 1, + srcs = glob([ + "Tests/TestHost/*.swift", + ]), + copts = SWIFT_COPTS, +) + swift_library( name = "PromisesTests", testonly = 1, diff --git a/Promises.tulsiproj/Configs/Promises.tulsigen b/Promises.tulsiproj/Configs/Promises.tulsigen new file mode 100644 index 0000000..91475ec --- /dev/null +++ b/Promises.tulsiproj/Configs/Promises.tulsigen @@ -0,0 +1,68 @@ +{ + "sourceFilters" : [ + "Sources", + "Sources/FBLPromises", + "Sources/FBLPromises/DotSyntax", + "Sources/FBLPromises/include", + "Sources/FBLPromises/include/DotSyntax", + "Sources/FBLPromisesTestHelpers", + "Sources/FBLPromisesTestHelpers/include", + "Sources/Promises", + "Sources/PromisesTestHelpers", + "Tests", + "Tests/FBLPromisesInteroperabilityTests", + "Tests/FBLPromisesPerformanceTests", + "Tests/FBLPromisesTests", + "Tests/PromisesInteroperabilityTests", + "Tests/PromisesPerformanceTests", + "Tests/PromisesTests", + "Tests/TestHost" + ], + "buildTargets" : [ + "//:FBLPromises", + "//:Promises", + "//:Tests" + ], + "projectName" : "Promises", + "optionSet" : { + "BazelBuildOptionsDebug" : { + "p" : "$(inherited)" + }, + "BazelBuildStartupOptionsRelease" : { + "p" : "$(inherited)" + }, + "LaunchActionPreActionScript" : { + "p" : "$(inherited)" + }, + "BazelBuildOptionsRelease" : { + "p" : "$(inherited)" + }, + "EnvironmentVariables" : { + "p" : "$(inherited)" + }, + "BuildActionPreActionScript" : { + "p" : "$(inherited)" + }, + "CommandlineArguments" : { + "p" : "$(inherited)" + }, + "TestActionPreActionScript" : { + "p" : "$(inherited)" + }, + "TestActionPostActionScript" : { + "p" : "$(inherited)" + }, + "BuildActionPostActionScript" : { + "p" : "$(inherited)" + }, + "BazelBuildStartupOptionsDebug" : { + "p" : "$(inherited)" + }, + "LaunchActionPostActionScript" : { + "p" : "$(inherited)" + } + }, + "additionalFilePaths" : [ + "BUILD" + ] +} diff --git a/Promises.tulsiproj/project.tulsiconf b/Promises.tulsiproj/project.tulsiconf new file mode 100644 index 0000000..65b3140 --- /dev/null +++ b/Promises.tulsiproj/project.tulsiconf @@ -0,0 +1,14 @@ +{ + "configDefaults" : { + "optionSet" : { + "ProjectPrioritizesSwift" : { + "p" : "YES" + } + } + }, + "projectName" : "Promises", + "packages" : [ + "" + ], + "workspaceRoot" : ".." +} diff --git a/Promises.xcodeproj/TestHost_Info.plist b/Promises.xcodeproj/TestHost_Info.plist new file mode 100644 index 0000000..7765a4b --- /dev/null +++ b/Promises.xcodeproj/TestHost_Info.plist @@ -0,0 +1,21 @@ + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/Tests/TestHost/AppDelegate.swift b/Tests/TestHost/AppDelegate.swift new file mode 100644 index 0000000..0fcb392 --- /dev/null +++ b/Tests/TestHost/AppDelegate.swift @@ -0,0 +1,25 @@ +// Copyright 2018 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + return true + } +} diff --git a/WORKSPACE b/WORKSPACE index 6793194..f392c93 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -3,7 +3,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") git_repository( name = "build_bazel_rules_apple", remote = "https://github.com/bazelbuild/rules_apple.git", - tag = "0.12.0", + tag = "0.13.0", ) load( @@ -25,5 +25,5 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") http_file( name = "xctestrunner", executable = 1, - urls = ["https://github.com/google/xctestrunner/releases/download/0.2.5/ios_test_runner.par"], + urls = ["https://github.com/google/xctestrunner/releases/download/0.2.6/ios_test_runner.par"], )