Skip to content

Commit 787ccc5

Browse files
authored
Merge branch 'main' into right-rattlesnake
2 parents 0b37929 + 6bd34bf commit 787ccc5

35 files changed

+241
-422
lines changed

.eslintrc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
"mocha": true
66
},
77
"parser": "@typescript-eslint/parser",
8-
"plugins": ["@typescript-eslint"],
8+
"plugins": [
9+
"@typescript-eslint",
10+
"no-only-tests"
11+
],
912
"extends": [
1013
"airbnb",
1114
"plugin:@typescript-eslint/recommended",
@@ -97,6 +100,7 @@
97100
}
98101
],
99102
"operator-assignment": "off",
100-
"strict": "off"
103+
"strict": "off",
104+
"no-only-tests/no-only-tests": ["error", { "block": ["test", "suite"], "focus": ["only"] }]
101105
}
102106
}

build/azure-pipeline.pre-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ extends:
107107
buildType: 'specific'
108108
project: 'Monaco'
109109
definition: 591
110-
buildVersionToDownload: 'latestFromBranch'
110+
buildVersionToDownload: 'latest'
111111
branchName: 'refs/heads/main'
112112
targetPath: '$(Build.SourcesDirectory)/python-env-tools/bin'
113113
artifactName: 'bin-$(vsceTarget)'

package-lock.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@
8383
"browser": "./dist/extension.browser.js",
8484
"l10n": "./l10n",
8585
"contributes": {
86-
"problemMatchers":
87-
[
86+
"problemMatchers": [
8887
{
8988
"name": "python",
9089
"owner": "python",
@@ -98,7 +97,6 @@
9897
},
9998
{
10099
"regexp": "^\\s*(.*)\\s*$"
101-
102100
},
103101
{
104102
"regexp": "^\\s*(.*Error.*)$",
@@ -682,6 +680,12 @@
682680
"experimental"
683681
]
684682
},
683+
"python.REPL.provideVariables": {
684+
"default": true,
685+
"description": "%python.REPL.provideVariables.description%",
686+
"scope": "resource",
687+
"type": "boolean"
688+
},
685689
"python.testing.autoTestDiscoverOnSaveEnabled": {
686690
"default": true,
687691
"description": "%python.testing.autoTestDiscoverOnSaveEnabled.description%",
@@ -1640,6 +1644,7 @@
16401644
"eslint-config-prettier": "^8.3.0",
16411645
"eslint-plugin-import": "^2.29.1",
16421646
"eslint-plugin-jsx-a11y": "^6.3.1",
1647+
"eslint-plugin-no-only-tests": "^3.3.0",
16431648
"eslint-plugin-react": "^7.20.3",
16441649
"eslint-plugin-react-hooks": "^4.0.0",
16451650
"expose-loader": "^3.1.0",

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"python.pixiToolPath.description": "Path to the pixi executable.",
6666
"python.EnableREPLSmartSend.description": "Toggle Smart Send for the Python REPL. Smart Send enables sending the smallest runnable block of code to the REPL on Shift+Enter and moves the cursor accordingly.",
6767
"python.REPL.sendToNativeREPL.description": "Toggle to send code to Python REPL instead of the terminal on execution. Turning this on will change the behavior for both Smart Send and Run Selection/Line in the Context Menu.",
68+
"python.REPL.provideVariables.description": "Toggle to provide variables for the REPL variable view for the native REPL.",
6869
"python.tensorBoard.logDirectory.description": "Set this setting to your preferred TensorBoard log directory to skip log directory prompt when starting TensorBoard.",
6970
"python.tensorBoard.logDirectory.markdownDeprecationMessage": "Tensorboard support has been moved to the extension [Tensorboard extension](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.tensorboard). Instead use the setting `tensorBoard.logDirectory`.",
7071
"python.tensorBoard.logDirectory.deprecationMessage": "Tensorboard support has been moved to the extension Tensorboard extension. Instead use the setting `tensorBoard.logDirectory`.",

python_files/tests/pytestadapter/helpers.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ def process_data_received(data: str) -> List[Dict[str, Any]]:
7171
7272
This function also:
7373
- Checks that the jsonrpc value is 2.0
74-
- Checks that the last JSON message contains the `eot` token.
7574
"""
7675
json_messages = []
7776
remaining = data
@@ -85,18 +84,14 @@ def process_data_received(data: str) -> List[Dict[str, Any]]:
8584
else:
8685
json_messages.append(json_data["params"])
8786

88-
last_json = json_messages.pop(-1)
89-
if "eot" not in last_json:
90-
raise ValueError("Last JSON messages does not contain 'eot' as its last payload.")
91-
return json_messages # return the list of json messages, only the params part without the EOT token
87+
return json_messages # return the list of json messages
9288

9389

9490
def parse_rpc_message(data: str) -> Tuple[Dict[str, str], str]:
9591
"""Process the JSON data which comes from the server.
9692
9793
A single rpc payload is in the format:
9894
content-length: #LEN# \r\ncontent-type: application/json\r\n\r\n{"jsonrpc": "2.0", "params": ENTIRE_DATA}
99-
with EOT params: "params": {"command_type": "discovery", "eot": true}
10095
10196
returns:
10297
json_data: A single rpc payload of JSON data from the server.

python_files/tests/pytestadapter/test_coverage.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import pathlib
55
import sys
66

7+
import pytest
8+
79
script_dir = pathlib.Path(__file__).parent.parent
810
sys.path.append(os.fspath(script_dir))
911

@@ -42,3 +44,47 @@ def test_simple_pytest_coverage():
4244
assert focal_function_coverage.get("lines_missed") is not None
4345
assert set(focal_function_coverage.get("lines_covered")) == {4, 5, 7, 9, 10, 11, 12, 13, 14, 17}
4446
assert set(focal_function_coverage.get("lines_missed")) == {18, 19, 6}
47+
48+
49+
coverage_file_path = TEST_DATA_PATH / "coverage_gen" / "coverage.json"
50+
51+
52+
@pytest.fixture
53+
def cleanup_coverage_file():
54+
# delete the coverage file if it exists as part of test cleanup
55+
yield
56+
if os.path.exists(coverage_file_path): # noqa: PTH110
57+
os.remove(coverage_file_path) # noqa: PTH107
58+
59+
60+
def test_coverage_gen_report(cleanup_coverage_file): # noqa: ARG001
61+
"""
62+
Test coverage payload is correct for simple pytest example. Output of coverage run is below.
63+
64+
Name Stmts Miss Branch BrPart Cover
65+
---------------------------------------------------
66+
__init__.py 0 0 0 0 100%
67+
reverse.py 13 3 8 2 76%
68+
test_reverse.py 11 0 0 0 100%
69+
---------------------------------------------------
70+
TOTAL 24 3 8 2 84%
71+
72+
"""
73+
args = ["--cov-report=json"]
74+
env_add = {"COVERAGE_ENABLED": "True"}
75+
cov_folder_path = TEST_DATA_PATH / "coverage_gen"
76+
actual = runner_with_cwd_env(args, cov_folder_path, env_add)
77+
assert actual
78+
coverage = actual[-1]
79+
assert coverage
80+
results = coverage["result"]
81+
assert results
82+
assert len(results) == 3
83+
focal_function_coverage = results.get(os.fspath(TEST_DATA_PATH / "coverage_gen" / "reverse.py"))
84+
assert focal_function_coverage
85+
assert focal_function_coverage.get("lines_covered") is not None
86+
assert focal_function_coverage.get("lines_missed") is not None
87+
assert set(focal_function_coverage.get("lines_covered")) == {4, 5, 7, 9, 10, 11, 12, 13, 14, 17}
88+
assert set(focal_function_coverage.get("lines_missed")) == {18, 19, 6}
89+
# assert that the coverage file was created at the right path
90+
assert os.path.exists(coverage_file_path) # noqa: PTH110

python_files/unittestadapter/discovery.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# If I use from utils then there will be an import error in test_discovery.py.
1717
from unittestadapter.pvsc_utils import ( # noqa: E402
1818
DiscoveryPayloadDict,
19-
EOTPayloadDict,
2019
VSCodeUnittestError,
2120
build_test_tree,
2221
parse_unittest_args,
@@ -129,7 +128,6 @@ def discover_tests(
129128
# collect args for Django discovery runner.
130129
args = argv[index + 1 :] or []
131130
django_discovery_runner(manage_py_path, args)
132-
# eot payload sent within Django runner.
133131
except Exception as e:
134132
error_msg = f"Error configuring Django test runner: {e}"
135133
print(error_msg, file=sys.stderr)
@@ -139,6 +137,3 @@ def discover_tests(
139137
payload = discover_tests(start_dir, pattern, top_level_dir)
140138
# Post this discovery payload.
141139
send_post_request(payload, test_run_pipe)
142-
# Post EOT token.
143-
eot_payload: EOTPayloadDict = {"command_type": "discovery", "eot": True}
144-
send_post_request(eot_payload, test_run_pipe)

python_files/unittestadapter/django_test_runner.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from execution import UnittestTestResult # noqa: E402
1414
from pvsc_utils import ( # noqa: E402
1515
DiscoveryPayloadDict,
16-
EOTPayloadDict,
1716
VSCodeUnittestError,
1817
build_test_tree,
1918
send_post_request,
@@ -64,9 +63,6 @@ def run_tests(self, test_labels, **kwargs):
6463

6564
# Send discovery payload.
6665
send_post_request(payload, test_run_pipe)
67-
# Send EOT token.
68-
eot_payload: EOTPayloadDict = {"command_type": "discovery", "eot": True}
69-
send_post_request(eot_payload, test_run_pipe)
7066
return 0 # Skip actual test execution, return 0 as no tests were run.
7167
except Exception as e:
7268
error_msg = (

python_files/unittestadapter/execution.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
from unittestadapter.pvsc_utils import ( # noqa: E402
2727
CoveragePayloadDict,
28-
EOTPayloadDict,
2928
ExecutionPayloadDict,
3029
FileCoverageInfo,
3130
TestExecutionStatus,
@@ -60,21 +59,6 @@ def startTest(self, test: unittest.TestCase): # noqa: N802
6059

6160
def stopTestRun(self): # noqa: N802
6261
super().stopTestRun()
63-
# After stopping the test run, send EOT
64-
test_run_pipe = os.getenv("TEST_RUN_PIPE")
65-
if os.getenv("MANAGE_PY_PATH"):
66-
# only send this if it is a Django run
67-
if not test_run_pipe:
68-
print(
69-
"UNITTEST ERROR: TEST_RUN_PIPE is not set at the time of unittest trying to send data. "
70-
f"TEST_RUN_PIPE = {test_run_pipe}\n",
71-
file=sys.stderr,
72-
)
73-
raise VSCodeUnittestError(
74-
"UNITTEST ERROR: TEST_RUN_PIPE is not set at the time of unittest trying to send data. "
75-
)
76-
eot_payload: EOTPayloadDict = {"command_type": "execution", "eot": True}
77-
send_post_request(eot_payload, test_run_pipe)
7862

7963
def addError( # noqa: N802
8064
self,
@@ -269,15 +253,8 @@ def run_tests(
269253
return payload
270254

271255

272-
def execute_eot_and_cleanup():
273-
eot_payload: EOTPayloadDict = {"command_type": "execution", "eot": True}
274-
send_post_request(eot_payload, test_run_pipe)
275-
if __socket:
276-
__socket.close()
277-
278-
279256
__socket = None
280-
atexit.register(execute_eot_and_cleanup)
257+
atexit.register(lambda: __socket.close() if __socket else None)
281258

282259

283260
def send_run_data(raw_data, test_run_pipe):
@@ -361,7 +338,6 @@ def send_run_data(raw_data, test_run_pipe):
361338
print("MANAGE_PY_PATH env var set, running Django test suite.")
362339
args = argv[index + 1 :] or []
363340
django_execution_runner(manage_py_path, test_ids, args)
364-
# the django run subprocesses sends the eot payload.
365341
else:
366342
# Perform regular unittest execution.
367343
payload = run_tests(

0 commit comments

Comments
 (0)