Commit 7eb196df by Ned Batchelder Committed by Calen Pennington

Run coverage directly instead of as a plugin. Also quiet the install and clean steps of tests.

parent 7033faf1
...@@ -14,9 +14,6 @@ from path import path ...@@ -14,9 +14,6 @@ from path import path
# Nose Test Runner # Nose Test Runner
INSTALLED_APPS += ('django_nose',) 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_RUNNER = 'django_nose.NoseTestSuiteRunner'
TEST_ROOT = path('test_root') TEST_ROOT = path('test_root')
......
...@@ -29,16 +29,10 @@ SOUTH_TESTS_MIGRATE = False # To disable migrations and use syncdb instead ...@@ -29,16 +29,10 @@ SOUTH_TESTS_MIGRATE = False # To disable migrations and use syncdb instead
INSTALLED_APPS += ('django_nose',) INSTALLED_APPS += ('django_nose',)
NOSE_ARGS = [] NOSE_ARGS = []
# Turning off coverage speeds up tests dramatically... until we have better config, NOSE_ARGS = [
# leave it here for manual fiddling. '--with-xunit',
_coverage = True # '-v', '--pdb', # When really stuck, uncomment to start debugger on error
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]
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
# Local Directories # Local Directories
......
...@@ -49,12 +49,12 @@ default_options = { ...@@ -49,12 +49,12 @@ default_options = {
task :predjango do task :predjango do
sh("find . -type f -name *.pyc -delete") sh("find . -type f -name *.pyc -delete")
sh('pip install -e common/lib/xmodule -e common/lib/capa') sh("pip install -q -e common/lib/xmodule -e common/lib/capa")
sh('git submodule update --init') sh("git submodule update --init")
end end
task :clean_test_files do task :clean_test_files do
sh("git clean -fdx test_root") sh("git clean -fqdx test_root")
end end
[:lms, :cms, :common].each do |system| [:lms, :cms, :common].each do |system|
...@@ -84,11 +84,18 @@ end ...@@ -84,11 +84,18 @@ end
$failed_tests = 0 $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) def run_tests(system, report_dir, stop_on_failure=true)
ENV['NOSE_XUNIT_FILE'] = File.join(report_dir, "nosetests.xml") ENV['NOSE_XUNIT_FILE'] = File.join(report_dir, "nosetests.xml")
ENV['NOSE_COVER_HTML_DIR'] = File.join(report_dir, "cover") ENV['NOSE_COVER_HTML_DIR'] = File.join(report_dir, "cover")
dirs = Dir["common/djangoapps/*"] + Dir["#{system}/djangoapps/*"] 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 if !ok and stop_on_failure
abort "Test failed!" abort "Test failed!"
end end
...@@ -152,7 +159,8 @@ Dir["common/lib/*"].each do |lib| ...@@ -152,7 +159,8 @@ Dir["common/lib/*"].each do |lib|
desc "Run tests for common lib #{lib}" desc "Run tests for common lib #{lib}"
task task_name => report_dir do task task_name => report_dir do
ENV['NOSE_XUNIT_FILE'] = File.join(report_dir, "nosetests.xml") 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 end
TEST_TASKS << task_name TEST_TASKS << task_name
......
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