Skip to content

Commit

Permalink
Use per exercise process timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
mk-mxp committed Apr 21, 2024
1 parent f2b7401 commit 14b31f4
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions bin/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,17 @@ function test {
cp "${exercise_dir}/.meta/${example_file}" "${outdir}/${exercise_file}.${file_ext}"
fi

# The time-limit `18` is based on an approximation of the performance.
# The time-limit `54` is based on an approximation of the performance.
# Online Test Runner is appr. 3x faster than GitHub CI on Ubuntu.
#
# The total runtime limit of the Online Test Runner is 20 seconds including
# Docker container launch and processing the results. That leaves appr. 18
# seconds for all tests of an exercise. But that's not the `18` here.
# seconds for all tests of an exercise.
#
# The longest running exercise tests in CI are in `alphametics`. It has 3 slow
# test cases (9 letters and 10 letters) that require appr. 15 secs each in CI
# and appr. 5 seconds each in the Online Test Runner.
#
# Putting that together gives a max. of 6 seconds for each of the slow test
# cases in the Online Test Runner before hitting the timeout in production
# -> use 3x 6secs = 18 seconds as a CI limit to ensure tests can actually
# be run in production.
# Putting that together gives a max. of 18 seconds x3 = 54 seconds for any
# test class in CI.
# See: https://forum.exercism.org/t/test-tracks-for-the-20-seconds-limit-on-test-runners/10536/8
eval "${PHPUNIT_BIN}" --default-time-limit 18 --enforce-time-limit --fail-on-risky --no-configuration "${outdir}/${test_file}"
timeout 54s eval "${PHPUNIT_BIN}" --no-configuration "${outdir}/${test_file}"
}

function installed {
Expand Down

0 comments on commit 14b31f4

Please sign in to comment.