Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

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)

trunk version of the patch

  • actionpack/test/template/compiled_templates_test.rb

    old new  
    1313  end 
    1414  def teardown 
    1515    [@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) 
    1717    end 
    1818  end 
    1919  attr_reader :ct, :v 
     
    2222    hi_world = ct.method_names['hi world'] 
    2323    hi_sexy = ct.method_names['hi sexy'] 
    2424    wish_upon_a_star = ct.method_names['I love seeing decent error messages'] 
    25      
     25 
    2626    assert_equal hi_world, ct.method_names['hi world'] 
    2727    assert_equal hi_sexy, ct.method_names['hi sexy'] 
    2828    assert_equal wish_upon_a_star, ct.method_names['I love seeing decent error messages'] 
     
    7171  def test_compile_time 
    7272    t = Time.now 
    7373    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 
    7579 
    7680    v = ActionView::Base.new 
    7781    v.base_path = '.' 
    78     v.cache_template_loading = false; 
     82    v.cache_template_loading = false 
    7983 
    8084    # private methods template_changed_since? and compile_template? 
    8185    # should report true for all since they have not been compiled 
    8286    assert v.send(:template_changed_since?, @a, t) 
    8387    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 
    8589    assert v.send(:compile_template?, nil, @a, {}) 
    8690    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 
    8892 
    8993    sleep 1 
    9094    v.compile_and_render_template(:rhtml, '', @a) 
     
    9296    v.compile_and_render_template(:rhtml, '', @s) 
    9397    a_n = v.method_names[@a] 
    9498    b_n = v.method_names[@b] 
    95     s_n = v.method_names[@s] 
     99    s_n = v.method_names[@s] unless windows 
    96100    # all of the files have changed since last compile 
    97101    assert v.compile_time[a_n] > t 
    98102    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 
    100104 
    101105    sleep 1 
    102106    t = Time.now 
     
    104108    # should report false for all since none have changed since compile 
    105109    assert !v.send(:template_changed_since?, @a, v.compile_time[a_n]) 
    106110    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 
    108112    assert !v.send(:compile_template?, nil, @a, {}) 
    109113    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 
    111115    v.compile_and_render_template(:rhtml, '', @a) 
    112116    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 
    114118    # none of the files have changed since last compile 
    115119    assert v.compile_time[a_n] < t 
    116120    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 
    118122 
    119     `rm #{@s}; ln -s #{@b} #{@s}` 
     123    `rm #{@s}; ln -s #{@b} #{@s}` unless windows 
    120124    # private methods template_changed_since? and compile_template? 
    121125    # should report true for symlink since it has changed since compile 
    122126    assert !v.send(:template_changed_since?, @a, v.compile_time[a_n]) 
    123127    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 
    125129    assert !v.send(:compile_template?, nil, @a, {}) 
    126130    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 
    128132    v.compile_and_render_template(:rhtml, '', @a) 
    129133    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 
    131135    # the symlink has changed since last compile 
    132136    assert v.compile_time[a_n] < t 
    133137    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 
    135139 
    136140    sleep 1 
    137     `touch #{@b}` 
     141    FileUtils.touch @b 
    138142    # private methods template_changed_since? and compile_template? 
    139143    # should report true for symlink and file at end of symlink 
    140144    # since it has changed since last compile 
    141145    assert !v.send(:template_changed_since?, @a, v.compile_time[a_n]) 
    142146    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 
    144148    assert !v.send(:compile_template?, nil, @a, {}) 
    145149    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 
    147152    t = Time.now 
     153    sleep 1 
    148154    v.compile_and_render_template(:rhtml, '', @a) 
    149155    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 
    151157    # the file at the end of the symlink has changed since last compile 
    152158    # both the symlink and the file at the end of it should be recompiled 
    153159    assert v.compile_time[a_n] < t 
    154160    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 
    156162  end 
    157163end 
    158164