Skip to content

Commit

Permalink
Introduce TIMEOUT_SEC on test
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkn committed May 31, 2024
1 parent fdd041a commit eb68d14
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ jobs:
- run: bundle install --jobs 4 --retry 3 --without "nmatrix python"

- run: bundle exec rake
env:
TIMEOUT_SEC: 180

- run: rake build

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/nmatrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ jobs:
- run: bundle install --jobs 4 --retry 3 --without "numo python"

- run: bundle exec rake
env:
TIMEOUT_SEC: 180

- run: rake build

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pycall.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@ jobs:
- run: bundle exec rake
env:
PYTHON: python
TIMEOUT_SEC: 180
continue-on-error: ${{ matrix.python == '2.x' }}
10 changes: 9 additions & 1 deletion test/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# $VERBOSE = true

require "pathname"
require "timeout"

base_dir = Pathname(__dir__).parent.expand_path

Expand All @@ -16,4 +17,11 @@

require_relative "helper"

exit(Test::Unit::AutoRunner.run(true, test_dir.to_s))
run_test = lambda { Test::Unit::AutoRunner.run(true, test_dir.to_s) }
timeout_sec = ENV.fetch("TIMEOUT_SEC", "0").to_i
status = if timeout_sec > 0
Timeout.timeout(timeout_sec) { run_test.() }
else
run_test.()
end
exit(status)

0 comments on commit eb68d14

Please sign in to comment.