@@ -63,11 +63,13 @@ test_scala_library_suite() {
63
63
action_should_fail build test_expect_failure/scala_library_suite:library_suite_dep_on_children
64
64
}
65
65
66
- test_scala_library_expect_failure_on_missing_direct_external_deps () {
67
- set +e
66
+ test_scala_library_expect_failure_on_missing_direct_deps () {
67
+ dependenecy_target=$1
68
+ test_target=$2
69
+
70
+ expected_message=" Target '$dependenecy_target ' is used but isn't explicitly declared, please add it to the deps"
71
+ command=" bazel build $test_target "
68
72
69
- expected_message=" Target '@com_google_guava_guava_21_0//jar:file' is used but isn't explicitly declared, please add it to the deps"
70
- command=' bazel build test_expect_failure/missing_direct_deps/external_deps:transitive_external_dependency_user'
71
73
output=$( $command 2>&1 )
72
74
if [ $? -eq 0 ]; then
73
75
echo " $output "
@@ -77,34 +79,26 @@ test_scala_library_expect_failure_on_missing_direct_external_deps() {
77
79
echo " $output "
78
80
echo $output | grep " $expected_message "
79
81
if [ $? -ne 0 ]; then
80
- echo " 'bazel build test_expect_failure/missing_direct_deps/external_deps:transitive_external_dependency_user ' should have logged \" $expected_message \" ."
82
+ echo " 'bazel build $test_target ' should have logged \" $expected_message \" ."
81
83
exit 1
82
84
fi
83
85
84
86
set -e
85
87
exit 0
86
88
}
87
89
88
- test_scala_library_expect_failure_on_missing_direct_internal_deps () {
89
- set +e
90
+ test_scala_library_expect_failure_on_missing_direct_external_deps () {
91
+ dependenecy_target=' @com_google_guava_guava_21_0//jar:file'
92
+ test_target=' test_expect_failure/missing_direct_deps/external_deps:transitive_external_dependency_user'
90
93
91
- expected_message=" Target '//test_expect_failure/missing_direct_deps/internal_deps:transitive_dependency' is used but isn't explicitly declared, please add it to the deps"
92
- command=' bazel build test_expect_failure/missing_direct_deps/internal_deps:transitive_dependency_user'
93
- output=$( $command 2>&1 )
94
- if [ $? -eq 0 ]; then
95
- echo " $output "
96
- echo " 'bazel build of scala_library with missing direct deps should have failed."
97
- exit 1
98
- fi
99
- echo " $output "
100
- echo $output | grep " $expected_message "
101
- if [ $? -ne 0 ]; then
102
- echo " 'bazel build test_expect_failure/missing_direct_deps/internal_deps:transitive_dependency_user' should have logged \" $expected_message \" ."
103
- exit 1
104
- fi
94
+ test_scala_library_expect_failure_on_missing_direct_deps $dependenecy_target $test_target
95
+ }
105
96
106
- set -e
107
- exit 0
97
+ test_scala_library_expect_failure_on_missing_direct_internal_deps () {
98
+ dependenecy_target=' //test_expect_failure/missing_direct_deps/internal_deps:transitive_dependency'
99
+ test_target=' test_expect_failure/missing_direct_deps/internal_deps:transitive_dependency_user'
100
+
101
+ test_scala_library_expect_failure_on_missing_direct_deps $dependenecy_target $test_target
108
102
}
109
103
110
104
test_scala_junit_test_can_fail () {
0 commit comments