Skip to content

Commit

Permalink
modify --diffbase test to expect new behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
justbuchanan committed Jul 12, 2016
1 parent b1d0baa commit a1c8c6b
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions tests/test_stylize.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,31 @@ def test_format_py(self):
class TestDiffbase(Fixture):
def test_diffbase(self):
self.run_cmd("git init")
self.write_file('bad1.cpp', BAD_CPP)
self.run_cmd("git add bad1.cpp")

# commit bad file on master
self.write_file('file1.cpp', BAD_CPP)
self.run_cmd("git add .")
self.run_cmd("git commit -m 'added poorly-formatted cpp file'")
self.write_file('bad2.cpp', BAD_CPP)

self.run_stylize(["--clang_style=Google", "--diffbase=master"])
# modify file
self.write_file('file1.cpp', (str(BAD_CPP) + '\n').encode('utf-8'))
self.run_cmd("git add .")
self.run_cmd("git commit -m 'modified file1.cpp'")

# new branch off of first commit (not most recent on master)
self.run_cmd("git checkout -b new-branch HEAD~1")

self.assertTrue(self.file_changed('bad2.cpp', BAD_CPP))
self.assertFalse(self.file_changed('bad1.cpp', BAD_CPP))
# run stylize - the file shouldn't change b/c it was modified on master
# *after* this branch was branched off
self.run_stylize(["--clang_style=Google", "--diffbase=master"])
self.assertFalse(self.file_changed('file1.cpp', BAD_CPP))

# When the config file changes and we're using the --diffbase option,
# all files with the extensions related to that config should be
# formatted.
self.write_file('.clang-format', EXAMPLE_CLANG_FORMAT)
self.run_stylize(["--clang_style=file", "--diffbase=master"])
self.assertTrue(self.file_changed('bad1.cpp', BAD_CPP))
self.assertTrue(self.file_changed('file1.cpp', BAD_CPP))


## Test to ensure that stylize respects the "--exclude_dirs" option when it's
Expand Down

0 comments on commit a1c8c6b

Please sign in to comment.