Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 2eb1cc9

Browse files
committed
Merge pull request ninja-build#1042 from avallee/master
Fix wrapping file paths in Writer.comment
2 parents be10fe3 + 97e9628 commit 2eb1cc9

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

misc/ninja_syntax.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ def __init__(self, output, width=78):
2121
def newline(self):
2222
self.output.write('\n')
2323

24-
def comment(self, text):
25-
for line in textwrap.wrap(text, self.width - 2):
24+
def comment(self, text, has_path=False):
25+
for line in textwrap.wrap(text, self.width - 2, break_long_words=False,
26+
break_on_hyphens=False):
2627
self.output.write('# ' + line + '\n')
2728

2829
def variable(self, key, value, indent=0):

misc/ninja_syntax_test.py

+6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ def test_few_long_words(self):
4545
INDENT + 'y']) + '\n',
4646
self.out.getvalue())
4747

48+
def test_comment_wrap(self):
49+
# Filenames shoud not be wrapped
50+
self.n.comment('Hello /usr/local/build-tools/bin')
51+
self.assertEqual('# Hello\n# /usr/local/build-tools/bin\n',
52+
self.out.getvalue())
53+
4854
def test_short_words_indented(self):
4955
# Test that indent is taking into acount when breaking subsequent lines.
5056
# The second line should not be ' to tree', as that's longer than the

0 commit comments

Comments
 (0)