diff options
author | Evan Martin <martine@danga.com> | 2015-12-06 19:17:55 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2015-12-06 19:17:55 (GMT) |
commit | 2eb1cc9329d2e8c7d80ce01c5af044e383e1e50e (patch) | |
tree | 2e2d7e4d21b873f962ba98b6d1c25d370cc60780 | |
parent | be10fe342e7fa30a65c6567e336705a91a90a14c (diff) | |
parent | 97e96284a3cec71b8cf78a3bec5b525cc3e538bd (diff) | |
download | Ninja-2eb1cc9329d2e8c7d80ce01c5af044e383e1e50e.zip Ninja-2eb1cc9329d2e8c7d80ce01c5af044e383e1e50e.tar.gz Ninja-2eb1cc9329d2e8c7d80ce01c5af044e383e1e50e.tar.bz2 |
Merge pull request #1042 from avallee/master
Fix wrapping file paths in Writer.comment
-rw-r--r-- | misc/ninja_syntax.py | 5 | ||||
-rwxr-xr-x | misc/ninja_syntax_test.py | 6 |
2 files changed, 9 insertions, 2 deletions
diff --git a/misc/ninja_syntax.py b/misc/ninja_syntax.py index 8673518..73d2209 100644 --- a/misc/ninja_syntax.py +++ b/misc/ninja_syntax.py @@ -21,8 +21,9 @@ class Writer(object): def newline(self): self.output.write('\n') - def comment(self, text): - for line in textwrap.wrap(text, self.width - 2): + def comment(self, text, has_path=False): + for line in textwrap.wrap(text, self.width - 2, break_long_words=False, + break_on_hyphens=False): self.output.write('# ' + line + '\n') def variable(self, key, value, indent=0): diff --git a/misc/ninja_syntax_test.py b/misc/ninja_syntax_test.py index 36b2e7b..c9755b8 100755 --- a/misc/ninja_syntax_test.py +++ b/misc/ninja_syntax_test.py @@ -45,6 +45,12 @@ class TestLineWordWrap(unittest.TestCase): INDENT + 'y']) + '\n', self.out.getvalue()) + def test_comment_wrap(self): + # Filenames shoud not be wrapped + self.n.comment('Hello /usr/local/build-tools/bin') + self.assertEqual('# Hello\n# /usr/local/build-tools/bin\n', + self.out.getvalue()) + def test_short_words_indented(self): # Test that indent is taking into acount when breaking subsequent lines. # The second line should not be ' to tree', as that's longer than the |