sapling/eden/integration/debug_test.py
Chad Austin 20c77da782 implement debugInodeStatus with traverseObservedInodes
Summary:
Replace the old implementation of debugInodeStatus with the more
general traverseObservedInodes functionality, and add the ability to
customize its results with flags.

Reviewed By: xavierd

Differential Revision: D24300122

fbshipit-source-id: 0fbd3aa02575faa515fd7852441547d7de13426d
2020-11-02 13:52:37 -08:00

34 lines
1.2 KiB
Python

#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
import binascii
import os
from .lib import testcase
@testcase.eden_repo_test
class DebugBlobTest(testcase.EdenRepoTest):
def populate_repo(self) -> None:
self.repo.write_file("binary", b"\xff\xfe\xfd\xfc")
self.repo.commit("Initial commit.")
# TODO: enable when using the modern Python 3 Thrift API
def xtest_debug_blob_prints_binary_data(self) -> None:
with self.eden.get_thrift_client() as client:
debugInfo = client.debugInodeStatus(os.fsencode(self.mount), b".", flags=0)
[root] = [entry for entry in debugInfo if entry.path == b""]
self.assertEqual(1, root.inodeNumber)
[file] = [entry for entry in root.entries if entry.name == b"binary"]
self.assertEqual(False, file.materialized)
blob_id = binascii.hexlify(file.hash).decode()
print(blob_id)
output = self.eden.run_cmd("debug", "blob", ".", blob_id, cwd=self.mount)
self.assertEqual(b"\xff\xfe\xfd\xfc", output)