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