sapling/tests/test-hgsubversion-svn-pre-commit-hooks.py
Kostia Balytskyi 5a73bf5843 hgsubversion: migrate all the tests to silentrunner
Summary:
This migration allows `./run-tests.py` to run `hgsubversion` tests. Since hgsubversion
tests are actually python unittests, we don't care about their output at all,
they fail differently. But the behavior of the test suite require us to match
whatever the tests prints. We do this later in the stack.

Depends on D6719886

Test Plan: - check that tests are runnable at least

Reviewers: #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D6719890
2018-01-17 03:23:44 -08:00

35 lines
1010 B
Python

# no-check-code -- see T24862348
import os
import test_hgsubversion_util
from mercurial import util
class TestSvnPreCommitHooks(test_hgsubversion_util.TestBase):
def setUp(self):
super(TestSvnPreCommitHooks, self).setUp()
self.repo_path = self.load_and_fetch('single_rev.svndump')[1]
# creating pre-commit hook that doesn't allow any commit
hook_file_name = os.path.join(
self.repo_path, 'hooks', 'pre-commit'
)
hook_file = open(hook_file_name, 'w')
hook_file.write(
'#!/bin/sh\n'
'echo "Commits are not allowed" >&2; exit 1;\n'
)
hook_file.close()
os.chmod(hook_file_name, 0755)
def test_push_with_pre_commit_hooks(self):
changes = [('narf/a', 'narf/a', 'ohai',),
]
self.commitchanges(changes)
self.assertRaises(util.Abort, self.pushrevisions)
if __name__ == '__main__':
import silenttestrunner
silenttestrunner.main(__name__)