Ticket #8234: fix_broken_compiled_template_test.trunk.patch
| File fix_broken_compiled_template_test.trunk.patch, 5.9 kB (added by skaes, 2 years ago) |
|---|
-
actionpack/test/template/compiled_templates_test.rb
old new 13 13 end 14 14 def teardown 15 15 [@a, @b, @s].each do |f| 16 `rm #{f}`if File.exist?(f) || File.symlink?(f)16 FileUtils.rm(f) if File.exist?(f) || File.symlink?(f) 17 17 end 18 18 end 19 19 attr_reader :ct, :v … … 22 22 hi_world = ct.method_names['hi world'] 23 23 hi_sexy = ct.method_names['hi sexy'] 24 24 wish_upon_a_star = ct.method_names['I love seeing decent error messages'] 25 25 26 26 assert_equal hi_world, ct.method_names['hi world'] 27 27 assert_equal hi_sexy, ct.method_names['hi sexy'] 28 28 assert_equal wish_upon_a_star, ct.method_names['I love seeing decent error messages'] … … 71 71 def test_compile_time 72 72 t = Time.now 73 73 sleep 1 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 # windows doesn't support symlinks (even under cygwin) 77 windows = (RUBY_PLATFORM =~ /win32/) 78 `ln -s #{@a} #{@s}` unless windows 75 79 76 80 v = ActionView::Base.new 77 81 v.base_path = '.' 78 v.cache_template_loading = false ;82 v.cache_template_loading = false 79 83 80 84 # private methods template_changed_since? and compile_template? 81 85 # should report true for all since they have not been compiled 82 86 assert v.send(:template_changed_since?, @a, t) 83 87 assert v.send(:template_changed_since?, @b, t) 84 assert v.send(:template_changed_since?, @s, t) 88 assert v.send(:template_changed_since?, @s, t) unless windows 85 89 assert v.send(:compile_template?, nil, @a, {}) 86 90 assert v.send(:compile_template?, nil, @b, {}) 87 assert v.send(:compile_template?, nil, @s, {}) 91 assert v.send(:compile_template?, nil, @s, {}) unless windows 88 92 89 93 sleep 1 90 94 v.compile_and_render_template(:rhtml, '', @a) … … 92 96 v.compile_and_render_template(:rhtml, '', @s) 93 97 a_n = v.method_names[@a] 94 98 b_n = v.method_names[@b] 95 s_n = v.method_names[@s] 99 s_n = v.method_names[@s] unless windows 96 100 # all of the files have changed since last compile 97 101 assert v.compile_time[a_n] > t 98 102 assert v.compile_time[b_n] > t 99 assert v.compile_time[s_n] > t 103 assert v.compile_time[s_n] > t unless windows 100 104 101 105 sleep 1 102 106 t = Time.now … … 104 108 # should report false for all since none have changed since compile 105 109 assert !v.send(:template_changed_since?, @a, v.compile_time[a_n]) 106 110 assert !v.send(:template_changed_since?, @b, v.compile_time[b_n]) 107 assert !v.send(:template_changed_since?, @s, v.compile_time[s_n]) 111 assert !v.send(:template_changed_since?, @s, v.compile_time[s_n]) unless windows 108 112 assert !v.send(:compile_template?, nil, @a, {}) 109 113 assert !v.send(:compile_template?, nil, @b, {}) 110 assert !v.send(:compile_template?, nil, @s, {}) 114 assert !v.send(:compile_template?, nil, @s, {}) unless windows 111 115 v.compile_and_render_template(:rhtml, '', @a) 112 116 v.compile_and_render_template(:rhtml, '', @b) 113 v.compile_and_render_template(:rhtml, '', @s) 117 v.compile_and_render_template(:rhtml, '', @s) unless windows 114 118 # none of the files have changed since last compile 115 119 assert v.compile_time[a_n] < t 116 120 assert v.compile_time[b_n] < t 117 assert v.compile_time[s_n] < t 121 assert v.compile_time[s_n] < t unless windows 118 122 119 `rm #{@s}; ln -s #{@b} #{@s}` 123 `rm #{@s}; ln -s #{@b} #{@s}` unless windows 120 124 # private methods template_changed_since? and compile_template? 121 125 # should report true for symlink since it has changed since compile 122 126 assert !v.send(:template_changed_since?, @a, v.compile_time[a_n]) 123 127 assert !v.send(:template_changed_since?, @b, v.compile_time[b_n]) 124 assert v.send(:template_changed_since?, @s, v.compile_time[s_n]) 128 assert v.send(:template_changed_since?, @s, v.compile_time[s_n]) unless windows 125 129 assert !v.send(:compile_template?, nil, @a, {}) 126 130 assert !v.send(:compile_template?, nil, @b, {}) 127 assert v.send(:compile_template?, nil, @s, {}) 131 assert v.send(:compile_template?, nil, @s, {}) unless windows 128 132 v.compile_and_render_template(:rhtml, '', @a) 129 133 v.compile_and_render_template(:rhtml, '', @b) 130 v.compile_and_render_template(:rhtml, '', @s) 134 v.compile_and_render_template(:rhtml, '', @s) unless windows 131 135 # the symlink has changed since last compile 132 136 assert v.compile_time[a_n] < t 133 137 assert v.compile_time[b_n] < t 134 assert v.compile_time[s_n] > t 138 assert v.compile_time[s_n] > t unless windows 135 139 136 140 sleep 1 137 `touch #{@b}`141 FileUtils.touch @b 138 142 # private methods template_changed_since? and compile_template? 139 143 # should report true for symlink and file at end of symlink 140 144 # since it has changed since last compile 141 145 assert !v.send(:template_changed_since?, @a, v.compile_time[a_n]) 142 146 assert v.send(:template_changed_since?, @b, v.compile_time[b_n]) 143 assert v.send(:template_changed_since?, @s, v.compile_time[s_n]) 147 assert v.send(:template_changed_since?, @s, v.compile_time[s_n]) unless windows 144 148 assert !v.send(:compile_template?, nil, @a, {}) 145 149 assert v.send(:compile_template?, nil, @b, {}) 146 assert v.send(:compile_template?, nil, @s, {}) 150 assert v.send(:compile_template?, nil, @s, {}) unless windows 151 147 152 t = Time.now 153 sleep 1 148 154 v.compile_and_render_template(:rhtml, '', @a) 149 155 v.compile_and_render_template(:rhtml, '', @b) 150 v.compile_and_render_template(:rhtml, '', @s) 156 v.compile_and_render_template(:rhtml, '', @s) unless windows 151 157 # the file at the end of the symlink has changed since last compile 152 158 # both the symlink and the file at the end of it should be recompiled 153 159 assert v.compile_time[a_n] < t 154 160 assert v.compile_time[b_n] > t 155 assert v.compile_time[s_n] > t 161 assert v.compile_time[s_n] > t unless windows 156 162 end 157 163 end 158 164