Make Rake auto-generate test/unit/temp directory if it is missing.
This commit is contained in:
parent
ae24df95ba
commit
ba6934ed87
5
Rakefile
5
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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue