forked from BobBuildTool/bob
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_scm_cvs.py
79 lines (63 loc) · 2.46 KB
/
test_scm_cvs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Bob build tool
# Copyright (C) 2019 Jan Klötzke
#
# SPDX-License-Identifier: GPL-3.0-or-later
from unittest import TestCase
import os
import subprocess
import tempfile
from bob.scm import CvsScm, ScmTaint
from bob.utils import emptyDirectory
class TestCvsScmStatus(TestCase):
@classmethod
def setUpClass(cls):
cls.__cvsroot = tempfile.TemporaryDirectory()
cls.cvsroot = cls.__cvsroot.name
with tempfile.TemporaryDirectory() as tmp:
# create template that is imported into svn repo
with open(os.path.join(tmp, "test.txt"), "w") as f:
f.write("dummy")
# setup repo
subprocess.check_call(['cvs', '-q', '-d', cls.cvsroot, 'init'], cwd="/tmp")
# import some files
subprocess.check_call(['cvs', '-q', '-d', cls.cvsroot, 'import', '-m',
"Initial Import", 'testmod', 'bob', 'start'], cwd=tmp)
@classmethod
def tearDownClass(cls):
cls.__cvsroot.cleanup()
def setUp(self):
self.__repodir = tempfile.TemporaryDirectory()
self.repodir = self.__repodir.name
# clone the repo
subprocess.check_call(['cvs', '-q', '-d', self.cvsroot, 'co', '-d',
self.repodir, 'testmod'], cwd='/tmp')
def tearDown(self):
self.__repodir.cleanup()
def statusCvsScm(self, spec = {}):
s = { 'scm' : "cvs", 'cvsroot' : self.cvsroot, 'module' : "testmod",
'recipe' : "foo.yaml#0", '__source' : "Recipe foo" }
s.update(spec)
return CvsScm(s).status(self.repodir)
def testClean(self):
s = self.statusCvsScm()
self.assertEqual(s.flags, set())
self.assertTrue(s.clean)
def testNonExisting(self):
emptyDirectory(self.repodir)
s = self.statusCvsScm()
self.assertEqual(s.flags, {ScmTaint.error})
self.assertTrue(s.error)
def testOtherRoot(self):
s = self.statusCvsScm({ 'cvsroot' : '/nonexisting' })
self.assertEqual(s.flags, {ScmTaint.switched})
self.assertTrue(s.dirty)
def testOtherModule(self):
s = self.statusCvsScm({ 'module' : 'nonexisting' })
self.assertEqual(s.flags, {ScmTaint.switched})
self.assertTrue(s.dirty)
def testModified(self):
with open(os.path.join(self.repodir, "test.txt"), "w") as f:
f.write("test modified")
s = self.statusCvsScm()
self.assertEqual(s.flags, {ScmTaint.modified})
self.assertTrue(s.dirty)