Skip to content

Commit 8a19cca

Browse files
committed
Run test files prior to pushing changes to remote repo
1 parent 2457053 commit 8a19cca

1 file changed

Lines changed: 11 additions & 17 deletions

File tree

tools/git/hooks/pre-push

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,6 @@ check_licenses() {
7474
return 0
7575
}
7676

77-
# Runs tests.
78-
run_tests() {
79-
echo 'Running tests...' >&2
80-
make test > /dev/null 2>&1
81-
if [[ "$?" -ne 0 ]]; then
82-
echo 'Tests failed. Run `make test` to see the failing tests.' >&2
83-
return 1
84-
fi
85-
echo 'Tests passed.' >&2
86-
return 0
87-
}
88-
8977
# Main execution sequence.
9078
main() {
9179
local changed_files
@@ -213,11 +201,17 @@ main() {
213201
fi
214202
fi
215203

216-
# FIXME: re-enable once we have written tooling to support running only those tests involving affected packages.
217-
# run_tests
218-
# if [[ "$?" -ne 0 ]]; then
219-
# on_error 1
220-
# fi
204+
# Run JavaScript test files...
205+
files=$(echo "${changed_files}" | grep '/test/.*\.js$' | tr '\n' ' ')
206+
if [[ -n "${files}" ]]; then
207+
echo 'Running JavaScript test files...' >&2
208+
make FILES="${files}" test-javascript-files > /dev/null >&2
209+
if [[ "$?" -ne 0 ]]; then
210+
echo '' >&2
211+
echo 'Encountered an error when running JavaScript tests.' >&2
212+
on_error 1
213+
fi
214+
fi
221215

222216
cleanup
223217
exit 0

0 commit comments

Comments
 (0)