sapling/eden/integration/hypothesis_simple_test.py
Adam Simpkins 9e21449bee move creation of the .hg directory into the Eden CLI
Summary:
Update the `eden clone` command to automatically create the `.hg` directory
when creating a checkout for a Mercurial repository.

Previously this logic was performed by a separate post-clone hook that was
invoked by `eden clone`.  Having this logic in a separate script made the code
slightly more complicated, and meant that configuring Eden was also more
complicated, as the hook also needed to be installed and configured.  Moving
the logic into the Eden CLI will make it easier to re-use this code in
`eden doctor` if the `.hg` directory needs to be repaired.

Reviewed By: wez

Differential Revision: D13447272

fbshipit-source-id: 11c4f8e389aead151dd235eff95c860a326967af
2018-12-19 15:34:01 -08:00

50 lines
1.6 KiB
Python

#!/usr/bin/env python3
#
# Copyright (c) 2016-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
import os
import stat
import hypothesis
from eden.test_support.hypothesis import FILENAME_STRATEGY
from .lib import testcase
@testcase.eden_repo_test
class HypothesisSimpleTest(testcase.EdenRepoTest):
def populate_repo(self) -> None:
self.repo.write_file("hello", "hola\n")
self.repo.write_file("adir/file", "foo!\n")
self.repo.write_file("bdir/test.sh", "#!/bin/bash\necho test\n", mode=0o755)
self.repo.write_file("bdir/noexec.sh", "#!/bin/bash\necho test\n")
self.repo.symlink("slink", "hello")
self.repo.commit("Initial commit.")
@hypothesis.given(FILENAME_STRATEGY)
def test_create(self, basename: str) -> None:
filename = os.path.join(self.mount, basename)
# Ensure that we don't proceed if hypothesis has selected a name that
# conflicts with the names we generated in the repo.
hypothesis.assume(not os.path.exists(filename))
with open(filename, "w") as f:
f.write("created\n")
self.assert_checkout_root_entries(
{".eden", "adir", "bdir", "hello", basename, "slink"}
)
with open(filename, "r") as f:
self.assertEqual(f.read(), "created\n")
st = os.lstat(filename)
self.assertEqual(st.st_size, 8)
self.assertTrue(stat.S_ISREG(st.st_mode))