From 7eb196df38a566328b85c83e4bebffa2e510fe9e Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 6 Nov 2012 16:44:32 -0500 Subject: [PATCH] Run coverage directly instead of as a plugin. Also quiet the install and clean steps of tests. --- cms/envs/test.py | 3 --- lms/envs/test.py | 14 ++++---------- rakefile | 18 +++++++++++++----- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/cms/envs/test.py b/cms/envs/test.py index 7dcd32caab..08b25346be 100644 --- a/cms/envs/test.py +++ b/cms/envs/test.py @@ -14,9 +14,6 @@ from path import path # Nose Test Runner INSTALLED_APPS += ('django_nose',) -NOSE_ARGS = ['--cover-erase', '--with-xunit', '--with-xcoverage', '--cover-html', '--cover-inclusive'] -for app in os.listdir(PROJECT_ROOT / 'djangoapps'): - NOSE_ARGS += ['--cover-package', app] TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' TEST_ROOT = path('test_root') diff --git a/lms/envs/test.py b/lms/envs/test.py index bad680077b..01abce9f5a 100644 --- a/lms/envs/test.py +++ b/lms/envs/test.py @@ -29,16 +29,10 @@ SOUTH_TESTS_MIGRATE = False # To disable migrations and use syncdb instead INSTALLED_APPS += ('django_nose',) NOSE_ARGS = [] -# Turning off coverage speeds up tests dramatically... until we have better config, -# leave it here for manual fiddling. -_coverage = True -if _coverage: - NOSE_ARGS = ['--cover-erase', '--with-xunit', '--with-xcoverage', '--cover-html', - # '-v', '--pdb', # When really stuck, uncomment to start debugger on error - '--cover-inclusive', '--cover-html-dir', - os.environ.get('NOSE_COVER_HTML_DIR', 'cover_html')] - for app in os.listdir(PROJECT_ROOT / 'djangoapps'): - NOSE_ARGS += ['--cover-package', app] +NOSE_ARGS = [ + '--with-xunit', + # '-v', '--pdb', # When really stuck, uncomment to start debugger on error +] TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' # Local Directories diff --git a/rakefile b/rakefile index 73b0c0fd83..8ada145b18 100644 --- a/rakefile +++ b/rakefile @@ -49,12 +49,12 @@ default_options = { task :predjango do sh("find . -type f -name *.pyc -delete") - sh('pip install -e common/lib/xmodule -e common/lib/capa') - sh('git submodule update --init') + sh("pip install -q -e common/lib/xmodule -e common/lib/capa") + sh("git submodule update --init") end task :clean_test_files do - sh("git clean -fdx test_root") + sh("git clean -fqdx test_root") end [:lms, :cms, :common].each do |system| @@ -84,11 +84,18 @@ end $failed_tests = 0 +def run_under_coverage(cmd) + cmd0, cmd_rest = cmd.split(" ", 2) + cmd = "coverage run `which #{cmd0}` #{cmd_rest}" + return cmd +end + def run_tests(system, report_dir, stop_on_failure=true) ENV['NOSE_XUNIT_FILE'] = File.join(report_dir, "nosetests.xml") ENV['NOSE_COVER_HTML_DIR'] = File.join(report_dir, "cover") dirs = Dir["common/djangoapps/*"] + Dir["#{system}/djangoapps/*"] - sh(django_admin(system, :test, 'test', *dirs.each)) do |ok, res| + cmd = django_admin(system, :test, 'test', '--logging-clear-handlers', *dirs.each) + sh(run_under_coverage(cmd)) do |ok, res| if !ok and stop_on_failure abort "Test failed!" end @@ -152,7 +159,8 @@ Dir["common/lib/*"].each do |lib| desc "Run tests for common lib #{lib}" task task_name => report_dir do ENV['NOSE_XUNIT_FILE'] = File.join(report_dir, "nosetests.xml") - sh("nosetests #{lib} --cover-erase --with-xunit --with-xcoverage --cover-html --cover-inclusive --cover-package #{File.basename(lib)} --cover-html-dir #{File.join(report_dir, "cover")}") + cmd = "nosetests #{lib} --logging-clear-handlers --with-xunit" + sh(run_under_coverage(cmd)) end TEST_TASKS << task_name