Skip to content

Commit

Permalink
Fix: Update tests for BitbakeTerminal
Browse files Browse the repository at this point in the history
Commands are not executed through tasks anymore. Instead, a terminal is
created.
  • Loading branch information
deribaucourt committed Dec 15, 2023
1 parent 0d6ce25 commit ca36c18
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 40 deletions.
1 change: 1 addition & 0 deletions __mocks__/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const languages = {
createWebviewPanel: jest.fn(),
registerTreeDataProvider: jest.fn(),
createTreeView: jest.fn(),
createTerminal: jest.fn(),
};

const workspace = {
Expand Down
51 changes: 11 additions & 40 deletions integration-tests/src/tests/bitbake-commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@
import * as assert from 'assert'
import * as vscode from 'vscode'
import { afterEach } from 'mocha'
import { delay } from '../utils/async'
import { assertWillComeTrue, assertWorkspaceWillBeOpen } from '../utils/async'

suite('Bitbake Commands Test Suite', () => {
let disposables: vscode.Disposable[] = []

suiteSetup(async function (this: Mocha.Context) {
this.timeout(10000)
while (vscode.workspace.workspaceFolders === undefined || vscode.workspace.workspaceFolders?.length === 0) {
await delay(100)
}
await assertWorkspaceWillBeOpen()
})

afterEach(function () {
Expand All @@ -35,43 +33,19 @@ suite('Bitbake Commands Test Suite', () => {
})

test('Bitbake can run a task', async () => {
let taskExecuted = false

disposables.push(vscode.tasks.onDidEndTask(async (e) => {
if (e.execution.task.definition.recipes !== undefined && e.execution.task.definition.recipes[0] === 'base-files') {
assert.strictEqual(e.execution.task.definition.task, 'unpack')
taskExecuted = true
}
}))

await vscode.commands.executeCommand('bitbake.run-task', 'base-files', 'unpack')
// eslint-disable-next-line no-unmodified-loop-condition
while (!taskExecuted) {
await delay(100)
}

const files = await vscode.workspace.findFiles('build/tmp/work/*/base-files/*/issue')
assert.strictEqual(files.length, 1)
await assertWillComeTrue(async () => {
const files = await vscode.workspace.findFiles('build/tmp/work/*/base-files/*/issue')
return files.length === 1
})
}).timeout(300000)

test('Bitbake can clean a recipe', async () => {
let taskExecuted = false

disposables.push(vscode.tasks.onDidEndTask(async (e) => {
if (e.execution.task.definition.recipes !== undefined && e.execution.task.definition.recipes[0] === 'base-files') {
assert.strictEqual(e.execution.task.definition.task, 'clean')
taskExecuted = true
}
}))

await vscode.commands.executeCommand('bitbake.clean-recipe', 'base-files')
// eslint-disable-next-line no-unmodified-loop-condition
while (!taskExecuted) {
await delay(100)
}

const files = await vscode.workspace.findFiles('build/tmp/work/*/base-files')
assert.strictEqual(files.length, 0)
await assertWillComeTrue(async () => {
const files = await vscode.workspace.findFiles('build/tmp/work/*/base-files')
return files.length === 0
})
}).timeout(300000)

test('Bitbake can run from task.json', async () => {
Expand All @@ -90,10 +64,7 @@ suite('Bitbake Commands Test Suite', () => {
await vscode.tasks.executeTask(task)
}
}
// eslint-disable-next-line no-unmodified-loop-condition
while (!taskExecuted) {
await delay(100)
}
await assertWillComeTrue(async () => taskExecuted)

const files = await vscode.workspace.findFiles('build/tmp/work/*/base-files/*/temp/log.do_fetch')
assert.strictEqual(files.length, 1)
Expand Down

0 comments on commit ca36c18

Please sign in to comment.