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

Fix some errors not matched by problem matcher #54

53 changes: 40 additions & 13 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,16 @@
"autoDetect",
"${cwd}"
],
"pattern": {
"regexp": "^.*ParseError (at|in) (.+?):(\\d+)?:? (.+)$",
"file": 2,
"line": 3,
"message": 4
}
"pattern": [
{
"regexp": "^.*ParseError (at|in) (.+?):(\\d+)?:? (unparsed line: '(.+)')$",
deribaucourt marked this conversation as resolved.
Show resolved Hide resolved
"file": 2,
"line": 3,
"message": 4,
"code": 5,
"column": 0
}
]
},
{
"name": "bitbake-UnableToParse",
Expand All @@ -221,9 +225,10 @@
"${cwd}"
],
"pattern": {
"regexp": "^ERROR: (Unable to parse) (.+)$",
"file": 2,
"message": 1,
"regexp": "(ERROR): (Unable to parse (.+))$",
"severity": 1,
"file": 3,
"message": 2,
"kind": "File"
}
},
Expand All @@ -236,28 +241,44 @@
"${cwd}"
],
"pattern": {
"regexp": "^Parsing recipes...(ERROR): (.+?): (.*?) file: (.+) line: (\\d+) (.*)$",
"regexp": "(^Parsing recipes...)?(ERROR): (.+?): (.*?) file: (.+) line: (\\d+) (.*)$",
"file": 2,
"line": 5,
"severity": 1,
"message": 6
}
},
{
"name": "bitbake-generic",
"name": "bitbake-compilation-python-function",
"source": "bitbake",
"owner": "bitbake",
"fileLocation": [
"autoDetect",
"${cwd}"
],
"pattern": {
"regexp": "^Parsing recipes...(ERROR): (.+?): (.*)$",
"regexp": "(ERROR): (.+): (Error in compiling python function) in (.*), line (\\d+):$",
"file": 2,
"severity": 1,
"line": 5,
"message": 3
}
},
{
"name": "bitbake-execution-error",
"source": "bitbake",
"owner": "bitbake",
"fileLocation": [
"autoDetect",
"${cwd}"
],
"pattern": {
"regexp": "(^Parsing recipes...)?(ERROR): (.+?): (.*):?$",
"file": 3,
"severity": 2,
"message": 4
}
},
{
"name": "bitbake-task-error",
"source": "bitbake",
Expand Down Expand Up @@ -307,6 +328,7 @@
{
"command": "bitbake.watch-recipe",
"title": "BitBake: Add a recipe to the active workspace",
"icon": "$(add)",
"description": "Start watching or suggesting a recipe in bitbake commands."
},
{
Expand Down Expand Up @@ -440,9 +462,14 @@
],
"view/title": [
{
"command": "bitbake.rescan-project",
"command": "bitbake.watch-recipe",
"group": "navigation@0",
"when": "view == bitbakeRecipes"
},
{
"command": "bitbake.rescan-project",
"group": "navigation@1",
"when": "view == bitbakeRecipes"
}
],
"view/item/context": [
Expand Down
2 changes: 1 addition & 1 deletion client/src/ui/BitbakeTaskProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class BitbakeTaskProvider implements vscode.TaskProvider {
this.bitbakeDriver.composeBitbakeScript(bitbakeCommand))
return pty
}),
['$bitbake-ParseError', '$bitbake-Variable', '$bitbake-generic', '$bitbake-task-error', '$bitbake-UnableToParse']
['$bitbake-ParseError', '$bitbake-Variable', '$bitbake-compilation-python-function', '$bitbake-execution-error', '$bitbake-task-error', '$bitbake-UnableToParse']
)
if ((bitbakeTaskDefinition.task === undefined || bitbakeTaskDefinition.task.includes('build')) &&
bitbakeTaskDefinition.options?.parseOnly !== true) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ERROR: [file-path]: Error in compiling python function in [file-path], line [line-number]:
# [multiline-error-info]
# SyntaxError: [error-reason] ([file-name], line [line-number])
python() {
garbage(code
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# ERROR: [file-path]: Error executing a python function in <code>:
# [multiline-error-info]
# Exception: TypeError: [error-reason]
LICENSE="GPL-2.0-only"
python() {
'2' + 2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# When .vscode/tasks.json has the following entry:
# {
# "tasks": [
# {
# "type":"bitbake",
# "recipes": ["base-files"],
# }
# ]
# }

#ERROR: Task ([file-path]:do_install) failed with exit code '1'
do_install:append () {
bbfatal should crash
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# WARNING: [file-path]: Error during finalise of [file-path]
# ERROR: Unable to parse [file-path]
# [multiline-error-info]
# SyntaxError: [error-reason]
LICENSE="GPL-2.0-only"
python do_compile() {
garbage(code
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# NOTE:
WilsonZiweiWang marked this conversation as resolved.
Show resolved Hide resolved
# Some error lines start with 'Parsing recipes...' but sometimes these words appear on a different line than the ones with 'ERROR:'
# Hence do not use '^Parsing recipes...' as part of the regex

# ERROR: ParseError at [file-path]:[line-number]: unparsed line: 'undefinedvariable'
undefinedvariable
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# ERROR: Variable BB_ENV_EXTRAWHITE has been renamed to BB_ENV_PASSTHROUGH_ADDITIONS (file: [file-path] line: [line-number])
BB_ENV_EXTRAWHITE = "deprecated var"
22 changes: 21 additions & 1 deletion integration-tests/src/tests/bitbake-parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as assert from 'assert'
import * as vscode from 'vscode'

import path from 'path'
import { BITBAKE_TIMEOUT, addLayer, awaitBitbakeParsingResult, resetLayer } from '../utils/bitbake'
import { BITBAKE_TIMEOUT, addLayer, excludeRecipes, resetExcludedRecipes, awaitBitbakeParsingResult, resetLayer } from '../utils/bitbake'
import { assertWorkspaceWillBeOpen, delay } from '../utils/async'

suite('Bitbake Parsing Test Suite', () => {
Expand Down Expand Up @@ -42,20 +42,40 @@ suite('Bitbake Parsing Test Suite', () => {
}).timeout(BITBAKE_TIMEOUT)

test('Bitbake can detect parsing errors', async () => {
const recipesToExclude: string[] = [
'recipes-error/error/compilation-python-function.bb',
'recipes-error/error/execution-python-function.bb',
'recipes-error/error/unable-to-parse.bb',
'recipes-error/error/unparsed-line.bb',
'recipes-error/error/task-error.bb',
'recipes-error/error/variable-error.bb'
]

const workspacePath: string = workspaceURI.fsPath
await addLayer(path.resolve(__dirname, '../../project-folder/sources/meta-error'), workspacePath)

// Everything is excluded except the one that is filtered out
await excludeRecipes(recipesToExclude.filter((recipe) => recipe !== 'recipes-error/error/unparsed-line.bb'), workspacePath)

await vscode.commands.executeCommand('bitbake.parse-recipes')
await awaitBitbakeParsingResult()

await resetLayer(path.resolve(__dirname, '../../project-folder/sources/meta-error'), workspacePath)

await resetExcludedRecipes(workspacePath)

// Wait for the diagnostics to be updated. Another method would be to use
// the onDidChangeDiagnostics event, but it is not useful with the other test
// that checks for no diagnostics.
await delay(500)

const diagnostics = vscode.languages.getDiagnostics()
// Only 1 file has problem(s)
assert.strictEqual(diagnostics.length, 1)
// Only 1 problem on the file
assert.strictEqual(diagnostics[0][1].length, 1)

assert.ok(diagnostics[0][0].path.includes('recipes-error/error/unparsed-line.bb'))
assert.ok(diagnostics[0][1][0].message.includes('unparsed line: \'undefinedvariable\''))
}).timeout(BITBAKE_TIMEOUT)
})
32 changes: 28 additions & 4 deletions integration-tests/src/utils/bitbake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ export const BITBAKE_TIMEOUT = 300000

// TODO If bitbake-layers vscode commands are added in the future, use them instead
export async function addLayer (layer: string, workspaceFolder: string): Promise<void> {
const buildFolder = vscode.Uri.joinPath(vscode.Uri.file(workspaceFolder), 'build')
const bblayersConf = vscode.Uri.joinPath(buildFolder, 'conf/bblayers.conf')
const bblayersConf = getBBlayersConfUri(workspaceFolder)
const bblayersConfContent = await vscode.workspace.fs.readFile(bblayersConf)
let fileContent = bblayersConfContent.toString()
fileContent += `\nBBLAYERS+="${layer}"\n`
Expand All @@ -20,8 +19,7 @@ export async function addLayer (layer: string, workspaceFolder: string): Promise

// Replace with remove-layer command if available
export async function resetLayer (layer: string, workspaceFolder: string): Promise<void> {
const buildFolder = vscode.Uri.joinPath(vscode.Uri.file(workspaceFolder), 'build')
const bblayersConf = vscode.Uri.joinPath(buildFolder, 'conf/bblayers.conf')
const bblayersConf = getBBlayersConfUri(workspaceFolder)
const bblayersConfContent = await vscode.workspace.fs.readFile(bblayersConf)

// Remove last line
Expand All @@ -42,3 +40,29 @@ export async function awaitBitbakeParsingResult (): Promise<void> {
await assertWillComeTrue(async () => taskExecuted)
disposable.dispose()
}

export async function excludeRecipes (recipes: string[], workspaceFolder: string): Promise<void> {
const bblayersConfUri = getBBlayersConfUri(workspaceFolder)
const bblayersConfContent = await vscode.workspace.fs.readFile(bblayersConfUri)
let fileContent = bblayersConfContent.toString()
for (const recipe of recipes) {
fileContent += `\nBBMASK+="${recipe}"\n`
}
await vscode.workspace.fs.writeFile(bblayersConfUri, Buffer.from(fileContent))
}

export async function resetExcludedRecipes (workspaceFolder: string): Promise<void> {
const bblayersConfUri = getBBlayersConfUri(workspaceFolder)
const bblayersConfContent = await vscode.workspace.fs.readFile(bblayersConfUri)

const lines = bblayersConfContent.toString().split('\n')
const fileContentWithoutBBMASK = lines.filter((line) => (
!line.includes('BBMASK')
)).join('\n')
await vscode.workspace.fs.writeFile(bblayersConfUri, Buffer.from(fileContentWithoutBBMASK))
}

function getBBlayersConfUri (workspaceFolder: string): vscode.Uri {
const buildFolder = vscode.Uri.joinPath(vscode.Uri.file(workspaceFolder), 'build')
return vscode.Uri.joinPath(buildFolder, 'conf/bblayers.conf')
}
2 changes: 1 addition & 1 deletion server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ documents.onDidChangeContent(async (event) => {

documents.onDidSave(async (event) => {
if (parseOnSave && !eSDKMode) {
logger.debug(`onDidSave ${JSON.stringify(event)}`)
logger.debug('[onDidSave] Parsing all recipes...')
void connection.sendRequest('bitbake/parseAllRecipes')
}
})
Expand Down
Loading