Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run a runnable test item with a single non-runnable child #229120

Open
firelizzard18 opened this issue Sep 20, 2024 · 1 comment
Open

Can't run a runnable test item with a single non-runnable child #229120

firelizzard18 opened this issue Sep 20, 2024 · 1 comment
Assignees

Comments

@firelizzard18
Copy link

firelizzard18 commented Sep 20, 2024

Type: Bug

Using the testing API:

  1. Create run profile with tag id: runnable.
  2. Create test item A including tag id: runnable and add it to the root or some other collection.
  3. Create test item B without the runnable tag and add it as a child to A.
  4. Attempt to run test item A.

VS Code version: Code 1.93.1 (38c31bc, 2024-09-11T17:20:05.685Z)
OS version: Linux x64 6.6.21-gentoo
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i9-10850K CPU @ 3.60GHz (20 x 4799)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
webnn: disabled_off
Load (avg) 1, 1, 1
Memory (System) 62.61GB (50.72GB free)
Process Argv --ozone-platform-hint=auto --enable-wayland-ime --crash-reporter-id 217c2155-7214-48e7-83e7-a2317fced1b9
Screen Reader no
VM 0%
DESKTOP_SESSION plasma
XDG_CURRENT_DESKTOP KDE
XDG_SESSION_DESKTOP KDE
XDG_SESSION_TYPE wayland
Extensions (77)
Extension Author (truncated) Version
language-x86-64-assembly 13x 3.1.4
golangwithdidi ald 0.0.1
Bookmarks ale 13.5.0
chronicler arc 0.1.16
quitcontrol-vscode art 4.0.0
unique-lines bib 1.0.0
markdown-mermaid bie 1.25.0
esbuild-problem-matchers con 0.0.3
systemd-unit-file coo 1.0.6
vscode-eslint dba 3.0.10
xml Dot 2.5.1
udev-rules dpk 1.0.1
gitlens eam 15.5.1
permute-lines ear 1.1.0
EditorConfig Edi 0.16.4
prettier-vscode esb 11.0.0
go-notebook-kernel eth 0.2.0
go-playbooks eth 0.0.3
simple-notebook-renderers eth 0.1.1
vscode-firefox-debug fir 2.9.10
copilot Git 1.232.0
copilot-chat Git 0.20.3
remotehub Git 0.64.0
gitlab-workflow Git 5.12.0
gitpod-desktop git 0.0.174
go gol 0.42.1
vscode-graphql Gra 0.12.0
vscode-graphql-execution Gra 0.3.0
vscode-graphql-syntax Gra 1.3.6
vscode-test-explorer hbe 2.21.1
vscode-ansi ili 1.1.7
vscode-go-template jin 0.2.1
solidity Jua 0.0.176
vscode-clangd llv 0.1.29
bash-ide-vscode mad 1.42.0
rainbow-csv mec 3.12.0
template-string-converter meg 0.6.1
graphql mqu 0.1.2
vscode-docker ms- 1.29.1
csharp ms- 2.45.25
vscode-dotnet-runtime ms- 2.1.5
debugpy ms- 2024.10.0
python ms- 2024.14.1
vscode-pylance ms- 2024.9.1
jupyter ms- 2024.8.1
jupyter-keymap ms- 1.1.2
jupyter-renderers ms- 1.0.19
vscode-jupyter-cell-tags ms- 0.1.9
vscode-jupyter-slideshow ms- 0.1.6
remote-containers ms- 0.384.0
remote-ssh ms- 0.114.3
remote-ssh-edit ms- 0.86.0
cmake-tools ms- 1.19.52
hexeditor ms- 1.10.0
remote-explorer ms- 0.4.3
remote-repositories ms- 0.42.0
test-adapter-converter ms- 0.1.9
vscode-markdown-notebook ms- 0.0.26
vscode-serial-monitor ms- 0.13.1
wasm-dwarf-debugging ms- 1.0.1
vsliveshare ms- 1.0.5940
vsliveshare-pack ms- 0.4.0
linux-desktop-file nic 0.0.21
vscode-jest Ort 6.2.5
material-icon-theme PKi 5.10.0
vscode-xml red 0.27.1
vscode-yaml red 1.15.0
bash-beautify sha 0.1.1
shader sle 1.1.5
rewrap stk 1.16.3
code-spell-checker str 3.0.1
even-better-toml tam 0.19.2
vscode-tinygo tin 0.5.0
cmake twx 0.0.17
vscode-mdx uni 1.8.11
spice xua 0.1.0
vscode-proto3 zxh 0.5.5
@firelizzard18
Copy link
Author

I verified this in the extension host, and by debugging vscode with vscode and installing my extension as a VSIX into the running-in-a-debugger vscode. I generated the report from the host/top vscode which is why it shows all those extensions.

The behavior is coming from this function:

const attempt = (element: TestExplorerTreeElement, alreadyIncluded: boolean) => {
// sanity check hasElement since updates are debounced and they may exist
// but not be rendered yet
if (!(element instanceof TestItemTreeElement) || !this.viewModel.tree.hasElement(element)) {
return;
}
// If the current node is not visible or runnable in the current profile, it's excluded
const inTree = this.viewModel.tree.getNode(element);
if (!inTree.visible) {
if (alreadyIncluded) { exclude.push(element.test); }
return;
}
// If it's not already included but most of its children are, then add it
// if it can be run under the current profile (when specified)
if (
// If it's not already included...
!alreadyIncluded
// And it can be run using the current profile (if any)
&& (!profile || canUseProfileWithTest(profile, element.test))
// And either it's a leaf node or most children are included, the include it.
&& (inTree.children.length === 0 || inTree.visibleChildrenCount * 2 >= inTree.children.length)
// And not if we're only showing a single of its children, since it
// probably fans out later. (Worse case we'll directly include its single child)
&& inTree.visibleChildrenCount !== 1
) {
include.add(element.test);
alreadyIncluded = true;
}
// Recurse ✨
for (const child of element.children) {
attempt(child, alreadyIncluded);
}
};

I'm not going to pretend to understand why inTree.visibleChildrenCount !== 1 is there but the end result is that test item A does not get added to the include set. This is tolerable when test item B is runnable, because at the very least I can explicitly transform a request to run B into a request to run A, but if B is not runnable it just does nothing because the include set ends up empty and it never even calls the extension's run profile. Personally I don't like this behavior - if the user clicks run on test item A, then vscode should tell the extension "the user wishes to run test item A". But instead, the user clicks on A and vscode says "the user wishes to run B", which is surprising in a bad way to me. But ultimately, it wouldn't break anything for me except for the fact that this still happens when B is not runnable.

CC @connor4312

@firelizzard18 firelizzard18 changed the title testing: can't run a runnable test item with a single non-runnable child Can't run a runnable test item with a single non-runnable child Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants