Commit 76ae9800 by Will Daly

Clean the report directories before each test run,

to ensure we don't get coverage results from a
previous test run.
parent 34d1ea9e
...@@ -45,6 +45,11 @@ end ...@@ -45,6 +45,11 @@ end
directory REPORT_DIR directory REPORT_DIR
task :clean_test_files do task :clean_test_files do
# Delete all non-folder files in the reports directory
sh("find #{REPORT_DIR} -type f -print0 | xargs -0 rm")
# Reset the test fixtures
sh("git clean -fqdx test_root") sh("git clean -fqdx test_root")
end end
...@@ -81,12 +86,11 @@ TEST_TASK_DIRS = [] ...@@ -81,12 +86,11 @@ TEST_TASK_DIRS = []
end end
Dir["common/lib/*"].select{|lib| File.directory?(lib)}.each do |lib| Dir["common/lib/*"].select{|lib| File.directory?(lib)}.each do |lib|
task_name = "test_#{lib}"
report_dir = report_dir_path(lib) report_dir = report_dir_path(lib)
desc "Run tests for common lib #{lib}" desc "Run tests for common lib #{lib}"
task task_name => report_dir do task "test_#{lib}" => ["clean_test_files", report_dir] do
ENV['NOSE_XUNIT_FILE'] = File.join(report_dir, "nosetests.xml") ENV['NOSE_XUNIT_FILE'] = File.join(report_dir, "nosetests.xml")
cmd = "nosetests #{lib}" cmd = "nosetests #{lib}"
sh(run_under_coverage(cmd, lib)) do |ok, res| sh(run_under_coverage(cmd, lib)) do |ok, res|
...@@ -95,10 +99,13 @@ Dir["common/lib/*"].select{|lib| File.directory?(lib)}.each do |lib| ...@@ -95,10 +99,13 @@ Dir["common/lib/*"].select{|lib| File.directory?(lib)}.each do |lib|
end end
TEST_TASK_DIRS << lib TEST_TASK_DIRS << lib
desc "Run tests for common lib #{lib} (without coverage)" # There used to be a fasttest_#{lib} command that ran without coverage.
task "fasttest_#{lib}" do # However, this is an inconsistent usage of "fast":
sh("nosetests #{lib}") # When running tests for lms and cms, "fast" means skipping
end # staticfiles collection, but still running under coverage.
# We keep the fasttest_#{lib} command for backwards compatibility,
# but make it an alias to the normal test command.
task "fasttest_#{lib}" => "test_#{lib}"
end end
task :report_dirs task :report_dirs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment