From 57e51563851acfda93b532aa7812159943527c7b Mon Sep 17 00:00:00 2001 From: Alexandru Dima Date: Fri, 12 Nov 2021 15:27:47 +0100 Subject: [PATCH] Restore monaco-languages test running --- .vscode/launch.json | 20 ++++++++++++++ monaco-languages/.vscode/launch.json | 26 ------------------- .../src/fillers/monaco-editor-core-amd.ts | 12 +++++++++ monaco-languages/test/all.js | 12 +++++---- package.json | 1 + 5 files changed, 40 insertions(+), 31 deletions(-) create mode 100644 .vscode/launch.json delete mode 100644 monaco-languages/.vscode/launch.json create mode 100644 monaco-languages/src/fillers/monaco-editor-core-amd.ts diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..05c913fb --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,20 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "pwa-node", + "request": "launch", + "name": "Monaco Languages Unit Tests", + "skipFiles": [ + "/**" + ], + "program": "${workspaceFolder}\\monaco-languages\\test\\all.js", + "outFiles": [ + "${workspaceFolder}/**/*.js" + ] + } + ] +} diff --git a/monaco-languages/.vscode/launch.json b/monaco-languages/.vscode/launch.json deleted file mode 100644 index cf0b7bfe..00000000 --- a/monaco-languages/.vscode/launch.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "Unit Tests", - "type": "node", - "request": "launch", - "program": "./test/all.js", - "stopOnEntry": false, - "args": [ - // "--grep", - // "typescript" - ], - "cwd": "${workspaceRoot}", - "preLaunchTask": null, - "runtimeExecutable": null, - "runtimeArgs": ["--nolazy"], - "env": { - "NODE_ENV": "development" - }, - "console": "internalConsole", - "sourceMaps": false, - "outDir": null - } - ] -} diff --git a/monaco-languages/src/fillers/monaco-editor-core-amd.ts b/monaco-languages/src/fillers/monaco-editor-core-amd.ts new file mode 100644 index 00000000..6e27a8fb --- /dev/null +++ b/monaco-languages/src/fillers/monaco-editor-core-amd.ts @@ -0,0 +1,12 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +// Resolves with the global monaco API + +declare var define: any; + +define([], function () { + return (self).monaco; +}); diff --git a/monaco-languages/test/all.js b/monaco-languages/test/all.js index 5e1714b9..828ae45f 100644 --- a/monaco-languages/test/all.js +++ b/monaco-languages/test/all.js @@ -4,17 +4,19 @@ const glob = require('glob'); const path = require('path'); requirejs.config({ - baseUrl: '', + baseUrl: 'monaco-languages', paths: { 'vs/css': 'test/css.mock', 'vs/nls': 'test/nls.mock', - 'out/amd/fillers/monaco-editor-core': 'out/amd/fillers/monaco-editor-core-amd', - vs: 'node_modules/monaco-editor-core/dev/vs' + 'vs/basic-languages/fillers/monaco-editor-core': 'out/amd/fillers/monaco-editor-core-amd', + 'vs/basic-languages': 'out/amd', + vs: '../node_modules/monaco-editor-core/dev/vs' }, nodeRequire: require }); const tmp = new jsdom.JSDOM(''); +global.AMD = true; global.document = tmp.window.document; global.navigator = tmp.window.navigator; global.self = global; @@ -33,7 +35,7 @@ global.window = { }; requirejs( - ['./test/setup'], + ['test/setup'], function () { glob('out/amd/*/*.test.js', { cwd: path.dirname(__dirname) }, function (err, files) { if (err) { @@ -41,7 +43,7 @@ requirejs( return; } requirejs( - files.map((f) => f.replace(/\.js$/, '')), + files.map((f) => f.replace(/^out\/amd/, 'vs/basic-languages').replace(/\.js$/, '')), function () { // We can launch the tests! }, diff --git a/package.json b/package.json index 39dacb59..9a6de081 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "release-languages": "node ./monaco-languages/build", "release-typescript": "node ./monaco-typescript/build", "release-plugins": "npm-run-all -lp release-css release-html release-json release-languages release-typescript", + "test": "node ./monaco-languages/test/all.js", "gulp-release": "gulp release", "release": "npm-run-all -ls release-plugins gulp-release", "website": "gulp build-website && npm run typedoc && gulp prepare-website-branch",