Skip to content

Commit 37b4703

Browse files
grievejiafacebook-github-bot
authored andcommitted
Implement pyre coverage (2/3) -- find root
Reviewed By: kbansal Differential Revision: D30436429 fbshipit-source-id: 08e5f08061994cecd8f3c4eaea6b7a98d343dc37
1 parent 7bf5dfe commit 37b4703

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

client/commands/v2/coverage.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,31 @@
44
# LICENSE file in the root directory of this source tree.
55

66
import logging
7+
from pathlib import Path
78

89
from ... import commands, configuration as configuration_module
9-
from . import remote_logging
10+
from . import remote_logging, statistics
1011

1112
LOG: logging.Logger = logging.getLogger(__name__)
1213

1314

15+
def find_root(
16+
configuration: configuration_module.Configuration, working_directory: Path
17+
) -> Path:
18+
local_root = configuration.local_root
19+
if local_root is not None:
20+
return Path(local_root)
21+
22+
return working_directory
23+
24+
1425
def run_coverage(
1526
configuration: configuration_module.Configuration, working_directory: str
1627
) -> commands.ExitCode:
17-
LOG.warning("Coming soon...")
28+
sources = statistics.find_paths_to_parse(
29+
[find_root(configuration, Path(working_directory))]
30+
)
31+
LOG.warning(f"SOURCES = {list(sources)}")
1832
return commands.ExitCode.SUCCESS
1933

2034

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright (c) Facebook, Inc. and its affiliates.
2+
#
3+
# This source code is licensed under the MIT license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
from pathlib import Path
7+
8+
import testslide
9+
10+
from .... import configuration
11+
from ..coverage import find_root
12+
13+
14+
class CoverageTest(testslide.TestCase):
15+
def test_find_root(self) -> None:
16+
self.assertEqual(
17+
find_root(
18+
configuration.Configuration(
19+
project_root="/root",
20+
dot_pyre_directory=Path("/irrelevant"),
21+
relative_local_root="local",
22+
),
23+
working_directory=Path("/irrelevant"),
24+
),
25+
Path("/root/local"),
26+
)
27+
self.assertEqual(
28+
find_root(
29+
configuration.Configuration(
30+
project_root="/root", dot_pyre_directory=Path("/irrelevant")
31+
),
32+
working_directory=Path("/working/dir"),
33+
),
34+
Path("/working/dir"),
35+
)

0 commit comments

Comments
 (0)