diff options
author | Steven Knight <knight@baldmt.com> | 2003-10-22 03:15:44 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2003-10-22 03:15:44 (GMT) |
commit | 69767c5516cfd51afc93b87746f130825f0bf831 (patch) | |
tree | 0177b25e280c6371d87d57211d667c9952a7440d /src/engine/SCons/JobTests.py | |
parent | 4618fabde17038bd961f93ceb9af6b31e778540b (diff) | |
download | SCons-69767c5516cfd51afc93b87746f130825f0bf831.zip SCons-69767c5516cfd51afc93b87746f130825f0bf831.tar.gz SCons-69767c5516cfd51afc93b87746f130825f0bf831.tar.bz2 |
Really handle lack of the threading.py module when run by non-threaded Pythons.
Diffstat (limited to 'src/engine/SCons/JobTests.py')
-rw-r--r-- | src/engine/SCons/JobTests.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/engine/SCons/JobTests.py b/src/engine/SCons/JobTests.py index 1b09fd6..1b0128b 100644 --- a/src/engine/SCons/JobTests.py +++ b/src/engine/SCons/JobTests.py @@ -190,7 +190,7 @@ class Taskmaster: class ParallelTestCase(unittest.TestCase): def runTest(self): "test parallel jobs" - + try: import threading except: @@ -226,6 +226,31 @@ class SerialTestCase(unittest.TestCase): self.failIf(taskmaster.num_failed, "some task(s) failed to execute") +class NoParallelTestCase(unittest.TestCase): + def runTest(self): + "test handling lack of parallel support" + def NoParallel(tm, num): + raise NameError + save_Parallel = SCons.Job.Parallel + SCons.Job.Parallel = NoParallel + try: + taskmaster = Taskmaster(num_tasks, self, Task) + jobs = SCons.Job.Jobs(2, taskmaster) + self.failUnless(jobs.num_jobs == 1, + "unexpected number of jobs %d" % jobs.num_jobs) + jobs.run() + self.failUnless(taskmaster.tasks_were_serial(), + "the tasks were not executed in series") + self.failUnless(taskmaster.all_tasks_are_executed(), + "all the tests were not executed") + self.failUnless(taskmaster.all_tasks_are_iterated(), + "all the tests were not iterated over") + self.failIf(taskmaster.num_failed, + "some task(s) failed to execute") + finally: + SCons.Job.Parallel = save_Parallel + + class SerialExceptionTestCase(unittest.TestCase): def runTest(self): "test a serial job with tasks that raise exceptions" @@ -261,6 +286,7 @@ def suite(): suite = unittest.TestSuite() suite.addTest(ParallelTestCase()) suite.addTest(SerialTestCase()) + suite.addTest(NoParallelTestCase()) suite.addTest(SerialExceptionTestCase()) suite.addTest(ParallelExceptionTestCase()) return suite |