2018-01-09 23:28:30 +03:00
|
|
|
#!/usr/bin/env python3
|
2019-06-20 02:58:25 +03:00
|
|
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
2018-01-09 23:28:30 +03:00
|
|
|
#
|
2019-06-20 02:58:25 +03:00
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2.
|
2018-01-09 23:28:30 +03:00
|
|
|
|
|
|
|
import os
|
|
|
|
import subprocess
|
2018-04-05 03:31:28 +03:00
|
|
|
from typing import Dict
|
|
|
|
|
|
|
|
from .lib import testcase
|
2018-01-09 23:28:30 +03:00
|
|
|
|
|
|
|
|
|
|
|
@testcase.eden_repo_test
|
2018-04-05 03:31:25 +03:00
|
|
|
class PatchTest(testcase.EdenRepoTest):
|
2018-04-05 03:31:28 +03:00
|
|
|
def populate_repo(self) -> None:
|
2018-05-10 07:33:49 +03:00
|
|
|
self.repo.write_file("hello", "hola\n")
|
|
|
|
self.repo.commit("Initial commit.")
|
2018-01-09 23:28:30 +03:00
|
|
|
|
2018-04-05 03:31:28 +03:00
|
|
|
def edenfs_logging_settings(self) -> Dict[str, str]:
|
2018-05-10 07:33:49 +03:00
|
|
|
return {"eden.strace": "DBG7", "eden.fs.fuse": "DBG7"}
|
2018-01-09 23:28:30 +03:00
|
|
|
|
2018-04-05 03:31:28 +03:00
|
|
|
def test_patch(self) -> None:
|
2018-05-10 07:33:49 +03:00
|
|
|
proc = subprocess.Popen(["patch"], cwd=self.mount, stdin=subprocess.PIPE)
|
|
|
|
stdout, stderr = proc.communicate(
|
|
|
|
b"""
|
2018-01-09 23:28:30 +03:00
|
|
|
--- hello
|
|
|
|
+++ hello
|
|
|
|
@@ -1 +1 @@
|
|
|
|
-hola
|
|
|
|
+bye
|
2018-05-10 07:33:49 +03:00
|
|
|
"""
|
|
|
|
)
|
2018-01-09 23:28:30 +03:00
|
|
|
|
|
|
|
print(stdout, stderr)
|
|
|
|
|
2018-05-10 07:33:49 +03:00
|
|
|
with open(os.path.join(self.mount, "hello"), "r") as f:
|
|
|
|
self.assertEqual("bye\n", f.read())
|