Skip to content

Commit 98c66ee

Browse files
committed
Move more main logic into functions
1 parent d475626 commit 98c66ee

File tree

1 file changed

+45
-35
lines changed

1 file changed

+45
-35
lines changed

syntax-tests.sh

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -137,42 +137,22 @@ SYNTAX
137137
done
138138
}
139139

140-
# TODO cache $folder/syntax_test if not latest or stable
141-
build="$(resolve_build)"
142-
echo "::group::Fetching binary (build $build)"
143-
get_url "$build" | fetch_binary
144-
echo '::endgroup::'
145-
146-
# TODO cache $packages based on $INPUT_DEFAULT_PACKAGES not in (master, st3, binary) (or resolve ref to hash)
147-
fetch_default_packages "$build"
148-
149-
link_package
150-
151-
link_additional_packages
152-
153-
create_dummy_syntaxes
154-
155-
echo "::group::Checking syntax test filenames"
156-
for path in $(find . -iname syntax_test*); do
157-
file="${path/$packages\/$INPUT_PACKAGE_NAME/$INPUT_PACKAGE_ROOT}"
158-
if echo "$file" | grep -v '/syntax_test_'; then
159-
echo "::warning file=$file::Syntax test filenames must begin with 'syntax_test_'"
160-
fi
161-
if head -n 1 "$path" | grep -vEq '.+\bSYNTAX TEST\b.+".+\.(sublime-syntax|tmLanguage)"'; then
162-
echo "::warning file=$file::Syntax test file format at https://www.sublimetext.com/docs/syntax.html#testing"
163-
fi
164-
done
165-
echo '::endgroup::'
166-
167-
# TODO There seems to be some add-matcher workflow command.
168-
# We could generate/adjust that to only catch files
169-
# in the installed package,
170-
# but we may not be able to rewrite the original root path.
171-
# https://github.com/rbialon/flake8-annotations/blob/master/index.js
172-
echo 'Running binary'
140+
check_syntax_test_filenames() {
141+
echo "::group::Checking syntax test filenames"
142+
for path in $(find . -iname syntax_test*); do
143+
file="${path/$packages\/$INPUT_PACKAGE_NAME/$INPUT_PACKAGE_ROOT}"
144+
if echo "$file" | grep -v '/syntax_test_'; then
145+
echo "::warning file=$file::Syntax test filenames must begin with 'syntax_test_'"
146+
fi
147+
if head -n 1 "$path" | grep -vEq '.+\bSYNTAX TEST\b.+".+\.(sublime-syntax|tmLanguage)"'; then
148+
echo "::warning file=$file::Syntax test file format at https://www.sublimetext.com/docs/syntax.html#testing"
149+
fi
150+
done
151+
echo '::endgroup::'
152+
}
173153

174-
"$folder/syntax_tests" \
175-
| while IFS='' read -r line; do
154+
parse_test_results() {
155+
while IFS='' read -r line; do
176156
echo "$line"
177157
### Before 4181
178158
# /home/runner/work/syntax-test-action/syntax_tests/Data/Packages/syntax-test-action/test/defpkg/syntax_test_test:7:1: [source.python constant.language] does not match scope [text.test]
@@ -195,3 +175,33 @@ echo 'Running binary'
195175
echo "::${logtype:-error} file=$file,line=$row,col=$col::${message# }"
196176
fi
197177
done
178+
}
179+
180+
###############################################################################
181+
###############################################################################
182+
###############################################################################
183+
184+
# TODO cache $folder/syntax_test if not latest or stable
185+
build="$(resolve_build)"
186+
echo "::group::Fetching binary (build $build)"
187+
get_url "$build" | fetch_binary
188+
echo '::endgroup::'
189+
190+
# TODO cache $packages based on $INPUT_DEFAULT_PACKAGES not in (master, st3, binary) (or resolve ref to hash)
191+
fetch_default_packages "$build"
192+
193+
link_package
194+
195+
link_additional_packages
196+
197+
create_dummy_syntaxes
198+
199+
check_syntax_test_filenames
200+
201+
# TODO There seems to be some add-matcher workflow command.
202+
# We could generate/adjust that to only catch files
203+
# in the installed package,
204+
# but we may not be able to rewrite the original root path.
205+
# https://github.com/rbialon/flake8-annotations/blob/master/index.js
206+
echo 'Running binary'
207+
"$folder/syntax_tests" | parse_test_results

0 commit comments

Comments
 (0)