@@ -668,7 +668,7 @@ genquery(name='q',
668
668
opts = ["--output=blargh"],)
669
669
EOF
670
670
671
- local expected_error_msg=" in genquery rule //starfruit:q: Invalid output format 'blargh'. Valid values are: label, label_kind, build, minrank, maxrank, package, location, graph, jsonproto, xml, proto"
671
+ local expected_error_msg=" in genquery rule //starfruit:q: Invalid output format 'blargh'. Valid values are: label, label_kind, build, minrank, maxrank, package, location, graph, xml, proto, streamed_jsonproto, "
672
672
bazel build //starfruit:q >& $TEST_log && fail " Expected failure"
673
673
expect_log " $expected_error_msg "
674
674
}
@@ -1098,7 +1098,7 @@ EOF
1098
1098
expect_log " //pkg3:t4"
1099
1099
}
1100
1100
1101
- function test_basic_query_jsonproto () {
1101
+ function test_basic_query_streamed_jsonproto () {
1102
1102
local pkg=" ${FUNCNAME[0]} "
1103
1103
mkdir -p " $pkg " || fail " mkdir -p $pkg "
1104
1104
cat > " $pkg /BUILD" << 'EOF '
@@ -1108,17 +1108,39 @@ genrule(
1108
1108
outs = ["bar_out.txt"],
1109
1109
cmd = "echo unused > $(OUTS)",
1110
1110
)
1111
+ genrule(
1112
+ name = "foo",
1113
+ srcs = ["dummy.txt"],
1114
+ outs = ["foo_out.txt"],
1115
+ cmd = "echo unused > $(OUTS)",
1116
+ )
1111
1117
EOF
1112
- bazel query --output=jsonproto --noimplicit_deps " //$pkg :bar " > output 2> " $TEST_log " \
1118
+ bazel query --output=streamed_jsonproto --noimplicit_deps " //$pkg /... " > output 2> " $TEST_log " \
1113
1119
|| fail " Expected success"
1114
1120
cat output >> " $TEST_log "
1115
1121
1116
1122
# Verify that the appropriate attributes were included.
1117
- assert_contains " \" ruleClass\" : \" genrule\" " output
1118
- assert_contains " \" name\" : \" //$pkg :bar\" " output
1119
- assert_contains " \" ruleInput\" : \[\" //$pkg :dummy.txt\" \]" output
1120
- assert_contains " \" ruleOutput\" : \[\" //$pkg :bar_out.txt\" \]" output
1121
- assert_contains " echo unused" output
1123
+
1124
+ foo_line_number=$( grep -n " foo" output | cut -d' :' -f1)
1125
+ bar_line_number=$( grep -n " bar" output | cut -d' :' -f1)
1126
+
1127
+ foo_ndjson_line=$( sed -n " ${foo_line_number} p" output)
1128
+ bar_ndjson_line=$( sed -n " ${bar_line_number} p" output)
1129
+
1130
+ echo " $foo_ndjson_line " > foo_ndjson_file
1131
+ echo " $bar_ndjson_line " > bar_ndjson_file
1132
+
1133
+ assert_contains " \" ruleClass\" :\" genrule\" " foo_ndjson_file
1134
+ assert_contains " \" name\" :\" //$pkg :foo\" " foo_ndjson_file
1135
+ assert_contains " \" ruleInput\" :\[\" //$pkg :dummy.txt\" \]" foo_ndjson_file
1136
+ assert_contains " \" ruleOutput\" :\[\" //$pkg :foo_out.txt\" \]" foo_ndjson_file
1137
+ assert_contains " echo unused" foo_ndjson_file
1138
+
1139
+ assert_contains " \" ruleClass\" :\" genrule\" " bar_ndjson_file
1140
+ assert_contains " \" name\" :\" //$pkg :bar\" " bar_ndjson_file
1141
+ assert_contains " \" ruleInput\" :\[\" //$pkg :dummy.txt\" \]" bar_ndjson_file
1142
+ assert_contains " \" ruleOutput\" :\[\" //$pkg :bar_out.txt\" \]" bar_ndjson_file
1143
+ assert_contains " echo unused" bar_ndjson_file
1122
1144
}
1123
1145
1124
1146
run_suite " ${PRODUCT_NAME} query tests"
0 commit comments