Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4217c00

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
fix: add missing installed version to the platform
Closes #2378 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent a088ba9 commit 4217c00

File tree

2 files changed

+62
-7
lines changed

2 files changed

+62
-7
lines changed

‎arduino-ide-extension/src/node/boards-service-impl.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ILogger } from '@theia/core/lib/common/logger';
22
import { nls } from '@theia/core/lib/common/nls';
33
import { notEmpty } from '@theia/core/lib/common/objects';
4+
import { Mutable } from '@theia/core/lib/common/types';
45
import { inject, injectable } from '@theia/core/shared/inversify';
56
import {
67
BoardDetails,
@@ -592,7 +593,7 @@ function createBoardsPackage(
592593
const availableVersions = Array.from(versionReleaseMap.keys())
593594
.sort(Installable.Version.COMPARATOR)
594595
.reverse();
595-
return {
596+
constboardsPackage: Mutable<BoardsPackage>= {
596597
id,
597598
name,
598599
summary: nls.localize(
@@ -607,6 +608,10 @@ function createBoardsPackage(
607608
deprecated,
608609
availableVersions,
609610
};
611+
if (summary.installedVersion) {
612+
boardsPackage.installedVersion = summary.installedVersion;
613+
}
614+
return boardsPackage;
610615
}
611616

612617
type PlatformSummaryWithMetadata = PlatformSummary.AsObject &

‎arduino-ide-extension/src/test/node/boards-service-impl.slow-test.ts‎

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
import { DisposableCollection } from '@theia/core/lib/common/disposable';
1+
import {
2+
Disposable,
3+
DisposableCollection,
4+
} from '@theia/core/lib/common/disposable';
25
import { Container } from '@theia/core/shared/inversify';
36
import { expect } from 'chai';
4-
import { BoardSearch, BoardsService, Installable } from '../../common/protocol';
7+
import { promises as fs } from 'node:fs';
8+
import path from 'node:path';
9+
import temp from 'temp';
10+
import {
11+
BoardSearch,
12+
BoardsPackage,
13+
BoardsService,
14+
Installable,
15+
} from '../../common/protocol';
516
import { createBaseContainer, startDaemon } from './node-test-bindings';
617

718
describe('boards-service-impl', () => {
@@ -10,8 +21,12 @@ describe('boards-service-impl', () => {
1021

1122
before(async function () {
1223
this.timeout(20_000);
13-
toDispose = new DisposableCollection();
14-
const container = await createContainer();
24+
const tracked = temp.track();
25+
toDispose = new DisposableCollection(
26+
Disposable.create(() => tracked.cleanupSync())
27+
);
28+
const testDirPath = tracked.mkdirSync();
29+
const container = await createContainer(testDirPath);
1530
await start(container, toDispose);
1631
boardService = container.get<BoardsService>(BoardsService);
1732
});
@@ -110,10 +125,45 @@ describe('boards-service-impl', () => {
110125
expect(first.deprecated).to.be.false;
111126
});
112127
});
128+
129+
it('should have the installed version set', async function () {
130+
const timeout = 5 * 60 * 1_000; // five minutes to install/uninstall the core
131+
this.timeout(timeout);
132+
133+
// ensure installed
134+
let result = await boardService.search({ query: 'arduino:avr' });
135+
let avr = result.find(
136+
(boardsPackage) => boardsPackage.id === 'arduino:avr'
137+
);
138+
expect(avr).to.be.not.undefined;
139+
await boardService.install({
140+
item: <BoardsPackage>avr,
141+
skipPostInstall: true,
142+
});
143+
144+
// when installed the version is set
145+
result = await boardService.search({ query: 'arduino:avr' });
146+
avr = result.find((boardsPackage) => boardsPackage.id === 'arduino:avr');
147+
expect(avr).to.be.not.undefined;
148+
expect(avr?.installedVersion).to.be.not.undefined;
149+
150+
// uninstall the core
151+
await boardService.uninstall({ item: <BoardsPackage>avr });
152+
result = await boardService.search({ query: 'arduino:avr' });
153+
avr = result.find((boardsPackage) => boardsPackage.id === 'arduino:avr');
154+
expect(avr).to.be.not.undefined;
155+
expect(avr?.installedVersion).to.be.undefined;
156+
});
113157
});
114158

115-
async function createContainer(): Promise<Container> {
116-
return createBaseContainer();
159+
async function createContainer(testDirPath: string): Promise<Container> {
160+
const data = path.join(testDirPath, 'data');
161+
const user = path.join(testDirPath, 'user');
162+
await Promise.all([
163+
fs.mkdir(data, { recursive: true }),
164+
fs.mkdir(user, { recursive: true }),
165+
]);
166+
return createBaseContainer({ cliConfig: { directories: { data, user } } });
117167
}
118168

119169
async function start(

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /