Skip to content

Commit 94cd457

Browse files
committed
test: add case for variables with whitespace
1 parent e07a85a commit 94cd457

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,27 @@ jobs:
3131
- name: '[test] many variables'
3232
run: diff test/many-variables/result test/many-variables/expected
3333

34-
- name: '[run] many variables (messy whitespace)'
34+
- name: '[run] many variables declared with messy whitespace'
3535
uses: ./
3636
with:
3737
template: test/many-variables/template
3838
output_file: test/many-variables/result
3939
variables: |
40-
foo=bar
41-
baz=cux
40+
foo=bar
41+
baz=cux
4242
4343
4444
45-
- name: '[test] many variables (messy whitespace)'
46-
run: diff test/many-variables/result test/many-variables/expected
45+
- name: '[test] many variables declared with messy whitespace'
46+
run: diff test/many-variables/result test/many-variables/expected
47+
48+
- name: '[run] many variables with messy whitespace'
49+
uses: ./
50+
with:
51+
template: test/whitespace/template
52+
output_file: test/whitespace/result
53+
variables: |
54+
foo=this variable has whitespace but it only takes one line
55+
bar= \nthis\nvariable\nhas\nmany\n \nlines\n and trailing whitespace
56+
- name: '[test] many variables with messy whitespace'
57+
run: diff test/whitespace/result test/whitespace/expected

entrypoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
params = [os.environ['INPUT_TEMPLATE']]
88

99
for variable in os.environ.get('INPUT_VARIABLES', '').split('\n'):
10-
clean_variable = variable.strip()
10+
clean_variable = bytes(variable.strip(), 'utf-8').decode('unicode_escape')
1111
if clean_variable != '':
1212
params.extend(['-D', clean_variable])
1313

test/whitespace/expected

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
this variable has whitespace but it only takes one line
3+
4+
this
5+
variable
6+
has
7+
many
8+
9+
lines
10+
and trailing whitespace

test/whitespace/template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
{{ foo }}
3+
{{ bar }}

0 commit comments

Comments
 (0)