Skip to content

Commit eb68d14

Browse files
committed
Introduce TIMEOUT_SEC on test
1 parent fdd041a commit eb68d14

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ jobs:
7272
- run: bundle install --jobs 4 --retry 3 --without "nmatrix python"
7373

7474
- run: bundle exec rake
75+
env:
76+
TIMEOUT_SEC: 180
7577

7678
- run: rake build
7779

.github/workflows/nmatrix.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ jobs:
6565
- run: bundle install --jobs 4 --retry 3 --without "numo python"
6666

6767
- run: bundle exec rake
68+
env:
69+
TIMEOUT_SEC: 180
6870

6971
- run: rake build
7072

.github/workflows/pycall.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,5 @@ jobs:
8686
- run: bundle exec rake
8787
env:
8888
PYTHON: python
89+
TIMEOUT_SEC: 180
8990
continue-on-error: ${{ matrix.python == '2.x' }}

test/run.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# $VERBOSE = true
55

66
require "pathname"
7+
require "timeout"
78

89
base_dir = Pathname(__dir__).parent.expand_path
910

@@ -16,4 +17,11 @@
1617

1718
require_relative "helper"
1819

19-
exit(Test::Unit::AutoRunner.run(true, test_dir.to_s))
20+
run_test = lambda { Test::Unit::AutoRunner.run(true, test_dir.to_s) }
21+
timeout_sec = ENV.fetch("TIMEOUT_SEC", "0").to_i
22+
status = if timeout_sec > 0
23+
Timeout.timeout(timeout_sec) { run_test.() }
24+
else
25+
run_test.()
26+
end
27+
exit(status)

0 commit comments

Comments
 (0)