summaryrefslogtreecommitdiffstats
path: root/misc/output_test.py
diff options
context:
space:
mode:
authorJan Niklas Hasse <jhasse@bixense.com>2024-03-22 20:12:05 (GMT)
committerGitHub <noreply@github.com>2024-03-22 20:12:05 (GMT)
commit903a05ce0e9befa8fb2767dd83a5a36499771087 (patch)
tree0b2ef21ff293c2553a42a677390fa020556fa371 /misc/output_test.py
parent481889bb5f3faa5b83116f6e583564e26bbabeec (diff)
parent878aa468d144d854005a6d4f0c7785a5185f0bf9 (diff)
downloadNinja-903a05ce0e9befa8fb2767dd83a5a36499771087.zip
Ninja-903a05ce0e9befa8fb2767dd83a5a36499771087.tar.gz
Ninja-903a05ce0e9befa8fb2767dd83a5a36499771087.tar.bz2
Merge pull request #2390 from jheydebrand/handle-deleted-logs-during-recompact
Gracefully handle outdated .ninja_log during '-t recompact'
Diffstat (limited to 'misc/output_test.py')
-rwxr-xr-xmisc/output_test.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/misc/output_test.py b/misc/output_test.py
index 78848cb..13b0926 100755
--- a/misc/output_test.py
+++ b/misc/output_test.py
@@ -127,6 +127,29 @@ build a: cat
self.assertEqual(run('', flags='-t recompact'), '')
self.assertEqual(run('', flags='-t restat'), '')
+ def test_issue_2048(self):
+ with tempfile.TemporaryDirectory() as d:
+ with open(os.path.join(d, 'build.ninja'), 'w'):
+ pass
+
+ with open(os.path.join(d, '.ninja_log'), 'w') as f:
+ f.write('# ninja log v4\n')
+
+ try:
+ output = subprocess.check_output([NINJA_PATH, '-t', 'recompact'],
+ cwd=d,
+ env=default_env,
+ stderr=subprocess.STDOUT,
+ text=True
+ )
+
+ self.assertEqual(
+ output.strip(),
+ "ninja: warning: build log version is too old; starting over"
+ )
+ except subprocess.CalledProcessError as err:
+ self.fail("non-zero exit code with: " + err.output)
+
def test_status(self):
self.assertEqual(run(''), 'ninja: no work to do.\n')
self.assertEqual(run('', pipe=True), 'ninja: no work to do.\n')