mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-09 12:26:34 +00:00
test: use raw core index-update
for the tests
It should make integration tests more resilient on the Windows CI. From now on, tests are not starting a daemon to initialize the `directories.data` folder for the test suites but rely on the raw command. It is required to avoid spawning the discovery processes, which cannot be terminated on Windows while the daemon is up and running. Closes #2059 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
parent
117b2a4fc7
commit
31deeebb49
@ -1,5 +1,4 @@
|
|||||||
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
||||||
import { waitForEvent } from '@theia/core/lib/common/promise-util';
|
|
||||||
import type { MaybePromise } from '@theia/core/lib/common/types';
|
import type { MaybePromise } from '@theia/core/lib/common/types';
|
||||||
import { FileUri } from '@theia/core/lib/node/file-uri';
|
import { FileUri } from '@theia/core/lib/node/file-uri';
|
||||||
import { Container } from '@theia/core/shared/inversify';
|
import { Container } from '@theia/core/shared/inversify';
|
||||||
@ -16,6 +15,7 @@ import { ArduinoDaemonImpl } from '../../node/arduino-daemon-impl';
|
|||||||
import { CLI_CONFIG, DefaultCliConfig } from '../../node/cli-config';
|
import { CLI_CONFIG, DefaultCliConfig } from '../../node/cli-config';
|
||||||
import { BoardListRequest } from '../../node/cli-protocol/cc/arduino/cli/commands/v1/board_pb';
|
import { BoardListRequest } from '../../node/cli-protocol/cc/arduino/cli/commands/v1/board_pb';
|
||||||
import { CoreClientProvider } from '../../node/core-client-provider';
|
import { CoreClientProvider } from '../../node/core-client-provider';
|
||||||
|
import { spawnCommand } from '../../node/exec-util';
|
||||||
import { ConfigDirUriProvider } from '../../node/theia/env-variables/env-variables-server';
|
import { ConfigDirUriProvider } from '../../node/theia/env-variables/env-variables-server';
|
||||||
import { ErrnoException } from '../../node/utils/errors';
|
import { ErrnoException } from '../../node/utils/errors';
|
||||||
import {
|
import {
|
||||||
@ -177,10 +177,9 @@ describe('core-client-provider', () => {
|
|||||||
boardsPackages.filter(({ id }) => id === 'teensy:avr').length
|
boardsPackages.filter(({ id }) => id === 'teensy:avr').length
|
||||||
).to.be.equal(1);
|
).to.be.equal(1);
|
||||||
};
|
};
|
||||||
const configDirPath = await prepareTestConfigDir(
|
const configDirPath = await prepareTestConfigDir({
|
||||||
{ board_manager: { additional_urls: additionalUrls } },
|
board_manager: { additional_urls: additionalUrls },
|
||||||
({ boardsService }) => assertTeensyAvailable(boardsService)
|
});
|
||||||
);
|
|
||||||
const thirdPartyPackageIndexPath = join(
|
const thirdPartyPackageIndexPath = join(
|
||||||
configDirPath,
|
configDirPath,
|
||||||
'data',
|
'data',
|
||||||
@ -273,27 +272,31 @@ async function assertFunctionalCli(
|
|||||||
* the config folder.
|
* the config folder.
|
||||||
*/
|
*/
|
||||||
async function prepareTestConfigDir(
|
async function prepareTestConfigDir(
|
||||||
configOverrides: Partial<DefaultCliConfig> = {},
|
configOverrides: Partial<DefaultCliConfig> = {}
|
||||||
otherExpect?: (services: Services) => MaybePromise<void>
|
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const toDispose = new DisposableCollection();
|
|
||||||
const params = { configDirPath: newTempConfigDirPath(), configOverrides };
|
const params = { configDirPath: newTempConfigDirPath(), configOverrides };
|
||||||
const container = await createContainer(params);
|
const container = await createContainer(params);
|
||||||
try {
|
const daemon = container.get<ArduinoDaemonImpl>(ArduinoDaemonImpl);
|
||||||
await start(container, toDispose);
|
const cliPath = await daemon.getExecPath();
|
||||||
await assertFunctionalCli(container, otherExpect);
|
|
||||||
const configDirUriProvider =
|
const configDirUriProvider =
|
||||||
container.get<ConfigDirUriProvider>(ConfigDirUriProvider);
|
container.get<ConfigDirUriProvider>(ConfigDirUriProvider);
|
||||||
return FileUri.fsPath(configDirUriProvider.configDirUri());
|
const configDirPath = FileUri.fsPath(configDirUriProvider.configDirUri());
|
||||||
} finally {
|
await coreUpdateIndex(cliPath, configDirPath);
|
||||||
const daemon = container.get<ArduinoDaemonImpl>(ArduinoDaemonImpl);
|
return configDirPath;
|
||||||
// Wait for the daemon stop event. All subprocesses (such as `serial-discovery` and `mdns-discovery`) must terminate.
|
}
|
||||||
// Otherwise, `EPERM: operation not permitted, unlink` is thrown on Windows when "corrupting" the `directories.data` folder for the tests.
|
|
||||||
await Promise.all([
|
async function coreUpdateIndex(
|
||||||
waitForEvent(daemon.onDaemonStopped, 5_000),
|
cliPath: string,
|
||||||
Promise.resolve(toDispose.dispose()),
|
configDirPath: string
|
||||||
]);
|
): Promise<void> {
|
||||||
}
|
const cliConfigPath = join(configDirPath, 'arduino-cli.yaml');
|
||||||
|
await fs.access(cliConfigPath);
|
||||||
|
const stdout = await spawnCommand(
|
||||||
|
cliPath,
|
||||||
|
['core', 'update-index', '--config-file', cliConfigPath],
|
||||||
|
(error) => console.error(error)
|
||||||
|
);
|
||||||
|
console.log(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startCli(
|
async function startCli(
|
||||||
@ -312,15 +315,8 @@ async function startCli(
|
|||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
const container = await createContainer(configDirPath);
|
const container = await createContainer(configDirPath);
|
||||||
await start(container, toDispose);
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function start(
|
|
||||||
container: Container,
|
|
||||||
toDispose: DisposableCollection
|
|
||||||
): Promise<void> {
|
|
||||||
await startDaemon(container, toDispose);
|
await startDaemon(container, toDispose);
|
||||||
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createContainer(
|
async function createContainer(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user