Skip to content

Commit b3465e3

Browse files
jsonnet_to_json_test support for ext_str_files and ext_code_files that are generated (#160)
1 parent bd79290 commit b3465e3

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

examples/BUILD

+11
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,17 @@ jsonnet_to_json_test(
9999
},
100100
)
101101

102+
jsonnet_to_json_test(
103+
name = "extvar_files_generated_test",
104+
size = "small",
105+
src = "extvar_files_generated.jsonnet",
106+
ext_code_file_vars = ["codefile"],
107+
ext_code_files = [":generated.jsonnet"],
108+
ext_str_file_vars = ["test"],
109+
ext_str_files = [":generated.jsonnet"],
110+
golden = "extvar_files_generated_golden.json",
111+
)
112+
102113
jsonnet_to_json_test(
103114
name = "extvar_files_test",
104115
size = "small",
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
local test = std.extVar("test");
2+
local codefile = std.extVar("codefile");
3+
4+
{
5+
file1: test,
6+
file2: codefile,
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"file1": "{}\n",
3+
"file2": {}
4+
}

jsonnet/jsonnet.bzl

+2-2
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,9 @@ def _jsonnet_to_json_test_impl(ctx):
379379
["--ext-code %s" %
380380
ext_code_env for ext_code_env in jsonnet_ext_code_envs] +
381381
["--ext-str-file %s=%s" %
382-
(var, jfile.path) for var, jfile in zip(jsonnet_ext_str_file_vars, jsonnet_ext_str_files)] +
382+
(var, jfile.short_path) for var, jfile in zip(jsonnet_ext_str_file_vars, jsonnet_ext_str_files)] +
383383
["--ext-code-file %s=%s" %
384-
(var, jfile.path) for var, jfile in zip(jsonnet_ext_code_file_vars, jsonnet_ext_code_files)] +
384+
(var, jfile.short_path) for var, jfile in zip(jsonnet_ext_code_file_vars, jsonnet_ext_code_files)] +
385385
["--tla-str %s=%s" %
386386
(_quote(key), _quote(val)) for key, val in jsonnet_tla_strs.items()] +
387387
["--tla-str '%s'" %

0 commit comments

Comments
 (0)