Skip to content

Commit

Permalink
Merge remote branch 'origin/master' into edge
Browse files Browse the repository at this point in the history
  • Loading branch information
automatic-merge committed Jan 26, 2024
2 parents fdc3f69 + 03a19f5 commit 04c4892
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 44 deletions.
76 changes: 46 additions & 30 deletions integration/vscode/ada/test/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import os from 'os';

import { runTests } from '@vscode/test-electron';
import { TestOptions } from '@vscode/test-electron/out/runTest';
import { mkdtemp } from 'fs';

async function main() {
// The folder containing the Extension Manifest package.json
Expand All @@ -28,37 +29,52 @@ async function main() {
`test/workspaces/${testsuite}`
);

const testOptions: TestOptions = {
extensionDevelopmentPath,
extensionTestsPath,
// --user-data-dir is set to the OS default directory for temporary files to avoid
// warnings related to longs paths in IPC sockets created by VSCode.
launchArgs: ['--user-data-dir', `${os.tmpdir()}`, testWorkspace],
};
if (process.env.VSCODE) {
// If specified, use the VSCode executable provided externally. This
// can be use to test with an externally installed VS Code version
// such as in a CI environment for example.
//
// The expected value is the path to <install-dir>/code and not
// <install-dir>/bin/code.
testOptions.vscodeExecutablePath = process.env.VSCODE;
} else {
// Otherwise download the latest stable version and test using that.
testOptions.version = 'stable';
}
await new Promise<void>((resolve) => {
mkdtemp(`${os.tmpdir()}/vsc-ada-test-`, (err, folder) => {
if (err) throw err;

const testOptions: TestOptions = {
extensionDevelopmentPath: extensionDevelopmentPath,
extensionTestsPath: extensionTestsPath,
// --user-data-dir is set to a unique dirctory under the OS
// default tmp directory for temporary files to avoid
// warnings related to longs paths in IPC sockets created by
// VSCode. The directory is made unique to avoid
// interference between successive runs.
launchArgs: ['--user-data-dir', folder, testWorkspace],
};
if (process.env.VSCODE) {
// If specified, use the VSCode executable provided externally. This
// can be use to test with an externally installed VS Code version
// such as in a CI environment for example.
//
// The expected value is the path to <install-dir>/code and not
// <install-dir>/bin/code.
testOptions.vscodeExecutablePath = process.env.VSCODE;
} else {
// Otherwise download the latest stable version and test using that.
testOptions.version = 'stable';
}

// Catch any errors running this testsuite, but continue running the remaining ones.
try {
// Download and unzip VS Code (if it has not been done before), and run this testsuite.
await runTests(testOptions);
} catch (err) {
console.error(err);
console.error(`Failed to run ${testsuite} testsuite`);
// If this testsuite failed, flag it so that we can exit with a non zero error code
// later.
someTestsuiteFailed = true;
}
console.info('Calling runTests with: ' + JSON.stringify(testOptions, undefined, 2));
// Download and unzip VS Code (if it has not been done before),
// and run this testsuite.
runTests(testOptions)
.then(() => {
resolve();
})
.catch((err) => {
// Catch any errors running this testsuite, to continue
// running the remaining testsuites.
console.error(err);
console.error(`Failed to run ${testsuite} testsuite`);
// If this testsuite failed, flag it so that we can exit
// with a non zero error code later.
someTestsuiteFailed = true;
resolve();
});
});
});
}

if (someTestsuiteFailed) {
Expand Down
20 changes: 10 additions & 10 deletions integration/vscode/ada/test/suite/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as vscode from 'vscode';
import assert from 'assert';
import { env } from 'process';
import path, { resolve } from 'path';
import Mocha, { MochaOptions } from 'mocha';
import { Glob, GlobOptionsWithFileTypesUnset } from 'glob';
import { existsSync, readFileSync, writeFileSync } from 'fs';
import { Glob, GlobOptionsWithFileTypesUnset } from 'glob';
import Mocha, { MochaOptions } from 'mocha';
import path from 'path';
import { env } from 'process';
import * as vscode from 'vscode';

/**
* This function compares some actual output to an expected referenced stored in
Expand Down Expand Up @@ -89,11 +89,11 @@ export function runMochaTestsuite(suiteName: string, suiteDirectory: string) {
// Create the mocha test
const mocha = new Mocha(mochaOptions);

return new Promise<void>((c, e) => {
return new Promise<void>((resolve, reject) => {
const globOptions: GlobOptionsWithFileTypesUnset = { cwd: suiteDirectory };
const glob = new Glob('**/*.test.js', globOptions);
for (const file of glob) {
mocha.addFile(resolve(suiteDirectory, file));
mocha.addFile(path.resolve(suiteDirectory, file));
}
try {
// This variable is set in the launch configuration (launch.json) of
Expand All @@ -110,13 +110,13 @@ export function runMochaTestsuite(suiteName: string, suiteDirectory: string) {
// Run the mocha test
mocha.run((failures) => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
reject(new Error(`${failures} tests failed.`));
} else {
c();
resolve();
}
});
} catch (err) {
e(err);
reject(err);
}
});
}
3 changes: 2 additions & 1 deletion source/gpr/lsp-gpr_completions.adb
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ package body LSP.GPR_Completions is
end Fill_Completion_Response;

procedure Fill_Completion_Resolve_Response
(Response : in out LSP.Structures.CompletionItem) is
(Response : in out LSP.Structures.CompletionItem)
is
Pack : Package_Id;
Attr : Q_Optional_Attribute_Id;
Doc_Text : VSS.Strings.Virtual_String;
Expand Down
4 changes: 2 additions & 2 deletions source/protocol/generated/lsp-message_io.adb
Original file line number Diff line number Diff line change
Expand Up @@ -7080,7 +7080,7 @@ package body LSP.Message_IO is
elsif Key = "command" then
Optional_Command'Read (S, V.command);
elsif Key = "data" then
Optional_Location'Read (S, V.data);
Optional_LSP_Any'Read (S, V.data);
else
JS.Skip_Value;
end if;
Expand Down Expand Up @@ -7130,7 +7130,7 @@ package body LSP.Message_IO is
JS.Key ("command");
Optional_Command'Write (S, V.command);
JS.Key ("data");
Optional_Location'Write (S, V.data);
Optional_LSP_Any'Write (S, V.data);
JS.End_Object;
end Write_CompletionItem;

Expand Down
2 changes: 1 addition & 1 deletion source/protocol/lsp-messages.ads
Original file line number Diff line number Diff line change
Expand Up @@ -7625,7 +7625,7 @@ package LSP.Messages is
additionalTextEdits : TextEdit_Vector;
commitCharacters : Optional_Virtual_String_Vector;
command : Optional_Command;
data : Optional_Location;
data : Optional_LSP_Any;
end record;

procedure Read_CompletionItem
Expand Down

0 comments on commit 04c4892

Please sign in to comment.