mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
Implement NLS without AMD loader (#214588)
This commit is contained in:
@@ -246,6 +246,18 @@ async function runTestsInBrowser(testModules, browserType) {
|
||||
|
||||
await page.goto(target.href);
|
||||
|
||||
if (args.build) {
|
||||
const nlsMessages = await fs.promises.readFile(path.join(out, 'nls.messages.json'), 'utf8');
|
||||
await page.evaluate(value => {
|
||||
// when running from `out-build`, ensure to load the default
|
||||
// messages file, because all `nls.localize` calls have their
|
||||
// english values removed and replaced by an index.
|
||||
// VSCODE_GLOBALS: NLS
|
||||
// @ts-ignore
|
||||
globalThis._VSCODE_NLS_MESSAGES = JSON.parse(value);
|
||||
}, nlsMessages);
|
||||
}
|
||||
|
||||
page.on('console', async msg => {
|
||||
consoleLogFn(msg)(msg.text(), await Promise.all(msg.args().map(async arg => await arg.jsonValue())));
|
||||
});
|
||||
|
||||
@@ -97,6 +97,16 @@ const _tests_glob = '**/test/**/*.test.js';
|
||||
let loader;
|
||||
let _out;
|
||||
|
||||
function initNls(opts) {
|
||||
if (opts.build) {
|
||||
// when running from `out-build`, ensure to load the default
|
||||
// messages file, because all `nls.localize` calls have their
|
||||
// english values removed and replaced by an index.
|
||||
// VSCODE_GLOBALS: NLS
|
||||
globalThis._VSCODE_NLS_MESSAGES = (require.__$__nodeRequire ?? require)(`../../../out-build/nls.messages.json`);
|
||||
}
|
||||
}
|
||||
|
||||
function initLoader(opts) {
|
||||
const outdir = opts.build ? 'out-build' : 'out';
|
||||
_out = path.join(__dirname, `../../../${outdir}`);
|
||||
@@ -438,6 +448,7 @@ function runTests(opts) {
|
||||
}
|
||||
|
||||
ipcRenderer.on('run', (e, opts) => {
|
||||
initNls(opts);
|
||||
initLoader(opts);
|
||||
runTests(opts).catch(err => {
|
||||
if (typeof err !== 'string') {
|
||||
|
||||
@@ -84,6 +84,14 @@ function main() {
|
||||
globalThis._VSCODE_PRODUCT_JSON = require(`${REPO_ROOT}/product.json`);
|
||||
globalThis._VSCODE_PACKAGE_JSON = require(`${REPO_ROOT}/package.json`);
|
||||
|
||||
if (args.build) {
|
||||
// when running from `out-build`, ensure to load the default
|
||||
// messages file, because all `nls.localize` calls have their
|
||||
// english values removed and replaced by an index.
|
||||
// VSCODE_GLOBALS: NLS
|
||||
globalThis._VSCODE_NLS_MESSAGES = require(`../../../${out}/nls.messages.json`);
|
||||
}
|
||||
|
||||
// Test file operations that are common across platforms. Used for test infra, namely snapshot tests
|
||||
Object.assign(globalThis, {
|
||||
__analyzeSnapshotInTests: takeSnapshotAndCountClasses,
|
||||
|
||||
Reference in New Issue
Block a user