summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoanna Wang <jojwang@google.com>2022-11-03 16:51:19 -0400
committerJoanna Wang <jojwang@google.com>2022-11-03 21:07:07 +0000
commita6c52f566acfbff5b0f37158c0d33adf05d250e5 (patch)
treed79d55b872c3be39c54dcb6ef41749c40d39ccf2 /tests
parent0d130d2da0754c546f654ede99a79aac2b8e6c5f (diff)
downloadgit-repo-a6c52f566acfbff5b0f37158c0d33adf05d250e5.tar.gz
Set tracing to always on and save to .repo/TRACE_FILE.
- add `--trace_to_stderr` option so stderr will include trace outputs and any other errors that get sent to stderr - while TRACE_FILE will only include trace outputs piggy-backing on: https://gerrit-review.googlesource.com/c/git-repo/+/349154 Change-Id: I3895a84de4b2784f17fac4325521cd5e72e645e2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/350114 Reviewed-by: LaMont Jones <lamontjones@google.com> Tested-by: Joanna Wang <jojwang@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_git_config.py14
-rw-r--r--tests/test_git_superproject.py2
-rw-r--r--tests/test_manifest_xml.py2
-rw-r--r--tests/test_project.py8
4 files changed, 26 insertions, 0 deletions
diff --git a/tests/test_git_config.py b/tests/test_git_config.py
index a4fad9ef..0df38430 100644
--- a/tests/test_git_config.py
+++ b/tests/test_git_config.py
@@ -19,6 +19,7 @@ import tempfile
19import unittest 19import unittest
20 20
21import git_config 21import git_config
22import repo_trace
22 23
23 24
24def fixture(*paths): 25def fixture(*paths):
@@ -33,9 +34,16 @@ class GitConfigReadOnlyTests(unittest.TestCase):
33 def setUp(self): 34 def setUp(self):
34 """Create a GitConfig object using the test.gitconfig fixture. 35 """Create a GitConfig object using the test.gitconfig fixture.
35 """ 36 """
37
38 self.tempdirobj = tempfile.TemporaryDirectory(prefix='repo_tests')
39 repo_trace._TRACE_FILE = os.path.join(self.tempdirobj.name, 'TRACE_FILE_from_test')
40
36 config_fixture = fixture('test.gitconfig') 41 config_fixture = fixture('test.gitconfig')
37 self.config = git_config.GitConfig(config_fixture) 42 self.config = git_config.GitConfig(config_fixture)
38 43
44 def tearDown(self):
45 self.tempdirobj.cleanup()
46
39 def test_GetString_with_empty_config_values(self): 47 def test_GetString_with_empty_config_values(self):
40 """ 48 """
41 Test config entries with no value. 49 Test config entries with no value.
@@ -109,9 +117,15 @@ class GitConfigReadWriteTests(unittest.TestCase):
109 """Read/write tests of the GitConfig class.""" 117 """Read/write tests of the GitConfig class."""
110 118
111 def setUp(self): 119 def setUp(self):
120 self.tempdirobj = tempfile.TemporaryDirectory(prefix='repo_tests')
121 repo_trace._TRACE_FILE = os.path.join(self.tempdirobj.name, 'TRACE_FILE_from_test')
122
112 self.tmpfile = tempfile.NamedTemporaryFile() 123 self.tmpfile = tempfile.NamedTemporaryFile()
113 self.config = self.get_config() 124 self.config = self.get_config()
114 125
126 def tearDown(self):
127 self.tempdirobj.cleanup()
128
115 def get_config(self): 129 def get_config(self):
116 """Get a new GitConfig instance.""" 130 """Get a new GitConfig instance."""
117 return git_config.GitConfig(self.tmpfile.name) 131 return git_config.GitConfig(self.tmpfile.name)
diff --git a/tests/test_git_superproject.py b/tests/test_git_superproject.py
index 0ad9b01d..0bb77185 100644
--- a/tests/test_git_superproject.py
+++ b/tests/test_git_superproject.py
@@ -24,6 +24,7 @@ from unittest import mock
24import git_superproject 24import git_superproject
25import git_trace2_event_log 25import git_trace2_event_log
26import manifest_xml 26import manifest_xml
27import repo_trace
27from test_manifest_xml import sort_attributes 28from test_manifest_xml import sort_attributes
28 29
29 30
@@ -39,6 +40,7 @@ class SuperprojectTestCase(unittest.TestCase):
39 """Set up superproject every time.""" 40 """Set up superproject every time."""
40 self.tempdirobj = tempfile.TemporaryDirectory(prefix='repo_tests') 41 self.tempdirobj = tempfile.TemporaryDirectory(prefix='repo_tests')
41 self.tempdir = self.tempdirobj.name 42 self.tempdir = self.tempdirobj.name
43 repo_trace._TRACE_FILE = os.path.join(self.tempdir, 'TRACE_FILE_from_test')
42 self.repodir = os.path.join(self.tempdir, '.repo') 44 self.repodir = os.path.join(self.tempdir, '.repo')
43 self.manifest_file = os.path.join( 45 self.manifest_file = os.path.join(
44 self.repodir, manifest_xml.MANIFEST_FILE_NAME) 46 self.repodir, manifest_xml.MANIFEST_FILE_NAME)
diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py
index 06328661..f92108e1 100644
--- a/tests/test_manifest_xml.py
+++ b/tests/test_manifest_xml.py
@@ -23,6 +23,7 @@ import xml.dom.minidom
23 23
24import error 24import error
25import manifest_xml 25import manifest_xml
26import repo_trace
26 27
27 28
28# Invalid paths that we don't want in the filesystem. 29# Invalid paths that we don't want in the filesystem.
@@ -93,6 +94,7 @@ class ManifestParseTestCase(unittest.TestCase):
93 def setUp(self): 94 def setUp(self):
94 self.tempdirobj = tempfile.TemporaryDirectory(prefix='repo_tests') 95 self.tempdirobj = tempfile.TemporaryDirectory(prefix='repo_tests')
95 self.tempdir = self.tempdirobj.name 96 self.tempdir = self.tempdirobj.name
97 repo_trace._TRACE_FILE = os.path.join(self.tempdir, 'TRACE_FILE_from_test')
96 self.repodir = os.path.join(self.tempdir, '.repo') 98 self.repodir = os.path.join(self.tempdir, '.repo')
97 self.manifest_dir = os.path.join(self.repodir, 'manifests') 99 self.manifest_dir = os.path.join(self.repodir, 'manifests')
98 self.manifest_file = os.path.join( 100 self.manifest_file = os.path.join(
diff --git a/tests/test_project.py b/tests/test_project.py
index acd44ccc..5c600be7 100644
--- a/tests/test_project.py
+++ b/tests/test_project.py
@@ -26,6 +26,7 @@ import git_command
26import git_config 26import git_config
27import platform_utils 27import platform_utils
28import project 28import project
29import repo_trace
29 30
30 31
31@contextlib.contextmanager 32@contextlib.contextmanager
@@ -64,6 +65,13 @@ class FakeProject(object):
64class ReviewableBranchTests(unittest.TestCase): 65class ReviewableBranchTests(unittest.TestCase):
65 """Check ReviewableBranch behavior.""" 66 """Check ReviewableBranch behavior."""
66 67
68 def setUp(self):
69 self.tempdirobj = tempfile.TemporaryDirectory(prefix='repo_tests')
70 repo_trace._TRACE_FILE = os.path.join(self.tempdirobj.name, 'TRACE_FILE_from_test')
71
72 def tearDown(self):
73 self.tempdirobj.cleanup()
74
67 def test_smoke(self): 75 def test_smoke(self):
68 """A quick run through everything.""" 76 """A quick run through everything."""
69 with TempGitTree() as tempdir: 77 with TempGitTree() as tempdir: