ソースを参照

Replace mocha with tape (for security issue)

Alex Dima 5 年 前
コミット
f697f2e5ba
7 ファイル変更154 行追加622 行削除
  1. 0 5
      .mocharc.json
  2. 0 1
      .npmignore
  3. 3 1
      .vscode/launch.json
  4. 132 597
      package-lock.json
  5. 4 2
      package.json
  6. 14 15
      src/test/testRunner.ts
  7. 1 1
      test/all.js

+ 0 - 5
.mocharc.json

@@ -1,5 +0,0 @@
-{
-  "delay": true,
-  "ui": "tdd",
-  "spec": "test/all.js"
-}

+ 0 - 1
.npmignore

@@ -8,6 +8,5 @@
 /tsconfig.json
 /.npmignore
 /.travis.yml
-/.mocharc.json
 /.editorconfig
 /azure-pipelines.yml

+ 3 - 1
.vscode/launch.json

@@ -5,9 +5,11 @@
             "name": "Unit Tests",
             "type": "node",
             "request": "launch",
-            "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
+            "program": "${workspaceRoot}/node_modules/.bin/tape",
             "stopOnEntry": false,
             "args": [
+                "-r",
+                "./test/all.js",
                 // "--grep",
                 // "typescript"
             ],

ファイルの差分が大きいため隠しています
+ 132 - 597
package-lock.json


+ 4 - 2
package.json

@@ -5,7 +5,8 @@
   "scripts": {
     "compile": "mrmdir ./release && tsc -p ./src/tsconfig.json && tsc -p ./src/tsconfig.esm.json",
     "watch": "tsc -p ./src --watch",
-    "test": "mocha",
+    "watch-esm": "tsc -p ./src/tsconfig.esm.json --watch",
+    "test": "tape -r ./test/all.js",
     "prepublishOnly": "npm run compile && node ./scripts/bundle"
   },
   "author": "Microsoft Corporation",
@@ -18,12 +19,13 @@
     "url": "https://github.com/Microsoft/monaco-languages/issues"
   },
   "devDependencies": {
+    "@types/tape": "^4.2.34",
     "glob": "^7.1.6",
     "jsdom": "^16.2.1",
-    "mocha": "^7.1.0",
     "monaco-editor-core": "0.20.0",
     "monaco-plugin-helpers": "^1.0.2",
     "requirejs": "^2.3.6",
+    "tape": "^4.13.2",
     "terser": "^4.6.6",
     "typescript": "3.7.5"
   }

+ 14 - 15
src/test/testRunner.ts

@@ -5,7 +5,7 @@
 
 import '../monaco.contribution';
 import {loadLanguage} from '../_.contribution';
-import * as assert from 'assert';
+import * as test from 'tape';
 
 // Allow for running under nodejs/requirejs in tests
 const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (<any>self).monaco : monaco);
@@ -28,24 +28,23 @@ export function testTokenization(_language:string|string[], tests:ITestItem[][])
 		languages = _language;
 	}
 	let mainLanguage = languages[0];
-	suite(mainLanguage + ' tokenization', () => {
-		test('', (done) => {
-			Promise.all(languages.map(l => loadLanguage(l))).then(() => {
-				// clean stack
-				setTimeout(() => {
-					runTests(mainLanguage, tests);
-					done();
-				});
-			}).then(null, done);
-		});
+
+	test(mainLanguage + ' tokenization', (t: test.Test) => {
+		Promise.all(languages.map(l => loadLanguage(l))).then(() => {
+			// clean stack
+			setTimeout(() => {
+				runTests(t, mainLanguage, tests);
+				t.end();
+			});
+		}).then(null, () => t.end());
 	});
 }
 
-function runTests(languageId:string, tests:ITestItem[][]): void {
-	tests.forEach((test) => runTest(languageId, test));
+function runTests(t: test.Test, languageId:string, tests:ITestItem[][]): void {
+	tests.forEach((test) => runTest(t, languageId, test));
 }
 
-function runTest(languageId:string, test:ITestItem[]): void {
+function runTest(t: test.Test, languageId:string, test:ITestItem[]): void {
 
 	let text = test.map(t => t.line).join('\n');
 	let actualTokens = _monaco.editor.tokenize(text, languageId);
@@ -61,5 +60,5 @@ function runTest(languageId:string, test:ITestItem[]): void {
 		};
 	});
 
-	assert.deepEqual(actual, test);
+	t.deepEqual(actual, test);
 }

+ 1 - 1
test/all.js

@@ -27,7 +27,7 @@ requirejs(['./test/setup'], function () {
 			return;
 		}
 		requirejs(files.map(f => f.replace(/\.js$/, '')), function () {
-			run(); // We can launch the tests!
+			// We can launch the tests!
 		}, function (err) {
 			console.log(err);
 		})

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません