-
Notifications
You must be signed in to change notification settings - Fork 60
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
tests/automation: XML generate automation #2716
Open
ilidio-lopes
wants to merge
1
commit into
eclipse-che4z:development
Choose a base branch
from
ilidio-lopes:tests/automation-XML-Generate
base: development
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.
+507
−0
Open
Changes from all commits
Commits
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
364 changes: 364 additions & 0 deletions
364
clients/cobol-lsp-vscode-extension/src/test/suite/lsp.spec.xmlgenerate.test.ts
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,364 @@ | ||
/* | ||
* Copyright (c) 2025 Broadcom. | ||
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Broadcom, Inc. - initial API and implementation | ||
*/ | ||
|
||
import * as assert from "assert"; | ||
import * as helper from "./testHelper"; | ||
import { pos } from "./testHelper"; | ||
import * as vscode from "vscode"; | ||
import * as path from "path"; | ||
|
||
suite("TF48417: XML GENERATE", function () { | ||
suiteSetup(async function () { | ||
this.timeout(0); | ||
this.slow(2000); | ||
await helper.updateConfig("basic.json"); | ||
await helper.activate(); | ||
}); | ||
|
||
this.afterEach(async () => await helper.closeAllEditors()).timeout( | ||
helper.TEST_TIMEOUT, | ||
); | ||
|
||
this.afterAll(async () => await helper.closeAllEditors()).timeout( | ||
helper.TEST_TIMEOUT, | ||
); | ||
|
||
test("TC369351: Identifier1 must be alphanumeric", async () => { | ||
const extSrcPath = path.join("TEST2.CBL"); | ||
const diagPromise = helper.waitForDiagnosticsChange(extSrcPath); | ||
await helper.showDocument(extSrcPath); | ||
const editor = helper.getEditor("TEST2.CBL"); | ||
let diagnostics = await diagPromise; | ||
await helper.insertString( | ||
editor, | ||
pos(19, 0), | ||
" 01 XML-DOC123 PIC X(5000) USAGE NATIONAL.\n", | ||
); | ||
await helper.deleteLine(editor, 23); | ||
await helper.waitFor( | ||
() => vscode.languages.getDiagnostics(editor.document.uri).length === 0, | ||
); | ||
diagnostics = vscode.languages.getDiagnostics(editor.document.uri); | ||
assert.strictEqual(diagnostics.length, 0); | ||
await helper.sleep(5000); | ||
}); | ||
|
||
test("TC369351: identifier1 must be category national, national group", async () => { | ||
const extSrcPath = path.join("TEST2.CBL"); | ||
const diagPromise = helper.waitForDiagnosticsChange(extSrcPath); | ||
await helper.showDocument(extSrcPath); | ||
const editor = helper.getEditor("TEST2.CBL"); | ||
let diagnostics = await diagPromise; | ||
await helper.insertString( | ||
editor, | ||
pos(19, 0), | ||
" 01 XML-DOC123 PIC X(5000) USAGE NATIONAL.\n" + | ||
" 01 REQUEST GROUP-USAGE NATIONAL.\n" + | ||
" 06 ROUTE.\n" + | ||
" 11 NAME PIC X(030).\n" + | ||
" 11 VERSION PIC 9(004).\n", | ||
); | ||
await helper.deleteLine(editor, 27); | ||
await helper.waitFor( | ||
() => vscode.languages.getDiagnostics(editor.document.uri).length === 0, | ||
); | ||
diagnostics = vscode.languages.getDiagnostics(editor.document.uri); | ||
assert.strictEqual(diagnostics.length, 0); | ||
await helper.sleep(5000); | ||
}); | ||
|
||
test("TC369351: Identifier1 must not overlap identifier2, identifier3, identifier4, identifier5.", async () => { | ||
const extSrcPath = path.join("TEST2.CBL"); | ||
const diagPromise = helper.waitForDiagnosticsChange(extSrcPath); | ||
await helper.showDocument(extSrcPath); | ||
const editor = helper.getEditor("TEST2.CBL"); | ||
let diagnostics = await diagPromise; | ||
await helper.deleteLine(editor, 22); | ||
await helper.insertString( | ||
editor, | ||
pos(19, 0), | ||
" 01 OutputXml.\n" + " 05 TestXmlTag PIC X(20).\n", | ||
); | ||
await helper.insertString( | ||
editor, | ||
pos(23, 0), | ||
" XML GENERATE OutputXml FROM TestXmlTag\n" + | ||
" END-XML.\n", | ||
); | ||
await helper.waitFor( | ||
() => vscode.languages.getDiagnostics(editor.document.uri).length === 1, | ||
); | ||
diagnostics = vscode.languages.getDiagnostics(editor.document.uri); | ||
assert.strictEqual(diagnostics.length, 1); | ||
const message = diagnostics[0].message; | ||
assert.match( | ||
message, | ||
/^XML generate TESTXMLTAG must not overlap OUTPUTXML/, | ||
); | ||
await helper.deleteLine(editor, 19); | ||
await helper.deleteLine(editor, 20); | ||
await helper.insertString( | ||
editor, | ||
pos(19, 0), | ||
" 01 TestXmlTag PIC X(20).\n" + | ||
" 01 OutputXml PIC X(100).\n", | ||
); | ||
await helper.waitFor( | ||
() => vscode.languages.getDiagnostics(editor.document.uri).length === 0, | ||
); | ||
diagnostics = vscode.languages.getDiagnostics(editor.document.uri); | ||
assert.strictEqual(diagnostics.length, 0); | ||
await helper.sleep(5000); | ||
}); | ||
|
||
test("TC369352: identifier2 references a national group item", async () => { | ||
const extSrcPath = path.join("TEST14.CBL"); | ||
const diagPromise = helper.waitForDiagnosticsChange(extSrcPath); | ||
await helper.showDocument(extSrcPath); | ||
const editor = helper.getEditor("TEST14.CBL"); | ||
let diagnostics = await diagPromise; | ||
await helper.insertString( | ||
editor, | ||
pos(10, 0), | ||
" 01 WS-ORDERS GROUP-USAGE NATIONAL.\n" + | ||
" 05 WS-ORDER OCCURS 2.\n" + | ||
" 10 WS-DATA usage NATIONAL PIC X(4096).\n" + | ||
" 01 WS-ORDERS.\n" + | ||
" 05 WS-ORDER OCCURS 2.\n" + | ||
" 10 WS-DATA USAGE NATIONAL PIC X(4096).\n", | ||
); | ||
await helper.deleteLine(editor, 22); | ||
await helper.waitFor( | ||
() => vscode.languages.getDiagnostics(editor.document.uri).length === 0, | ||
); | ||
diagnostics = vscode.languages.getDiagnostics(editor.document.uri); | ||
assert.strictEqual(diagnostics.length, 0); | ||
await helper.sleep(5000); | ||
}); | ||
|
||
test("TC369352: identifier2 must not overlap identifier1,or identifier3", async () => { | ||
const extSrcPath = path.join("TEST14.CBL"); | ||
const diagPromise = helper.waitForDiagnosticsChange(extSrcPath); | ||
await helper.showDocument(extSrcPath); | ||
const editor = helper.getEditor("TEST14.CBL"); | ||
let diagnostics = await diagPromise; | ||
await helper.deleteLine(editor, 16); | ||
await helper.waitFor( | ||
() => vscode.languages.getDiagnostics(editor.document.uri).length === 0, | ||
); | ||
diagnostics = vscode.languages.getDiagnostics(editor.document.uri); | ||
assert.strictEqual(diagnostics.length, 0); | ||
await helper.deleteLine(editor, 8); | ||
await helper.deleteLine(editor, 6); | ||
await helper.insertString( | ||
editor, | ||
pos(6, 0), | ||
" 05 DOC PIC X(512).", | ||
); | ||
await helper.waitFor( | ||
() => vscode.languages.getDiagnostics(editor.document.uri).length === 1, | ||
); | ||
diagnostics = vscode.languages.getDiagnostics(editor.document.uri); | ||
assert.strictEqual(diagnostics.length, 1); | ||
const message = diagnostics[0].message; | ||
assert.match(message, /^XML generate GREET must not overlap DOC/); | ||
await helper.sleep(5000); | ||
}); | ||
|
||
test("TC369354: must not overlap identifier1, identifier2, identifier4, or identifier5", async () => { | ||
const extSrcPath = path.join("TEST14.CBL"); | ||
const diagPromise = helper.waitForDiagnosticsChange(extSrcPath); | ||
await helper.showDocument(extSrcPath); | ||
const editor = helper.getEditor("TEST14.CBL"); | ||
let diagnostics = await diagPromise; | ||
await helper.deleteLine(editor, 16); | ||
await helper.waitFor( | ||
() => vscode.languages.getDiagnostics(editor.document.uri).length === 0, | ||
); | ||
diagnostics = vscode.languages.getDiagnostics(editor.document.uri); | ||
assert.strictEqual(diagnostics.length, 0); | ||
await helper.deleteLine(editor, 9); | ||
await helper.deleteLine(editor, 7); | ||
await helper.insertString( | ||
editor, | ||
pos(7, 0), | ||
" 05 DOC-LENGTH PIC 9(05).", | ||
); | ||
await helper.waitFor( | ||
() => vscode.languages.getDiagnostics(editor.document.uri).length === 1, | ||
); | ||
diagnostics = vscode.languages.getDiagnostics(editor.document.uri); | ||
assert.strictEqual(diagnostics.length, 1); | ||
const message = diagnostics[0].message; | ||
assert.match(message, /^XML generate DOC-LENGTH must not overlap GREET/); | ||
await helper.sleep(5000); | ||
}); | ||
|
||
test( | ||
"TC369355: COUNT IN phrase, " + | ||
"TC369360: NAMESPACE and NAMESPACE-PREFIX phrases", | ||
async () => { | ||
const extSrcPath = path.join("TEST14.CBL"); | ||
const diagPromise = helper.waitForDiagnosticsChange(extSrcPath); | ||
await helper.showDocument(extSrcPath); | ||
const editor = helper.getEditor("TEST14.CBL"); | ||
let diagnostics = await diagPromise; | ||
await helper.deleteLine(editor, 16); | ||
await helper.waitFor( | ||
() => vscode.languages.getDiagnostics(editor.document.uri).length === 0, | ||
); | ||
diagnostics = vscode.languages.getDiagnostics(editor.document.uri); | ||
assert.strictEqual(diagnostics.length, 0); | ||
await helper.sleep(5000); | ||
}, | ||
); | ||
|
||
test("TC369356: ENCODING phrase without codepage", async () => { | ||
const extSrcPath = path.join("TEST61.CBL"); | ||
const diagPromise = helper.waitForDiagnosticsChange(extSrcPath); | ||
await helper.showDocument(extSrcPath); | ||
const editor = helper.getEditor("TEST61.CBL"); | ||
await helper.deleteLine(editor, 11); | ||
await helper.insertString(editor, pos(11, 0), " WITH ENCODING"); | ||
let diagnostics = await diagPromise; | ||
await helper.waitFor( | ||
() => vscode.languages.getDiagnostics(editor.document.uri).length === 1, | ||
); | ||
diagnostics = vscode.languages.getDiagnostics(editor.document.uri); | ||
assert.strictEqual(diagnostics.length, 1); | ||
await helper.sleep(5000); | ||
}); | ||
|
||
test("TC369358: XML-DECLARATION phrase", async () => { | ||
const extSrcPath = path.join("TEST61.CBL"); | ||
const diagPromise = helper.waitForDiagnosticsChange(extSrcPath); | ||
await helper.showDocument(extSrcPath); | ||
const editor = helper.getEditor("TEST61.CBL"); | ||
await helper.deleteLine(editor, 11); | ||
await helper.deleteLine(editor, 12); | ||
let diagnostics = await diagPromise; | ||
await helper.waitFor( | ||
() => vscode.languages.getDiagnostics(editor.document.uri).length === 1, | ||
); | ||
diagnostics = vscode.languages.getDiagnostics(editor.document.uri); | ||
assert.strictEqual(diagnostics.length, 1); | ||
await helper.insertString( | ||
editor, | ||
pos(11, 0), | ||
" WITH XML-DECLARATION.", | ||
); | ||
await helper.waitFor( | ||
() => vscode.languages.getDiagnostics(editor.document.uri).length === 0, | ||
); | ||
diagnostics = vscode.languages.getDiagnostics(editor.document.uri); | ||
assert.strictEqual(diagnostics.length, 0); | ||
await helper.sleep(5000); | ||
}); | ||
|
||
test("TC369359: ATTRIBUTES phrase", async () => { | ||
const extSrcPath = path.join("TEST51.CBL"); | ||
const diagPromise = helper.waitForDiagnosticsChange(extSrcPath); | ||
await helper.showDocument(extSrcPath); | ||
const editor = helper.getEditor("TEST51.CBL"); | ||
await helper.deleteLine(editor, 12); | ||
let diagnostics = await diagPromise; | ||
await helper.waitFor( | ||
() => vscode.languages.getDiagnostics(editor.document.uri).length === 1, | ||
); | ||
diagnostics = vscode.languages.getDiagnostics(editor.document.uri); | ||
assert.strictEqual(diagnostics.length, 1); | ||
await helper.insertString( | ||
editor, | ||
pos(12, 0), | ||
" 01 XML-OUT PIC X(200).", | ||
); | ||
await helper.waitFor( | ||
() => vscode.languages.getDiagnostics(editor.document.uri).length === 0, | ||
); | ||
diagnostics = vscode.languages.getDiagnostics(editor.document.uri); | ||
assert.strictEqual(diagnostics.length, 0); | ||
await helper.sleep(5000); | ||
}); | ||
|
||
test("TC369361: NAME phrase", async () => { | ||
const extSrcPath = path.join("TEST15.CBL"); | ||
const diagPromise = helper.waitForDiagnosticsChange(extSrcPath); | ||
await helper.showDocument(extSrcPath); | ||
const editor = helper.getEditor("TEST15.CBL"); | ||
await helper.deleteLine(editor, 10); | ||
let diagnostics = await diagPromise; | ||
await helper.waitFor( | ||
() => vscode.languages.getDiagnostics(editor.document.uri).length === 2, | ||
); | ||
diagnostics = vscode.languages.getDiagnostics(editor.document.uri); | ||
assert.strictEqual(diagnostics.length, 2); | ||
await helper.insertString( | ||
editor, | ||
pos(10, 0), | ||
" 05 abc PIC x(3) value spaces.", | ||
); | ||
await helper.waitFor( | ||
() => vscode.languages.getDiagnostics(editor.document.uri).length === 0, | ||
); | ||
diagnostics = vscode.languages.getDiagnostics(editor.document.uri); | ||
assert.strictEqual(diagnostics.length, 0); | ||
await helper.sleep(5000); | ||
}); | ||
|
||
test("TC369362: TYPE phrase", async () => { | ||
const extSrcPath = path.join("TEST16.CBL"); | ||
const diagPromise = helper.waitForDiagnosticsChange(extSrcPath); | ||
await helper.showDocument(extSrcPath); | ||
const editor = helper.getEditor("TEST16.CBL"); | ||
await helper.deleteLine(editor, 8); | ||
let diagnostics = await diagPromise; | ||
await helper.waitFor( | ||
() => vscode.languages.getDiagnostics(editor.document.uri).length === 1, | ||
); | ||
diagnostics = vscode.languages.getDiagnostics(editor.document.uri); | ||
assert.strictEqual(diagnostics.length, 1); | ||
await helper.insertString(editor, pos(8, 0), " 01 Doc pic X(500)."); | ||
await helper.waitFor( | ||
() => vscode.languages.getDiagnostics(editor.document.uri).length === 0, | ||
); | ||
diagnostics = vscode.languages.getDiagnostics(editor.document.uri); | ||
assert.strictEqual(diagnostics.length, 0); | ||
await helper.sleep(5000); | ||
}); | ||
|
||
test("TC369363: SUPPRESS, generic-suppression-phrase, ON EXCEPTION, NOT ON EXCEPTION phrase", async () => { | ||
const extSrcPath = path.join("TEST10.CBL"); | ||
const diagPromise = helper.waitForDiagnosticsChange(extSrcPath); | ||
await helper.showDocument(extSrcPath); | ||
const editor = helper.getEditor("TEST10.CBL"); | ||
await helper.deleteLine(editor, 16); | ||
let diagnostics = await diagPromise; | ||
await helper.waitFor( | ||
() => vscode.languages.getDiagnostics(editor.document.uri).length === 3, | ||
); | ||
diagnostics = vscode.languages.getDiagnostics(editor.document.uri); | ||
assert.strictEqual(diagnostics.length, 3); | ||
await helper.insertString( | ||
editor, | ||
pos(16, 0), | ||
" 01 OUTPUT-XML PIC X(5000).", | ||
); | ||
await helper.waitFor( | ||
() => vscode.languages.getDiagnostics(editor.document.uri).length === 0, | ||
); | ||
diagnostics = vscode.languages.getDiagnostics(editor.document.uri); | ||
assert.strictEqual(diagnostics.length, 0); | ||
await helper.sleep(5000); | ||
}); | ||
}); |
Oops, something went wrong.
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.
The statement is not related, however it must be deleted because of TEST2.cbl content. which has been selected that It is the closest one to the template. Consider creating a template to remove these operations.