ya2 · news · projects · code · about

renamed lib to ya2
[pmachines.git] / tests / lib / build / test_mtprocesser.py
1 '''lib.build.mtprocesser's unit tests.'''
2 from pathlib import Path
3 import sys
4 sys.path = [path for path in sys.path if path != '']
5
6 # we're in yocto/tests/lib/build/
7 sys.path.append(str(Path(__file__).parent.parent.parent.parent))
8 from pathlib import Path
9 from os.path import exists
10 from unittest import TestCase
11 from ya2.build.mtprocesser import ProcesserMgr
12
13
14 class ProcesserMgrTests(TestCase):
15 '''ProcesserMgr's unit tests '''
16
17 def setUp(self):
18 '''unit tests' set up'''
19 for idx in [1, 2]:
20 Path('./tests/%s.txt' % idx).unlink(missing_ok=True)
21
22 def tearDown(self):
23 '''unit tests' tear down'''
24 self.setUp()
25
26 def test_threaded(self):
27 '''test of the threaded case'''
28 pmgr = ProcesserMgr(2)
29 pmgr.add('echo 1 > ./tests/1.txt')
30 pmgr.add('echo 2 > ./tests/2.txt')
31 pmgr.run()
32 self.assertTrue(exists('./tests/1.txt'))
33 self.assertTrue(exists('./tests/2.txt'))
34
35 def test_nothreaded(self):
36 '''test when we don't use threads'''
37 pmgr = ProcesserMgr(1)
38 pmgr.add('echo 1 > ./tests/1.txt')
39 pmgr.run()
40 self.assertTrue(exists('./tests/1.txt'))