Skip to content

Commit 7bf5dfe

Browse files
grievejiafacebook-github-bot
authored andcommitted
Implement pyre coverage (1/3) -- skeleton
Reviewed By: kbansal Differential Revision: D30436432 fbshipit-source-id: 0154da6da330697967300b59ff293f23f0eeafd9
1 parent 664648b commit 7bf5dfe

File tree

3 files changed

+44
-10
lines changed

3 files changed

+44
-10
lines changed

client/commands/v2/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from . import backend_arguments # noqa F401
77
from . import check # noqa F401
8+
from . import coverage # noqa F401
89
from . import incremental # noqa F401
910
from . import infer # noqa F401
1011
from . import initialize # noqa F401

client/commands/v2/coverage.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
import logging
7+
8+
from ... import commands, configuration as configuration_module
9+
from . import remote_logging
10+
11+
LOG: logging.Logger = logging.getLogger(__name__)
12+
13+
14+
def run_coverage(
15+
configuration: configuration_module.Configuration, working_directory: str
16+
) -> commands.ExitCode:
17+
LOG.warning("Coming soon...")
18+
return commands.ExitCode.SUCCESS
19+
20+
21+
@remote_logging.log_usage(command_name="coverage")
22+
def run(
23+
configuration: configuration_module.Configuration, working_directory: str
24+
) -> commands.ExitCode:
25+
try:
26+
return run_coverage(configuration, working_directory)
27+
except Exception as error:
28+
raise commands.ClientException(
29+
f"Exception occured during pyre coverage: {error}"
30+
) from error

client/pyre.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,16 +1439,19 @@ def coverage(
14391439
"""
14401440
command_argument: command_arguments.CommandArguments = context.obj["arguments"]
14411441
configuration = _create_configuration_with_retry(command_argument, Path("."))
1442-
return run_pyre_command(
1443-
commands.Coverage(
1444-
command_argument,
1445-
original_directory=os.getcwd(),
1446-
configuration=configuration,
1447-
working_directory=working_directory,
1448-
),
1449-
configuration,
1450-
command_argument.noninteractive,
1451-
)
1442+
if configuration.use_command_v2:
1443+
return v2.coverage.run(configuration, working_directory)
1444+
else:
1445+
return run_pyre_command(
1446+
commands.Coverage(
1447+
command_argument,
1448+
original_directory=os.getcwd(),
1449+
configuration=configuration,
1450+
working_directory=working_directory,
1451+
),
1452+
configuration,
1453+
command_argument.noninteractive,
1454+
)
14521455

14531456

14541457
@pyre.command()

0 commit comments

Comments
 (0)