Skip to content

Commit

Permalink
Add shell test to msvc CROSSTOOL
Browse files Browse the repository at this point in the history
--
Change-Id: I4df7be7de77dd5d44b2090311bce79dbc85a6775
Reviewed-on: https://bazel-review.googlesource.com/#/c/3388
MOS_MIGRATED_REVID=120232900
  • Loading branch information
meteorcloudy authored and damienmg committed Apr 20, 2016
1 parent c10ce5c commit cf215d3
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/test/shell/bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ sh_test(
shard_count = 3,
)

sh_test(
name = "bazel_windows_cpp_test",
size = "large",
srcs = ["bazel_windows_cpp_test.sh"],
data = [
":test-deps",
],
)

sh_test(
name = "bazel_rust_example_test",
srcs = ["bazel_rust_example_test.sh"],
Expand Down
64 changes: 64 additions & 0 deletions src/test/shell/bazel/bazel_windows_cpp_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash
#
# Copyright 2016 The Bazel Authors. 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.
#
# Tests the examples provided in Bazel with MSVC toolchain
#

# Load test environment
source $(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/test-setup.sh \
|| { echo "test-setup.sh not found!" >&2; exit 1; }

if ! is_windows; then
echo "This test suite requires running on Windows. But now is ${PLATFORM}" >&2
exit 0
fi

function set_up() {
copy_examples
}

common_args="-s --verbose_failures --crosstool_top=//tools/cpp:default-toolchain --cpu=x64_windows_msvc"

function assert_build_windows() {
bazel build ${common_args} $* || fail "Failed to build $*"
}

function assert_test_ok_windows() {
bazel test ${common_args} --test_output=errors $* \
|| fail "Test $1 failed while expecting success"
}

function assert_test_fails_windows() {
bazel test ${common_args} --test_output=errors $* >& $TEST_log \
&& fail "Test $* succeed while expecting failure" \
|| true
expect_log "$1.*FAILED"
}

#
# Native rules
#
function test_cpp() {
local cpp_pkg=examples/cpp
assert_build_windows "//examples/cpp:hello-world"
test -f "./bazel-bin/${cpp_pkg}/libhello-lib.a" || fail "libhello-lib.a should be generated"
assert_binary_run "./bazel-bin/${cpp_pkg}/hello-world foo" "Hello foo"
assert_test_ok_windows "//examples/cpp:hello-success_test"
assert_test_fails_windows "//examples/cpp:hello-fail_test"
}

run_suite "cpp examples on Windows"

0 comments on commit cf215d3

Please sign in to comment.