Skip to content

Commit f103a3b

Browse files
authored
Fix missing pp exec when plugin config is missing (#782)
Signed-off-by: Steven Smyth <steven.smyth@typefox.io>
1 parent 0ed2515 commit f103a3b

5 files changed

Lines changed: 95 additions & 13 deletions

File tree

packages/language/src/preprocessor/compiler-options/translate.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
*
1010
*/
1111

12-
import { CompilerOptionResult, CompilerOptionsPP } from "./options";
12+
import {
13+
CompilerOptionResult,
14+
CompilerOptionsPP,
15+
getDefaultCompilerOptions,
16+
} from "./options";
1317
import {
1418
AbstractCompilerOptions,
1519
parseAbstractCompilerOptions,
@@ -42,11 +46,7 @@ export class CompilerOptionTranslator {
4246
protected translatorSQL = getTranslatorSQL();
4347

4448
protected result: CompilerOptionResult = {
45-
options: {
46-
...({} as CompilerOptionsPLI),
47-
macroOptions: {} as CompilerOptionsMacro,
48-
sqlOptions: {} as CompilerOptionsSQL,
49-
},
49+
options: getDefaultCompilerOptions(),
5050
tokens: [],
5151
comments: [],
5252
issues: [],
@@ -111,14 +111,9 @@ export class CompilerOptionTranslator {
111111
this.translatorMacro.clear();
112112
this.translatorSQL.clear();
113113
this.result = {
114-
options: {
115-
...({} as CompilerOptionsPLI),
116-
macroOptions: {} as CompilerOptionsMacro,
117-
sqlOptions: {} as CompilerOptionsSQL,
118-
},
114+
options: getDefaultCompilerOptions(),
119115
tokens: [],
120116
comments: [],
121-
122117
issues: [],
123118
};
124119
}

packages/language/test/fourslash-harness/execute.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ function runSingleHarnessTest(filePath: string, timeout = 10_000) {
190190
// can be exercised by harness tests. The afterEach hook above resets
191191
// the workspace config between tests, so this can't leak across tests.
192192
preservePluginConfiguration: true,
193+
// Skip default config creation if @noDefaultConfig directive is present
194+
noDefaultConfig: testFile.tags["noDefaultConfig"] === "true",
193195
});
194196
implementation = createTestBuilderHarnessImplementation(testBuilder);
195197
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* This program and the accompanying materials are made available under the terms of the
3+
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
4+
* https://www.eclipse.org/legal/epl-v20.html
5+
*
6+
* SPDX-License-Identifier: EPL-2.0
7+
*
8+
* Copyright Contributors to the Zowe Project.
9+
*
10+
*/
11+
12+
/// <reference path="../../framework.ts" />
13+
14+
// Regression test: EXEC SQL should work without config files or *PROCESS directive.
15+
// The default PP(MACRO SQL CICS) should be applied automatically.
16+
17+
// @noDefaultConfig
18+
//// HELLO: PROCEDURE OPTIONS (MAIN);
19+
//// DCL PROGNAME CHAR(100);
20+
//// EXEC CICS LINK PROGRAM(PROGNAME);
21+
//// END HELLO;
22+
23+
// If EXEC CICS is NOT processed, the EXEC token remains and we get a parser error.
24+
// If it IS processed, EXEC is replaced with DO; END; and DFHEIBLK is declared.
25+
preprocessor.containsTokens(["DFHEIBLK", "DFHEIPTR"]);
26+
verify.noDiagnostics();
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* This program and the accompanying materials are made available under the terms of the
3+
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
4+
* https://www.eclipse.org/legal/epl-v20.html
5+
*
6+
* SPDX-License-Identifier: EPL-2.0
7+
*
8+
* Copyright Contributors to the Zowe Project.
9+
*
10+
*/
11+
12+
/// <reference path="../../framework.ts" />
13+
14+
// Regression test: EXEC SQL should work without config files or *PROCESS directive.
15+
// The default PP(MACRO SQL CICS) should be applied automatically.
16+
17+
// @noDefaultConfig
18+
//// SQLTEST: PROCEDURE OPTIONS (MAIN);
19+
//// EXEC SQL BEGIN DECLARE SECTION;
20+
//// DCL EMPNO CHAR(6);
21+
//// EXEC SQL END DECLARE SECTION;
22+
//// END SQLTEST;
23+
24+
// If EXEC SQL is NOT processed, the parser fails with "Expected ... but found EXEC"
25+
// If it IS processed, the EXEC SQL statements are replaced with DO; END;
26+
preprocessor.containsTokens([
27+
"SQLTEST",
28+
":",
29+
"PROCEDURE",
30+
"OPTIONS",
31+
"(",
32+
"MAIN",
33+
")",
34+
";",
35+
"DCL",
36+
"EMPNO",
37+
"CHAR",
38+
"DO",
39+
";",
40+
"END",
41+
";",
42+
"END",
43+
"SQLTEST",
44+
";",
45+
]);
46+
verify.noDiagnostics();

packages/language/test/test-builder.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ export type TestBuilderOptions = {
103103
* preservePluginConfiguration can be used to disable this behavior for other test cases.
104104
*/
105105
preservePluginConfiguration?: boolean;
106+
107+
/**
108+
* Skip creating default plugin configuration files (pgm_conf.json, proc_grps.json).
109+
* Used to test scenarios where no configuration exists.
110+
* Corresponds to the fourslash directive: // @noDefaultConfig
111+
*/
112+
noDefaultConfig?: boolean;
106113
};
107114

108115
type LinkingRequest = {
@@ -291,7 +298,7 @@ export class TestBuilder extends AbstractTestBuilder {
291298
/**
292299
* Configures the plugin configuration provider based on the test files.
293300
* If a file for either the program or process group configuration is found, use it.
294-
* If not, provide a default configuration.
301+
* If not, provide a default configuration (unless noDefaultConfig is set).
295302
* Ensures we have a proper config after writing all files to the fs & before parsing,
296303
* so that we can build $computedLibs correctly
297304
*/
@@ -313,6 +320,12 @@ export class TestBuilder extends AbstractTestBuilder {
313320
? UriUtils.dirname(UriUtils.dirname(UriUtils.toUri(pgmConfUri)))
314321
: config.getWorkspacePath();
315322

323+
// Skip default config creation if noDefaultConfig is set
324+
if (this.options.noDefaultConfig) {
325+
await defaultTestWorkspace().config.init(workspaceUri);
326+
return;
327+
}
328+
316329
if (!pgmConfUri) {
317330
await defaultTestWorkspace().config.writeProgramConfigFile(
318331
PluginConfiguration.DEFAULT_PROGRAM_FILE_CONTENT,

0 commit comments

Comments
 (0)