e2e tests: make them run on Windows (#121)
This commit is contained in:
parent
2d1669ed88
commit
b2dc5c0e63
|
@ -50,9 +50,10 @@ tasks:
|
||||||
test_targets:
|
test_targets:
|
||||||
- "--"
|
- "--"
|
||||||
- "//..."
|
- "//..."
|
||||||
# Shell tests don't run on windows.
|
test_flags:
|
||||||
- "-//tests:analysis_test_e2e_test"
|
# TODO(laszlocsomor): remove "--test_env=LOCALAPPDATA" after
|
||||||
- "-//tests:unittest_e2e_test"
|
# https://github.com/bazelbuild/bazel/issues/7761 is fixed
|
||||||
|
- "--test_env=LOCALAPPDATA"
|
||||||
|
|
||||||
ubuntu1804_last_green:
|
ubuntu1804_last_green:
|
||||||
name: "Last Green Bazel"
|
name: "Last Green Bazel"
|
||||||
|
@ -104,8 +105,9 @@ tasks:
|
||||||
test_targets:
|
test_targets:
|
||||||
- "--"
|
- "--"
|
||||||
- "//..."
|
- "//..."
|
||||||
# Shell tests don't run on windows.
|
test_flags:
|
||||||
- "-//tests:analysis_test_e2e_test"
|
# TODO(laszlocsomor): remove "--test_env=LOCALAPPDATA" after
|
||||||
- "-//tests:unittest_e2e_test"
|
# https://github.com/bazelbuild/bazel/issues/7761 is fixed
|
||||||
|
- "--test_env=LOCALAPPDATA"
|
||||||
|
|
||||||
buildifier: latest
|
buildifier: latest
|
||||||
|
|
|
@ -62,6 +62,12 @@ sh_test(
|
||||||
data = [
|
data = [
|
||||||
":unittest.bash",
|
":unittest.bash",
|
||||||
":unittest_tests_bzl",
|
":unittest_tests_bzl",
|
||||||
|
"//lib:dicts.bzl",
|
||||||
|
"//lib:new_sets.bzl",
|
||||||
|
"//lib:old_sets.bzl",
|
||||||
|
"//lib:sets.bzl",
|
||||||
|
"//lib:types.bzl",
|
||||||
|
"//lib:unittest.bzl",
|
||||||
"//toolchains/unittest:test_deps",
|
"//toolchains/unittest:test_deps",
|
||||||
"@bazel_tools//tools/bash/runfiles",
|
"@bazel_tools//tools/bash/runfiles",
|
||||||
],
|
],
|
||||||
|
|
|
@ -44,19 +44,23 @@ fi
|
||||||
source "$(rlocation bazel_skylib/tests/unittest.bash)" \
|
source "$(rlocation bazel_skylib/tests/unittest.bash)" \
|
||||||
|| { echo "Could not source bazel_skylib/tests/unittest.bash" >&2; exit 1; }
|
|| { echo "Could not source bazel_skylib/tests/unittest.bash" >&2; exit 1; }
|
||||||
|
|
||||||
function set_up() {
|
function create_pkg() {
|
||||||
touch WORKSPACE
|
local -r pkg="$1"
|
||||||
|
mkdir -p "$pkg"
|
||||||
|
cd "$pkg"
|
||||||
|
|
||||||
cat > WORKSPACE <<EOF
|
cat > WORKSPACE <<EOF
|
||||||
workspace(name = 'bazel_skylib')
|
workspace(name = 'bazel_skylib')
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
touch rules/BUILD
|
mkdir -p rules
|
||||||
cat > rules/BUILD <<EOF
|
cat > rules/BUILD <<EOF
|
||||||
exports_files(["*.bzl"])
|
exports_files(["*.bzl"])
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
ln -sf "$(rlocation bazel_skylib/rules/analysis_test.bzl)" rules/analysis_test.bzl
|
||||||
|
|
||||||
mkdir -p fakerules
|
mkdir -p fakerules
|
||||||
touch fakerules/rules.bzl
|
|
||||||
cat > fakerules/rules.bzl <<EOF
|
cat > fakerules/rules.bzl <<EOF
|
||||||
load("//rules:analysis_test.bzl", "analysis_test")
|
load("//rules:analysis_test.bzl", "analysis_test")
|
||||||
|
|
||||||
|
@ -76,7 +80,6 @@ fake_depending_rule = rule(
|
||||||
)
|
)
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
touch fakerules/BUILD
|
|
||||||
cat > fakerules/BUILD <<EOF
|
cat > fakerules/BUILD <<EOF
|
||||||
exports_files(["*.bzl"])
|
exports_files(["*.bzl"])
|
||||||
EOF
|
EOF
|
||||||
|
@ -118,27 +121,31 @@ analysis_test(
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
function tear_down() {
|
|
||||||
rm -rf testdir
|
|
||||||
rm -rf fakerules
|
|
||||||
}
|
|
||||||
|
|
||||||
function test_target_succeeds() {
|
function test_target_succeeds() {
|
||||||
bazel test //testdir:target_succeeds >"$TEST_log" 2>&1 || fail "Expected test to pass"
|
local -r pkg="${FUNCNAME[0]}"
|
||||||
|
create_pkg "$pkg"
|
||||||
|
|
||||||
|
bazel test testdir:target_succeeds >"$TEST_log" 2>&1 || fail "Expected test to pass"
|
||||||
|
|
||||||
expect_log "PASSED"
|
expect_log "PASSED"
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_direct_target_fails() {
|
function test_direct_target_fails() {
|
||||||
! bazel test //testdir:direct_target_fails --test_output=all --verbose_failures \
|
local -r pkg="${FUNCNAME[0]}"
|
||||||
>"$TEST_log" 2>&1 || fail "Expected test to fail"
|
create_pkg "$pkg"
|
||||||
|
|
||||||
|
bazel test testdir:direct_target_fails --test_output=all --verbose_failures \
|
||||||
|
>"$TEST_log" 2>&1 && fail "Expected test to fail" || true
|
||||||
|
|
||||||
expect_log "This rule should never work"
|
expect_log "This rule should never work"
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_transitive_target_fails() {
|
function test_transitive_target_fails() {
|
||||||
! bazel test //testdir:transitive_target_fails --test_output=all --verbose_failures \
|
local -r pkg="${FUNCNAME[0]}"
|
||||||
>"$TEST_log" 2>&1 || fail "Expected test to fail"
|
create_pkg "$pkg"
|
||||||
|
|
||||||
|
bazel test testdir:transitive_target_fails --test_output=all --verbose_failures \
|
||||||
|
>"$TEST_log" 2>&1 && fail "Expected test to fail" || true
|
||||||
|
|
||||||
expect_log "This rule should never work"
|
expect_log "This rule should never work"
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,11 @@ fi
|
||||||
source "$(rlocation bazel_skylib/tests/unittest.bash)" \
|
source "$(rlocation bazel_skylib/tests/unittest.bash)" \
|
||||||
|| { echo "Could not source bazel_skylib/tests/unittest.bash" >&2; exit 1; }
|
|| { echo "Could not source bazel_skylib/tests/unittest.bash" >&2; exit 1; }
|
||||||
|
|
||||||
function set_up() {
|
function create_pkg() {
|
||||||
touch WORKSPACE
|
local -r pkg="$1"
|
||||||
|
mkdir -p "$pkg"
|
||||||
|
cd "$pkg"
|
||||||
|
|
||||||
cat > WORKSPACE <<EOF
|
cat > WORKSPACE <<EOF
|
||||||
workspace(name = 'bazel_skylib')
|
workspace(name = 'bazel_skylib')
|
||||||
|
|
||||||
|
@ -55,15 +58,24 @@ load("//lib:unittest.bzl", "register_unittest_toolchains")
|
||||||
register_unittest_toolchains()
|
register_unittest_toolchains()
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
mkdir -p tests
|
||||||
touch tests/BUILD
|
touch tests/BUILD
|
||||||
cat > tests/BUILD <<EOF
|
cat > tests/BUILD <<EOF
|
||||||
exports_files(["*.bzl"])
|
exports_files(["*.bzl"])
|
||||||
EOF
|
EOF
|
||||||
|
ln -sf "$(rlocation bazel_skylib/tests/unittest_tests.bzl)" tests/unittest_tests.bzl
|
||||||
|
|
||||||
|
mkdir -p lib
|
||||||
touch lib/BUILD
|
touch lib/BUILD
|
||||||
cat > lib/BUILD <<EOF
|
cat > lib/BUILD <<EOF
|
||||||
exports_files(["*.bzl"])
|
exports_files(["*.bzl"])
|
||||||
EOF
|
EOF
|
||||||
|
ln -sf "$(rlocation bazel_skylib/lib/dicts.bzl)" lib/dicts.bzl
|
||||||
|
ln -sf "$(rlocation bazel_skylib/lib/new_sets.bzl)" lib/new_sets.bzl
|
||||||
|
ln -sf "$(rlocation bazel_skylib/lib/old_sets.bzl)" lib/old_sets.bzl
|
||||||
|
ln -sf "$(rlocation bazel_skylib/lib/sets.bzl)" lib/sets.bzl
|
||||||
|
ln -sf "$(rlocation bazel_skylib/lib/types.bzl)" lib/types.bzl
|
||||||
|
ln -sf "$(rlocation bazel_skylib/lib/unittest.bzl)" lib/unittest.bzl
|
||||||
|
|
||||||
mkdir -p testdir
|
mkdir -p testdir
|
||||||
cat > testdir/BUILD <<EOF
|
cat > testdir/BUILD <<EOF
|
||||||
|
@ -85,28 +97,36 @@ fail_unexpected_passing_fake_rule(
|
||||||
name = "fail_unexpected_passing_fake_target",
|
name = "fail_unexpected_passing_fake_target",
|
||||||
tags = ["manual"])
|
tags = ["manual"])
|
||||||
EOF
|
EOF
|
||||||
}
|
|
||||||
|
|
||||||
function tear_down() {
|
mkdir -p toolchains/unittest
|
||||||
rm -rf testdir
|
ln -sf "$(rlocation bazel_skylib/toolchains/unittest/BUILD)" toolchains/unittest/BUILD
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_basic_passing_test() {
|
function test_basic_passing_test() {
|
||||||
bazel test //testdir:basic_passing_test >"$TEST_log" 2>&1 || fail "Expected test to pass"
|
local -r pkg="${FUNCNAME[0]}"
|
||||||
|
create_pkg "$pkg"
|
||||||
|
|
||||||
|
bazel test testdir:basic_passing_test >"$TEST_log" 2>&1 || fail "Expected test to pass"
|
||||||
|
|
||||||
expect_log "PASSED"
|
expect_log "PASSED"
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_basic_failing_test() {
|
function test_basic_failing_test() {
|
||||||
! bazel test //testdir:basic_failing_test --test_output=all --verbose_failures \
|
local -r pkg="${FUNCNAME[0]}"
|
||||||
>"$TEST_log" 2>&1 || fail "Expected test to fail"
|
create_pkg "$pkg"
|
||||||
|
|
||||||
|
bazel test testdir:basic_failing_test --test_output=all --verbose_failures \
|
||||||
|
>"$TEST_log" 2>&1 && fail "Expected test to fail" || true
|
||||||
|
|
||||||
expect_log "In test _basic_failing_test from //tests:unittest_tests.bzl: Expected \"1\", but got \"2\""
|
expect_log "In test _basic_failing_test from //tests:unittest_tests.bzl: Expected \"1\", but got \"2\""
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_fail_unexpected_passing_test() {
|
function test_fail_unexpected_passing_test() {
|
||||||
! bazel test //testdir:fail_unexpected_passing_test --test_output=all --verbose_failures \
|
local -r pkg="${FUNCNAME[0]}"
|
||||||
>"$TEST_log" 2>&1 || fail "Expected test to fail"
|
create_pkg "$pkg"
|
||||||
|
|
||||||
|
bazel test testdir:fail_unexpected_passing_test --test_output=all --verbose_failures \
|
||||||
|
>"$TEST_log" 2>&1 && fail "Expected test to fail" || true
|
||||||
|
|
||||||
expect_log "Expected failure of target_under_test, but found success"
|
expect_log "Expected failure of target_under_test, but found success"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue