sapling/eden/integration/sed_test.py
Adam Simpkins 8884b46b3f move integration tests to eden/integration
Summary:
Move the integration tests from eden/fs/integration up one directory, to
eden/integration.

The main benefit is that this makes it easy to run just the edenfs unit tests
by running "buck test eden/fs/...".  These unit tests complete much more
quickly than the full set of integration tests, providing a faster test suite
to re-run repeatedly during development.  The integration tests can be run with
"buck test eden/integration/...", and the full set of tests can still be run
with "buck test eden/..."

Reviewed By: wez

Differential Revision: D4490247

fbshipit-source-id: 5ceb5a19526f56e1cb926f352fa30ad2f1212c05
2017-01-31 14:41:14 -08:00

41 lines
1.3 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.
from .lib import testcase
import os
import stat
import subprocess
@testcase.eden_repo_test
class SedTest:
def populate_repo(self):
self.repo.write_file('hello', 'hola\n')
self.repo.commit('Initial commit.')
def test_sed(self):
filename = os.path.join(self.mount, 'sedme')
with open(filename, 'w') as f:
f.write('foo\n')
before_st = os.lstat(filename)
self.assertTrue(stat.S_ISREG(before_st.st_mode))
subprocess.check_call(['sed', '-i', '-e', 's/foo/bar/', filename])
after_st = os.lstat(filename)
self.assertNotEqual(after_st.st_ino, before_st.st_ino,
msg='renamed file has a new inode number')
self.assertEqual(4, after_st.st_size)
with open(filename, 'r') as f:
file_st = os.fstat(f.fileno())
self.assertEqual(after_st.st_ino, file_st.st_ino)
self.assertEqual('bar\n', f.read())