Skip to content

Commit e6ff971

Browse files
author
Alex Remedios
authored
UI fixes (#4)
1 parent 52def68 commit e6ff971

9 files changed

Lines changed: 231 additions & 129 deletions

File tree

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
],
3333
"menus": {
3434
"editor/title": [
35-
{
36-
"command": "deeptest.toggleDeeptest",
37-
"group": "navigation"
38-
}
35+
{
36+
"command": "deeptest.toggleDeeptest",
37+
"group": "navigation"
38+
}
3939
]
40-
}
40+
}
4141
},
4242
"scripts": {
4343
"vscode:prepublish": "yarn run compile",
@@ -64,5 +64,6 @@
6464
"typescript": "^4.1.3",
6565
"vscode-test": "^1.5.0"
6666
},
67-
"dependencies": {}
67+
"dependencies": {
68+
}
6869
}

python-cli/poetry.lock

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python-cli/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ rich = "^9.13.0"
1919
pydantic = "^1.8.1"
2020
coverage = "^5.5"
2121
junitparser = "^2.0.0"
22+
timeago = "^1.0.15"
2223

2324
[tool.poetry.dev-dependencies]
2425
pytest = "^6.2.2"

python-cli/src/deeptest/cli.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import json
22
import os
33
import sys
4+
from datetime import datetime
45
from enum import Enum
56
from pathlib import Path
6-
from typing import Dict, List, cast
7+
from typing import Dict, List, Optional, cast
78

89
import click
10+
import timeago
911
from coverage import Coverage, CoverageData
1012
from coverage.misc import NoSource
1113
from junitparser import JUnitXml
@@ -73,9 +75,23 @@ def get_file_cov(src: str, coverage: Coverage, coverage_data: CoverageData):
7375

7476

7577
@click.command()
76-
@click.argument("source")
77-
def run(source: str):
78+
@click.argument("source", required=False)
79+
@click.option("--data-dir", default=None)
80+
def run(source: Optional[str], data_dir: Optional[str]):
7881
""""""
82+
if data_dir:
83+
Path(data_dir).mkdir(exist_ok=True, parents=True)
84+
os.chdir(data_dir)
85+
86+
if source is None:
87+
if Path(".coverage").exists():
88+
stats = os.stat(".coverage")
89+
dt = datetime.fromtimestamp(stats.st_mtime)
90+
ago = timeago.format(dt, datetime.now())
91+
click.echo(json.dumps({"time_since_run": ago}))
92+
else:
93+
click.echo(json.dumps({"time_since_run": None}))
94+
sys.exit(0)
7995
src = Path(source).as_posix()
8096
test_results = Path("junit.xml")
8197
if not test_results.exists():
@@ -108,8 +124,13 @@ def run(source: str):
108124
assert coverage_data is not None
109125
lines, missing_lines = get_file_cov(src, coverage, coverage_data)
110126

111-
norm_contexts = {norm(ctx) for ctx in coverage_data.measured_contexts()}
112-
assert norm_contexts.difference(status.keys()) == set()
127+
# norm_contexts = {norm(ctx) for ctx in coverage_data.measured_contexts()}
128+
129+
# no_matching_key = norm_contexts.difference(status.keys())
130+
131+
# if len(no_matching_key)> 0:
132+
# lkj = '\n'.join(no_matching_key)
133+
# click.echo(f"No matching key:{lkj} ")
113134

114135
file = File(
115136
lines={

python-cli/tests/test_cli.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,13 @@ def test_when_out_of_cov_scope_then_error(self, tested_dir: object):
9090
print(f"Running {source}")
9191
result = runner.invoke(cli.run, source.as_posix(), catch_exceptions=False)
9292
assert json.loads(result.stdout)["error"].startswith("No cov")
93+
94+
def test_when_status_then_time_given(self, tested_dir: object):
95+
runner = CliRunner()
96+
result = runner.invoke(cli.run, catch_exceptions=False)
97+
assert json.loads(result.stdout)["time_since_run"] == "just now"
98+
99+
def test_when_status_no_data_then_null(self, testdir: pytest.Testdir):
100+
runner = CliRunner()
101+
result = runner.invoke(cli.run, catch_exceptions=False)
102+
assert json.loads(result.stdout)["time_since_run"] == None

0 commit comments

Comments
 (0)