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

feat: Add 'modulePaths' to test configuration #1329

Merged
merged 1 commit into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,30 @@
"description": "%configuration.java.test.config.classPaths.description%",
"default": []
},
"modulePaths": {
"type": "array",
"items": {
"anyOf": [
{
"enum": [
"$Auto",
"$Runtime",
"$Test",
"!<path>"
],
"enumDescriptions": [
"%configuration.java.test.config.modulePaths.auto.description%",
"%configuration.java.test.config.modulePaths.runtime.description%",
"%configuration.java.test.config.modulePaths.test.description%",
"%configuration.java.test.config.modulePaths.exclude.description%"
]
},
"string"
]
},
"description": "%configuration.java.test.config.modulePaths.description%",
"default": []
},
"vmArgs": {
"type": "array",
"items": {
Expand Down Expand Up @@ -280,6 +304,30 @@
"description": "%configuration.java.test.config.classPaths.description%",
"default": []
},
"modulePaths": {
"type": "array",
"items": {
"anyOf": [
{
"enum": [
"$Auto",
"$Runtime",
"$Test",
"!<path>"
],
"enumDescriptions": [
"%configuration.java.test.config.modulePaths.auto.description%",
"%configuration.java.test.config.modulePaths.runtime.description%",
"%configuration.java.test.config.modulePaths.test.description%",
"%configuration.java.test.config.modulePaths.exclude.description%"
]
},
"string"
]
},
"description": "%configuration.java.test.config.modulePaths.description%",
"default": []
},
"vmargs": {
"type": "array",
"items": {
Expand Down
7 changes: 6 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@
"configuration.java.test.config.item.description": "Specify the configuration item for running the tests",
"configuration.java.test.config.name.description": "Specify the name of the configuration item",
"configuration.java.test.config.workingDirectory.description": "Specify the working directory when running the tests",
"configuration.java.test.config.classPaths.description": "The classpath defined in this setting will be appended to the resolved classpath",
"configuration.java.test.config.classPaths.description": "The classpaths defined in this setting will be appended to the resolved classpaths",
"configuration.java.test.config.classPaths.auto.description": "Automatically resolve the classpaths of current project",
"configuration.java.test.config.classPaths.runtime.description": "The classpaths within 'runtime' scope of current project",
"configuration.java.test.config.classPaths.test.description": "The classpaths within 'test' scope of current project",
"configuration.java.test.config.classPaths.exclude.description": "The path after '!' will be excluded from the classpaths",
"configuration.java.test.config.modulePaths.description": "The modulepaths defined in this setting will be appended to the resolved modulepaths",
"configuration.java.test.config.modulePaths.auto.description": "Automatically resolve the modulepaths of current project",
"configuration.java.test.config.modulePaths.runtime.description": "The modulepaths within 'runtime' scope of current project",
"configuration.java.test.config.modulePaths.test.description": "The modulepaths within 'test' scope of current project",
"configuration.java.test.config.modulePaths.exclude.description": "The path after '!' will be excluded from the modulePaths",
"configuration.java.test.config.vmArgs.description": "Specify the extra options and system properties for the JVM",
"configuration.java.test.config.args.description": "Specify the command line arguments which will be passed to the test runner",
"configuration.java.test.config.env.description": "Specify the extra environment variables when running the tests",
Expand Down
5 changes: 5 additions & 0 deletions package.nls.zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
"configuration.java.test.config.classPaths.runtime.description": "当前工程中属于 runtime 作用域的类路径",
"configuration.java.test.config.classPaths.test.description": "当前工程中属于 test 作用域的类路径",
"configuration.java.test.config.classPaths.exclude.description": "'!' 之后的路径将会从类路径中去除",
"configuration.java.test.config.modulePaths.description": "通过该配置项设置的模块路径会被追加到自动解析的模块路径上",
"configuration.java.test.config.modulePaths.auto.description": "自动从当前工程中解析模块路径",
"configuration.java.test.config.modulePaths.runtime.description": "当前工程中属于 runtime 作用域的模块路径",
"configuration.java.test.config.modulePaths.test.description": "当前工程中属于 test 作用域的模块路径",
"configuration.java.test.config.modulePaths.exclude.description": "'!' 之后的路径将会从模块路径中去除",
"configuration.java.test.config.vmArgs.description": "设定启动 JVM 的额外选项和系统属性",
"configuration.java.test.config.args.description": "设定启动 Test Runner 时的命令行参数",
"configuration.java.test.config.env.description": "启动应用程序时自定义的环境变量",
Expand Down
19 changes: 17 additions & 2 deletions src/runConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,62 @@ export interface IExecutionConfig {
* @since 0.14.0
*/
name?: string;

/**
* The working directory when running the tests.
* @since 0.14.0
*/
workingDirectory?: string;

/**
* The classpath defined in this setting will be appended to the resolved classpath.
* The classpaths defined in this setting will be appended to the resolved classpaths.
* @since 0.33.0
*/
classPaths?: string[]
classPaths?: string[]

/**
* The modulepaths defined in this setting will be appended to the resolved modulepaths
* @since 0.33.0
*/
modulePaths?: string[]

/**
* The command line arguments which will be passed to the test runner.
* @since 0.14.0
*/
args?: any[];

/**
* the extra options and system properties for the JVM.
* It's deprecated, we should align with the debug launch configuration, which is 'vmArgs'.
* @since 0.14.0
*/
vmargs?: any[];

/**
* the extra options and system properties for the JVM.
* @since 0.14.0
*/
vmArgs?: any[];

/**
* The extra environment variables when running the tests.
* @since 0.25.0
*/
env?: { [key: string]: string; };

/**
* The absolute path to a file containing environment variable definitions.
* @since 0.33.0
*/
envFile?: string;

/**
* The extra source paths when debugging the tests
* @since 0.22.4
*/
sourcePaths?: string[];

/**
* The label of a task specified in tasks.json.
* @since 0.33.0
Expand Down
14 changes: 10 additions & 4 deletions src/utils/launchUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ export async function resolveLaunchConfigurationForRunner(runner: BaseRunner, te
cwd: config && config.workingDirectory ? config.workingDirectory : launchArguments.workingDirectory,
classPaths: [
...config?.classPaths || [],
...launchArguments.classpath,
...launchArguments.classpath || [],
path.join(extensionContext.extensionPath, 'server', 'com.microsoft.java.test.runner.jar'),
path.join(extensionContext.extensionPath, 'server', 'lib'),
],
modulePaths: launchArguments.modulepath,
modulePaths: [
...config?.modulePaths || [],
...launchArguments.modulepath || [],
],
args: runner.getApplicationArgs(config),
vmArgs: launchArguments.vmArguments,
env: config?.env,
Expand All @@ -56,9 +59,12 @@ export async function resolveLaunchConfigurationForRunner(runner: BaseRunner, te
cwd: config && config.workingDirectory ? config.workingDirectory : launchArguments.workingDirectory,
classPaths: [
...config?.classPaths || [],
...launchArguments.classpath,
...launchArguments.classpath || [],
],
modulePaths: [
...config?.modulePaths || [],
...launchArguments.modulepath || [],
],
modulePaths: launchArguments.modulepath,
args: launchArguments.programArguments,
vmArgs: launchArguments.vmArguments,
env: config?.env,
Expand Down
6 changes: 5 additions & 1 deletion test/suite/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ suite('JUnit Runner Analyzer Tests', () => {
"/a/b/c.jar",
"/foo/bar.jar"
],
modulePaths: [
"/test/module.jar",
],
env: {
test: "test",
},
Expand All @@ -57,8 +60,9 @@ suite('JUnit Runner Analyzer Tests', () => {
});
assert.strictEqual(configuration.env.test, "test");
assert.strictEqual(configuration.envFile, "${workspaceFolder}/.env");
assert.strictEqual(configuration.sourcePaths?.[0], "/a/b/c.jar");
assert.strictEqual(configuration.sourcePaths[0], "/a/b/c.jar");
assert.strictEqual(configuration.preLaunchTask, "test");
assert.strictEqual(configuration.modulePaths[0], "/test/module.jar");
assert.strictEqual(configuration.classPaths[0], "/a/b/c.jar");
assert.strictEqual(configuration.classPaths[1], "/foo/bar.jar");
});
Expand Down