-
Notifications
You must be signed in to change notification settings - Fork 169
Handle a multi-line desc in R test explorer (on Windows)
#14336
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c84741c
Create a helper for escaping test description
jennybc 492cac3
Create a (partially failing) unit test
jennybc 8d6920b
Add e2e test for running multi-line desc test alone
jennybc 0c93a82
Trigger CI
jennybc 20ce423
Expand the set of characters that we escape to include newlines
jennybc 349ffce
Wait for the test explorer to be evident in the sidebar
jennybc 9326ff6
Multi-line test desc's seem to be normalized to `\n` in the reported …
jennybc a0254b7
Add an integration test for the parser fix
jennybc 273479a
Refine comments
jennybc 46f5055
Merge branch 'main' into r-test-explorer-multi-line-desc
jennybc 74de062
Rename to be more consistent with other test files
jennybc 81200ee
Merge branch 'main' into r-test-explorer-multi-line-desc
jennybc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
...ron-r/resources/testing/r.pkg.test.explorer.fixture/tests/testthat/test-multi-line-desc.R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| test_that("test_that with a | ||
| multi-line description passes", { | ||
| expect_equal(2 * 2, 4) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (C) 2026 Posit Software, PBC. All rights reserved. | ||
| * Licensed under the Elastic License 2.0. See LICENSE.txt for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import * as assert from 'assert'; | ||
| import { escapeLabelForRDesc } from '../testing/util-testing'; | ||
|
|
||
| suite('escapeLabelForRDesc', () => { | ||
| // Labels arrive LF-normalized from the parser; the escaper turns a multi-line | ||
| // description's newline into the `\n` escape so the R command stays one line (#10133). | ||
| const cases: Record<string, [input: string, expected: string]> = { | ||
| 'leaves a plain label untouched': ['plain label', 'plain label'], | ||
| 'escapes single quotes': ['it\'s fine', 'it\\\'s fine'], | ||
| 'escapes double quotes and backticks': ['a "b" `c`', 'a \\"b\\" \\`c\\`'], | ||
| 'escapes a LF newline': ['multi\nline', 'multi\\nline'], | ||
| }; | ||
|
|
||
| for (const [name, [input, expected]] of Object.entries(cases)) { | ||
| test(name, () => { | ||
| assert.strictEqual(escapeLabelForRDesc(input), expected); | ||
| }); | ||
| } | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,15 +23,19 @@ test.describe('R Test Explorer', { tag: [tags.TEST_EXPLORER, tags.R_PKG_DEVELOPM | |
| copyFixtureFolder(source, destination); | ||
| }); | ||
|
|
||
| test('Basic R Test Explorer Functionality', async function ({ app, openFolder }) { | ||
| test.beforeEach(async function ({ app, openFolder }) { | ||
| const { testExplorer, sessions } = app.workbench; | ||
|
|
||
| // Open the test fixture folder | ||
| await openFolder(FIXTURE_NAME); | ||
|
|
||
| // Open the test explorer, start R session, and run tests | ||
| await testExplorer.openTestExplorer(); | ||
| // Tests share one app instance; reset to a known state. | ||
| await testExplorer.collapseAllTests(); | ||
| await testExplorer.clearAllTestResults(); | ||
|
Comment on lines
+30
to
+32
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Beneficial once we go from 1 e2e to test to 2 and, before long, >2. |
||
| await sessions.start('r'); | ||
| }); | ||
|
|
||
| test('Basic R Test Explorer Functionality', async function ({ app }) { | ||
| const { testExplorer } = app.workbench; | ||
|
|
||
| await testExplorer.expectTestItems(['test-test-that.R', 'test-describe-it.R']); | ||
| await testExplorer.runAllTests(); | ||
|
|
||
|
|
@@ -53,4 +57,16 @@ test.describe('R Test Explorer', { tag: [tags.TEST_EXPLORER, tags.R_PKG_DEVELOPM | |
| await testExplorer.expectTestStatus('test_that number 1 passes', 'Passed'); | ||
| await testExplorer.expectTestStatus('test_that number 2 fails', 'Failed'); | ||
| }); | ||
|
|
||
| // https://github.com/posit-dev/positron/issues/10133 | ||
| test('Test with multi-line description can be run by itself', async function ({ app }) { | ||
| const { testExplorer } = app.workbench; | ||
| const MULTI_LINE_LABEL = 'test_that with a multi-line description passes'; | ||
|
|
||
| await testExplorer.expectTestItems(['test-multi-line-desc.R']); | ||
| await testExplorer.expandAllTests(); | ||
|
|
||
| await testExplorer.runTest(MULTI_LINE_LABEL); | ||
| await testExplorer.expectTestStatus(MULTI_LINE_LABEL, 'Passed', 60000); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switching to a less janky method of focusing the test explorer, while we're here.