Skip to content

Commit b7e3743

Browse files
authored
Merge pull request mruby#6762 from mruby/fix-test-build-race
2 parents 805e6db + e8c5e7c commit b7e3743

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

mrbgems/mruby-test/mrbgem.rake

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ MRuby::Gem::Specification.new('mruby-test') do |spec|
1919
file assert_c => [assert_rb, build.mrbcfile] do |t|
2020
_pp "GEN", t.name.relative_path
2121
mkdir_p File.dirname(t.name)
22-
open(t.name, 'w') do |f|
22+
tmpfile = t.name + ".tmp"
23+
open(tmpfile, 'w') do |f|
2324
mrbc.run f, assert_rb, 'mrbtest_assert_irep', cdump: false
2425
end
26+
File.rename(tmpfile, t.name)
2527
end
2628

2729
gem_table = build.gems.generate_gem_table build
@@ -36,7 +38,8 @@ MRuby::Gem::Specification.new('mruby-test') do |spec|
3638
file g.test_rbireps => [g.test_rbfiles, build.mrbcfile].flatten do |t|
3739
_pp "GEN", t.name.relative_path
3840
mkdir_p File.dirname(t.name)
39-
open(t.name, 'w') do |f|
41+
tmpfile = t.name + ".tmp"
42+
open(tmpfile, 'w') do |f|
4043
g.print_gem_test_header(f)
4144
test_preload = g.test_preload and [g.dir, MRUBY_ROOT].map {|dir|
4245
File.expand_path(g.test_preload, dir)
@@ -117,6 +120,7 @@ MRuby::Gem::Specification.new('mruby-test') do |spec|
117120
end
118121
f.puts %Q[}]
119122
end
123+
File.rename(tmpfile, t.name)
120124
end
121125
end
122126

@@ -134,7 +138,8 @@ MRuby::Gem::Specification.new('mruby-test') do |spec|
134138
file clib => ["#{build.build_dir}/mrbgems/active_gems.txt", build.mrbcfile, __FILE__] do |_t|
135139
_pp "GEN", clib.relative_path
136140
mkdir_p File.dirname(clib)
137-
open(clib, 'w') do |f|
141+
tmpfile = clib + ".tmp"
142+
open(tmpfile, 'w') do |f|
138143
f.puts %Q[/*]
139144
f.puts %Q[ * This file contains a list of all]
140145
f.puts %Q[ * test functions.]
@@ -169,5 +174,6 @@ MRuby::Gem::Specification.new('mruby-test') do |spec|
169174
end
170175
f.puts %Q[}]
171176
end
177+
File.rename(tmpfile, clib)
172178
end
173179
end

0 commit comments

Comments
 (0)