-
Notifications
You must be signed in to change notification settings - Fork 129
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
Set which encoding your test JVM will start with #1735
Open
awilkins
wants to merge
8
commits into
microsoft:main
Choose a base branch
from
awilkins:feature/launch-encoding-for-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1eb57d6
Set which encoding your test JVM will start with
awilkins d2b54e1
Merge branch 'main' into feature/launch-encoding-for-tests
jdneo 84910ad
Added config description to package.json
007ac6b
Update the parts of package.json that the Maven build updates
87f239e
Change the case of the vmArgs property in the array type of config to…
awilkins cb75771
Add encoding to the array type of config as well
awilkins f2674b9
Remove handling of deprecated `vmargs` config item.
awilkins 9a5425a
Merge branch 'main' into feature/launch-encoding-for-tests
awilkins 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
This file contains 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 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 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 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 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 |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
'use strict'; | ||
|
||
import * as assert from 'assert'; | ||
|
||
import { TestController, TestRunRequest, tests, workspace } from 'vscode'; | ||
import { JUnitRunner } from '../../src/runners/junitRunner/JunitRunner'; | ||
import { resolveLaunchConfigurationForRunner } from '../../src/utils/launchUtils'; | ||
|
@@ -70,4 +71,40 @@ suite('JUnit Runner Analyzer Tests', () => { | |
assert.strictEqual(configuration.classPaths[1], "/foo/bar.jar"); | ||
assert.strictEqual(configuration.javaExec, "/usr/bin/java"); | ||
}); | ||
|
||
test("test launch encoding", async() => { | ||
const testItem = generateTestItem(testController, '[email protected]#latin1IsSet', TestKind.JUnit, undefined, '=junit/src\\/test\\/java=/optional=/true=/=/maven.pomderived=/true=/=/test=/true=/<junit4{TestAnnotation.java[TestEncoding~latin1IsSet'); | ||
const testRunRequest = new TestRunRequest([testItem], []); | ||
const testRun = testController.createTestRun(testRunRequest); | ||
const runnerContext: IRunTestContext = { | ||
isDebug: false, | ||
kind: TestKind.JUnit, | ||
projectName: 'junit', | ||
testItems: [testItem], | ||
testRun: testRun, | ||
workspaceFolder: workspace.workspaceFolders?.[0]!, | ||
}; | ||
const junitRunner = new JUnitRunner(runnerContext); | ||
const configuration = await resolveLaunchConfigurationForRunner(junitRunner, runnerContext, { | ||
classPaths: [ | ||
"/a/b/c.jar", | ||
"/foo/bar.jar" | ||
], | ||
env: { | ||
test: "test", | ||
}, | ||
envFile: "${workspaceFolder}/.env", | ||
encoding: "ISO-8859-1", | ||
javaExec: "/usr/bin/java", | ||
modulePaths: [ | ||
"/test/module.jar", | ||
], | ||
postDebugTask: "test", | ||
preLaunchTask: "test", | ||
sourcePaths: [ | ||
"/a/b/c.jar" | ||
] | ||
}); | ||
assert.strictEqual(configuration.encoding, "ISO-8859-1"); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
test/test-projects/junit/src/test/java/junit4/TestEncoding.java
This file contains 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,20 @@ | ||
package junit4; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.nio.charset.Charset; | ||
|
||
/** | ||
* The test case in this class will fail unless you set `java.test.config : encoding` to ISO-8859-1 | ||
*/ | ||
public class TestEncoding { | ||
@Test | ||
public void latin1IsSet() { | ||
assertEquals( | ||
"ISO-8859-1", | ||
Charset.defaultCharset().name() | ||
); | ||
} | ||
} |
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.
Since
java.test.config
can either be an array or an object. So we need to duplicated this underitem
section as well. (start from line 349)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.
Also noted, because they're right next to each other, that it's
vmargs
in the array andvmArgs
in the singular ; have changed the case of the array to match (this has been deprecated 4 years, I think it might have been long enough :-) )