From ba6934ed87abbce10031842c861372e6574e7b41 Mon Sep 17 00:00:00 2001 From: Tobie Langel Date: Wed, 23 Apr 2008 12:05:30 +0200 Subject: [PATCH] Make Rake auto-generate test/unit/temp directory if it is missing. --- Rakefile | 5 ++++- test/lib/jstest.rb | 9 +++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Rakefile b/Rakefile index c98fa8e..50da90e 100644 --- a/Rakefile +++ b/Rakefile @@ -54,16 +54,19 @@ JavaScriptTestTask.new(:test_units) do |t| testcases = ENV['TESTCASES'] tests_to_run = ENV['TESTS'] && ENV['TESTS'].split(',') browsers_to_test = ENV['BROWSERS'] && ENV['BROWSERS'].split(',') + tmp_dir = "test/unit/tmp" t.mount("/dist") t.mount("/test") + Dir.mkdir(tmp_dir) unless File.exist?(tmp_dir) + Dir["test/unit/*_test.js"].each do |file| TestBuilder.new(file).render test_file = File.basename(file, ".js") test_name = test_file.sub("_test", "") unless tests_to_run && !tests_to_run.include?(test_name) - t.run("/test/unit/tmp/#{test_file}.html", testcases) + t.run("/#{tmp_dir}/#{test_file}.html", testcases) end end diff --git a/test/lib/jstest.rb b/test/lib/jstest.rb index c0ff155..85df342 100644 --- a/test/lib/jstest.rb +++ b/test/lib/jstest.rb @@ -429,9 +429,10 @@ class TestSuiteResults end class TestBuilder - UNITTEST_DIR = File.expand_path('test') - TEMPLATE = File.join(UNITTEST_DIR, 'lib', 'template.erb') - FIXTURES_DIR = File.join(UNITTEST_DIR, 'unit', 'fixtures') + UNITTEST_DIR = File.expand_path('test') + FIXTURES_DIR = File.join(UNITTEST_DIR, 'unit', 'fixtures') + TMP_DIR = File.join(UNITTEST_DIR, 'unit', 'tmp') + TEMPLATE = File.join(UNITTEST_DIR, 'lib', 'template.erb') def initialize(filename, template = TEMPLATE) @filename = filename @@ -465,6 +466,6 @@ class TestBuilder def destination filename = File.basename(@filename, ".js") - File.join(UNITTEST_DIR, 'unit', 'tmp', "#{filename}.html") + File.join(TMP_DIR, "#{filename}.html") end end