зеркало из https://github.com/github/ruby.git
Omit TestFile#test_stat when the machine is stupidly slow
GitHub Actions macos-14 machine is stupid. https://app.launchableinc.com/organizations/ruby/workspaces/ruby/data/test-paths/file%3Dtest%2Fruby%2Ftest_file.rb%23%23%23class%3DTestFile%23%23%23testcase%3Dtest_stat?organizationId=ruby&workspaceId=ruby&testPathId=file%3Dtest%2Fruby%2Ftest_file.rb%23%23%23class%3DTestFile%23%23%23testcase%3Dtest_stat&testSessionStatus=flake
This commit is contained in:
Родитель
357ae357e8
Коммит
5f6a1c2e22
|
@ -358,6 +358,19 @@ class TestFile < Test::Unit::TestCase
|
|||
assert_equal(mod_time_contents, stats.mtime, bug6385)
|
||||
end
|
||||
|
||||
def measure_time
|
||||
log = []
|
||||
30.times do
|
||||
t1 = Process.clock_gettime(Process::CLOCK_REALTIME)
|
||||
yield
|
||||
t2 = Process.clock_gettime(Process::CLOCK_REALTIME)
|
||||
log << (t2 - t1)
|
||||
return (t1 + t2) / 2 if t2 - t1 < 1
|
||||
sleep 1
|
||||
end
|
||||
omit "failed to setup; the machine is stupidly slow #{log.inspect}"
|
||||
end
|
||||
|
||||
def test_stat
|
||||
tb = Process.clock_gettime(Process::CLOCK_REALTIME)
|
||||
Tempfile.create("stat") {|file|
|
||||
|
@ -365,26 +378,27 @@ class TestFile < Test::Unit::TestCase
|
|||
file.close
|
||||
path = file.path
|
||||
|
||||
retry_count = 0
|
||||
while true
|
||||
t0 = Process.clock_gettime(Process::CLOCK_REALTIME)
|
||||
t0 = measure_time do
|
||||
File.write(path, "foo")
|
||||
sleep 2
|
||||
t1 = Process.clock_gettime(Process::CLOCK_REALTIME)
|
||||
end
|
||||
|
||||
sleep 2
|
||||
|
||||
t1 = measure_time do
|
||||
File.write(path, "bar")
|
||||
sleep 2
|
||||
t2 = Process.clock_gettime(Process::CLOCK_REALTIME)
|
||||
end
|
||||
|
||||
sleep 2
|
||||
|
||||
t2 = measure_time do
|
||||
File.read(path)
|
||||
File.chmod(0644, path)
|
||||
sleep 2
|
||||
t3 = Process.clock_gettime(Process::CLOCK_REALTIME)
|
||||
end
|
||||
|
||||
sleep 2
|
||||
|
||||
t3 = measure_time do
|
||||
File.read(path)
|
||||
|
||||
t4 = Process.clock_gettime(Process::CLOCK_REALTIME)
|
||||
break if t4 - t0 < 6.5
|
||||
|
||||
retry_count += 1
|
||||
raise "failed to setup; the machine is too slow? #{t0} #{t1} #{t2} #{t3} #{t4}" if retry_count > 3
|
||||
end
|
||||
|
||||
delta = 1
|
||||
|
|
Загрузка…
Ссылка в новой задаче