Commit dcefd9e9 by Calen Pennington

Taught rake test_lms and test_cms to run specific tests by passing a single argument

parent 2add58bb
...@@ -117,12 +117,11 @@ xmodule can be tested independently, with this: ...@@ -117,12 +117,11 @@ xmodule can be tested independently, with this:
To run a single django test class: To run a single django test class:
django-admin.py test --settings=lms.envs.test --pythonpath=. lms/djangoapps/courseware/tests/tests.py:TestViewAuth rake test_lms[courseware.tests.tests:testViewAuth]
To run a single django test: To run a single django test:
django-admin.py test --settings=lms.envs.test --pythonpath=. lms/djangoapps/courseware/tests/tests.py:TestViewAuth.test_dark_launch rake test_lms[courseware.tests.tests:TestViewAuth.test_dark_launch]
To run a single nose test file: To run a single nose test file:
......
...@@ -73,8 +73,8 @@ rake pylint > pylint.log || cat pylint.log ...@@ -73,8 +73,8 @@ rake pylint > pylint.log || cat pylint.log
TESTS_FAILED=0 TESTS_FAILED=0
# Run the python unit tests # Run the python unit tests
rake test_cms[false] || TESTS_FAILED=1 rake test_cms || TESTS_FAILED=1
rake test_lms[false] || TESTS_FAILED=1 rake test_lms || TESTS_FAILED=1
rake test_common/lib/capa || TESTS_FAILED=1 rake test_common/lib/capa || TESTS_FAILED=1
rake test_common/lib/xmodule || TESTS_FAILED=1 rake test_common/lib/xmodule || TESTS_FAILED=1
......
...@@ -12,10 +12,11 @@ def run_under_coverage(cmd, root) ...@@ -12,10 +12,11 @@ def run_under_coverage(cmd, root)
return cmd return cmd
end end
def run_tests(system, report_dir, stop_on_failure=true) def run_tests(system, report_dir, test_id=nil, stop_on_failure=true)
ENV['NOSE_XUNIT_FILE'] = File.join(report_dir, "nosetests.xml") ENV['NOSE_XUNIT_FILE'] = File.join(report_dir, "nosetests.xml")
dirs = Dir["common/djangoapps/*"] + Dir["#{system}/djangoapps/*"] dirs = Dir["common/djangoapps/*"] + Dir["#{system}/djangoapps/*"]
cmd = django_admin(system, :test, 'test', '--logging-clear-handlers', *dirs.each) test_id = dirs.join(' ') if test_id.nil? or test_id == ''
cmd = django_admin(system, :test, 'test', '--logging-clear-handlers', test_id)
sh(run_under_coverage(cmd, system)) do |ok, res| sh(run_under_coverage(cmd, system)) do |ok, res|
if !ok and stop_on_failure if !ok and stop_on_failure
abort "Test failed!" abort "Test failed!"
...@@ -44,13 +45,13 @@ TEST_TASK_DIRS = [] ...@@ -44,13 +45,13 @@ TEST_TASK_DIRS = []
# Per System tasks # Per System tasks
desc "Run all django tests on our djangoapps for the #{system}" desc "Run all django tests on our djangoapps for the #{system}"
task "test_#{system}", [:stop_on_failure] => ["clean_test_files", :predjango, "#{system}:gather_assets:test", "fasttest_#{system}"] task "test_#{system}", [:test_id, :stop_on_failure] => ["clean_test_files", :predjango, "#{system}:gather_assets:test", "fasttest_#{system}"]
# Have a way to run the tests without running collectstatic -- useful when debugging without # Have a way to run the tests without running collectstatic -- useful when debugging without
# messing with static files. # messing with static files.
task "fasttest_#{system}", [:stop_on_failure] => [report_dir, :install_prereqs, :predjango] do |t, args| task "fasttest_#{system}", [:test_id, :stop_on_failure] => [report_dir, :install_prereqs, :predjango] do |t, args|
args.with_defaults(:stop_on_failure => 'true') args.with_defaults(:stop_on_failure => 'true', :test_id => nil)
run_tests(system, report_dir, args.stop_on_failure) run_tests(system, report_dir, args.test_id, args.stop_on_failure)
end end
# Run acceptance tests # Run acceptance tests
...@@ -100,7 +101,7 @@ end ...@@ -100,7 +101,7 @@ end
task :test do task :test do
TEST_TASK_DIRS.each do |dir| TEST_TASK_DIRS.each do |dir|
Rake::Task["test_#{dir}"].invoke(false) Rake::Task["test_#{dir}"].invoke(nil, false)
end end
if $failed_tests > 0 if $failed_tests > 0
......
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