diff --git a/lib/private/yq.bzl b/lib/private/yq.bzl index 784fc23..29ca3d7 100644 --- a/lib/private/yq.bzl +++ b/lib/private/yq.bzl @@ -4,7 +4,7 @@ load("//lib:stamping.bzl", "STAMP_ATTRS", "maybe_stamp") _yq_attrs = dict({ "srcs": attr.label_list( - allow_files = [".yaml", ".json", ".xml"], + allow_files = True, mandatory = True, allow_empty = True, ), diff --git a/lib/tests/yq/BUILD.bazel b/lib/tests/yq/BUILD.bazel index ee99c1a..30a5a5c 100644 --- a/lib/tests/yq/BUILD.bazel +++ b/lib/tests/yq/BUILD.bazel @@ -1,6 +1,7 @@ load("//lib/private:diff_test.bzl", "diff_test") load("//lib:yq.bzl", "yq") load("//lib:testing.bzl", "assert_contains") +load("//lib:copy_file.bzl", "copy_file") exports_files( [ @@ -9,6 +10,18 @@ exports_files( visibility = ["//visibility:public"], ) +copy_file( + name = "yaml_otherextension", + src = "a.yaml", + out = "a.whatever", +) + +copy_file( + name = "json_otherextension", + src = "//lib/tests/jq:a_pretty.json", + out = "a.dealerschoice", +) + # Identity (dot) expression produces identical yaml yq( name = "case_dot_expression", @@ -22,6 +35,18 @@ diff_test( file2 = ":case_dot_expression", ) +yq( + name = "case_dot_expression_otherextension", + srcs = ["a.whatever"], + expression = ".", +) + +diff_test( + name = "case_dot_expression_otherextension_test", + file1 = "a.whatever", + file2 = ":case_dot_expression_otherextension", +) + # No expression same as dot expression yq( name = "case_no_expression", @@ -34,6 +59,17 @@ diff_test( file2 = ":case_no_expression", ) +yq( + name = "case_no_expression_otherextension", + srcs = ["a.whatever"], +) + +diff_test( + name = "case_no_expression_otherextension_test", + file1 = "a.whatever", + file2 = ":case_no_expression", +) + # Output json, no out declared yq( name = "case_json_output_no_out", @@ -48,6 +84,19 @@ diff_test( file2 = "case_json_output_no_out.json", ) +yq( + name = "case_json_output_no_out_otherextension", + srcs = ["a.whatever"], + args = ["-o=json"], + expression = ".", +) + +diff_test( + name = "case_json_output_no_out_otherextension_test", + file1 = "//lib/tests/jq:a_pretty.json", + file2 = "case_json_output_no_out.json", +) + # Output json, outs has ".json" extension but "-o=json" not set yq( name = "case_json_output_no_arg", @@ -77,6 +126,19 @@ diff_test( file2 = ":case_convert_json_to_yaml", ) +yq( + name = "case_convert_json_to_yaml_otherextension", + srcs = ["a.dealerschoice"], + args = ["-P"], + expression = ".", +) + +diff_test( + name = "case_convert_json_to_yaml_otherextension_test", + file1 = "a.yaml", + file2 = ":case_convert_json_to_yaml", +) + # No srcs, output is a generated expression yq( name = "case_generate_from_expression",