Ticket #8234: fix_broken_compiled_template_test.patch
| File fix_broken_compiled_template_test.patch, 3.2 kB (added by skaes, 2 years ago) |
|---|
-
actionpack/test/template/compiled_templates_test.rb
old new 71 71 end 72 72 73 73 def test_compile_time 74 `echo '#{@a}' > #{@a}; echo '#{@b}' > #{@b}; ln -s #{@a} #{@s}` 74 File.open(@a, "w"){|f| f.puts @a} 75 File.open(@b, "w"){|f| f.puts @b} 76 77 # windows doesn't support symlinks (even under cygwin) 78 windows = (RUBY_PLATFORM =~ /win32/) 79 `ln -s #{@a} #{@s}` unless windows 75 80 76 81 v = ActionView::Base.new 77 82 v.base_path = '.' … … 79 84 80 85 sleep 1 81 86 t = Time.now 87 sleep 1 88 82 89 v.compile_and_render_template(:rhtml, '', @a) 83 90 v.compile_and_render_template(:rhtml, '', @b) 84 v.compile_and_render_template(:rhtml, '', @s) 91 v.compile_and_render_template(:rhtml, '', @s) unless windows 92 85 93 a_n = v.method_names[@a] 86 94 b_n = v.method_names[@b] 87 s_n = v.method_names[@s] 95 s_n = v.method_names[@s] unless windows 96 ct_a = v.compile_time[a_n] 97 ct_b = v.compile_time[b_n] 98 ct_s = v.compile_time[s_n] unless windows 88 99 # all of the files have changed since last compile 89 100 assert v.compile_time[a_n] > t 90 101 assert v.compile_time[b_n] > t 91 assert v.compile_time[s_n] > t 102 assert v.compile_time[s_n] > t unless windows 92 103 93 104 sleep 1 94 t = Time.now95 105 v.compile_and_render_template(:rhtml, '', @a) 96 106 v.compile_and_render_template(:rhtml, '', @b) 97 v.compile_and_render_template(:rhtml, '', @s) 107 v.compile_and_render_template(:rhtml, '', @s) unless windows 98 108 # none of the files have changed since last compile 99 assert v.compile_time[a_n] < t 100 assert v.compile_time[b_n] < t 101 assert v.compile_time[s_n] < t 109 # so they should not have been recmpiled 110 assert_equal ct_a, v.compile_time[a_n] 111 assert_equal ct_b, v.compile_time[b_n] 112 assert_equal ct_s, v.compile_time[s_n] unless windows 102 113 103 `rm #{@s}; ln -s #{@b} #{@s}` 114 `rm #{@s}; ln -s #{@b} #{@s}` unless windows 104 115 v.compile_and_render_template(:rhtml, '', @a) 105 116 v.compile_and_render_template(:rhtml, '', @b) 106 v.compile_and_render_template(:rhtml, '', @s) 117 v.compile_and_render_template(:rhtml, '', @s) unless windows 107 118 # the symlink has changed since last compile 108 assert v.compile_time[a_n] < t109 assert v.compile_time[b_n] < t110 assert v.compile_time[s_n] > t 119 assert_equal ct_a, v.compile_time[a_n] 120 assert_equal ct_b, v.compile_time[b_n] 121 assert v.compile_time[s_n] > t unless windows 111 122 112 sleep 1 113 `touch #{@b}` 123 FileUtils.touch @b 114 124 t = Time.now 125 sleep 0.1 115 126 v.compile_and_render_template(:rhtml, '', @a) 116 127 v.compile_and_render_template(:rhtml, '', @b) 117 v.compile_and_render_template(:rhtml, '', @s) 128 v.compile_and_render_template(:rhtml, '', @s) unless windows 118 129 # the file at the end of the symlink has changed since last compile 119 130 # both the symlink and the file at the end of it should be recompiled 120 131 assert v.compile_time[a_n] < t 121 132 assert v.compile_time[b_n] > t 122 assert v.compile_time[s_n] > t 133 assert v.compile_time[s_n] > t unless windows 123 134 end 124 135 end 125 136