From 80a3de206123b5c2bf2099a4a3a70e01be6db7fe Mon Sep 17 00:00:00 2001 From: Mate Pek Date: Thu, 18 Oct 2018 09:07:41 +0200 Subject: [PATCH 1/5] C2Adapter Integration tests --- .vscode/launch.json | 1 + package-lock.json | 373 ++++++++--------- package.json | 3 +- src/C2TestSuiteInfo.ts | 19 +- src/test/C2TestAdapter.test.ts | 713 ++++++++++++++++++++++++++------- src/test/suite1.cpp | 17 + src/test/suite2.cpp | 23 ++ 7 files changed, 822 insertions(+), 327 deletions(-) create mode 100644 src/test/suite1.cpp create mode 100644 src/test/suite2.cpp diff --git a/.vscode/launch.json b/.vscode/launch.json index 8a238868..03df68e1 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -19,6 +19,7 @@ "request": "launch", "runtimeExecutable": "${execPath}", "args": [ + "${workspaceFolder}/out/test", "--disable-extensions", "--extensionDevelopmentPath=${workspaceFolder}", "--extensionTestsPath=${workspaceFolder}/out/test" diff --git a/package-lock.json b/package-lock.json index ac6c1e66..ec851d2c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,10 +39,10 @@ "integrity": "sha512-ZwTHAlC9akprWDinwEPD4kOuwaYZlyMwVJIANsKNC3QVp0AHB04m7RnB4eqeWfgmxw8MGTzS9uMaw93Z3QcZbw==", "dev": true }, - "@types/chai": { - "version": "4.1.6", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.6.tgz", - "integrity": "sha512-CBk7KTZt3FhPsEkYioG6kuCIpWISw+YI8o+3op4+NXwTpvAPxE1ES8+PY8zfaK2L98b1z5oq03UHa4VYpeUxnw==", + "@types/deep-equal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@types/deep-equal/-/deep-equal-1.0.1.tgz", + "integrity": "sha512-mMUu4nWHLBlHtxXY17Fg6+ucS/MnndyOWyOe7MmwkoMYxvfQU2ajtRaEvqSUv+aVkMqH/C0NCI8UoVfRNQ10yg==", "dev": true }, "@types/entities": { @@ -53,7 +53,7 @@ }, "@types/events": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@types/events/-/events-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/@types/events/-/events-1.2.0.tgz", "integrity": "sha512-KEIlhXnIutzKwRbQkGWb/I4HFqBuUykAdHgDED6xqwXJfONCjF5VoE0cXEiurh3XauygxzeDzgtXUqvLkxFzzA==", "dev": true }, @@ -73,9 +73,9 @@ "dev": true }, "@types/node": { - "version": "10.9.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.9.4.tgz", - "integrity": "sha512-fCHV45gS+m3hH17zgkgADUSi2RR1Vht6wOZ0jyHP8rjiQra9f+mIcgwPQHllmDocYOstIEbKlxbFDYlgrTPYqw==", + "version": "10.12.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.0.tgz", + "integrity": "sha512-3TUHC3jsBAB7qVRGxT6lWyYo2v96BMmD2PTcl47H25Lu7UXtFH/2qqmKiVrnel6Ne//0TFYf6uvNX+HW2FRkLQ==", "dev": true }, "@types/xml-parser": { @@ -250,7 +250,6 @@ "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", "dev": true, - "optional": true, "requires": { "tweetnacl": "^0.14.3" } @@ -291,6 +290,12 @@ "repeat-element": "^1.1.2" } }, + "browser-stdout": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", + "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=", + "dev": true + }, "buffer-crc32": { "version": "0.2.13", "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", @@ -359,18 +364,18 @@ "dev": true }, "combined-stream": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", - "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", + "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", "dev": true, "requires": { "delayed-stream": "~1.0.0" } }, "commander": { - "version": "2.18.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.18.0.tgz", - "integrity": "sha512-6CYPa+JP2ftfRU2qkDK+UTVeQYosOg/2GbcjIcKPHfinyOLPVGXu/ovN86RP49Re5ndJK1N0kuiidFFuepc4ZQ==", + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", + "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==", "dev": true }, "concat-map": { @@ -380,10 +385,13 @@ "dev": true }, "convert-source-map": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.5.1.tgz", - "integrity": "sha1-uCeAl7m8IpNl3lxiz1/K7YtVmeU=", - "dev": true + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.6.0.tgz", + "integrity": "sha512-eFu7XigvxdZ1ETfbgPBohgyQ/Z++C0eEhTor0qRwBw9unw+L0/6V8wkSuGgzdThkiS5lSpdptOQPD8Ak40a+7A==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.1" + } }, "core-util-is": { "version": "1.0.2", @@ -436,6 +444,12 @@ "is-obj": "^1.0.0" } }, + "deep-equal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", + "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=", + "dev": true + }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -499,14 +513,14 @@ }, "duplexer": { "version": "0.1.1", - "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", + "resolved": "http://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", "dev": true }, "duplexify": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.6.0.tgz", - "integrity": "sha512-fO3Di4tBKJpYTFHAxTU00BcfWMY9w24r/x21a6rZRbsD/ToUgGxsMbiGRmB7uVAXeGKXD9MwiLZa5E97EVgIRQ==", + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.6.1.tgz", + "integrity": "sha512-vM58DwdnKmty+FSPzT14K9JXb90H+j5emaR4KYbr2KTIz00WHGbWOe5ghQTx233ZCLZtrGDALzKwcjEtSt35mA==", "dev": true, "requires": { "end-of-stream": "^1.0.0", @@ -520,7 +534,6 @@ "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", "dev": true, - "optional": true, "requires": { "jsbn": "~0.1.0", "safer-buffer": "^2.1.0" @@ -547,18 +560,19 @@ "dev": true }, "event-stream": { - "version": "3.3.4", - "resolved": "http://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", - "integrity": "sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE=", + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.6.tgz", + "integrity": "sha512-dGXNg4F/FgVzlApjzItL+7naHutA3fDqbV/zAZqDDlXTjiMnQmZKu+prImWKszeBM5UQeGvAl3u1wBiKeDh61g==", "dev": true, "requires": { - "duplexer": "~0.1.1", - "from": "~0", - "map-stream": "~0.1.0", - "pause-stream": "0.0.11", - "split": "0.3", - "stream-combiner": "~0.0.4", - "through": "~2.3.1" + "duplexer": "^0.1.1", + "flatmap-stream": "^0.1.0", + "from": "^0.1.7", + "map-stream": "0.0.7", + "pause-stream": "^0.0.11", + "split": "^1.0.1", + "stream-combiner": "^0.2.2", + "through": "^2.3.8" } }, "expand-brackets": { @@ -663,6 +677,12 @@ "integrity": "sha1-Wb+1DNkF9g18OUzT2ayqtOatk04=", "dev": true }, + "flatmap-stream": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/flatmap-stream/-/flatmap-stream-0.1.1.tgz", + "integrity": "sha512-lAq4tLbm3sidmdCN8G3ExaxH7cUCtP5mgDvrYowsx84dcYkJJ4I28N7gkxA6+YlSXzaGLJYIDEi9WGfXzMiXdw==", + "dev": true + }, "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", @@ -685,13 +705,13 @@ "dev": true }, "form-data": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", - "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", "dev": true, "requires": { "asynckit": "^0.4.0", - "combined-stream": "1.0.6", + "combined-stream": "^1.0.6", "mime-types": "^2.1.12" } }, @@ -828,15 +848,9 @@ "path-is-absolute": "^1.0.0" } }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, "readable-stream": { "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, "requires": { @@ -870,6 +884,12 @@ "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", "dev": true }, + "growl": { + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", + "dev": true + }, "gulp-chmod": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/gulp-chmod/-/gulp-chmod-2.0.0.tgz", @@ -902,15 +922,9 @@ "vinyl": "~0.4.6" }, "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, "readable-stream": { "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, "requires": { @@ -1258,7 +1272,7 @@ }, "is-obj": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "resolved": "http://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", "dev": true }, @@ -1299,9 +1313,9 @@ "dev": true }, "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", "dev": true }, "isobject": { @@ -1311,6 +1325,14 @@ "dev": true, "requires": { "isarray": "1.0.0" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + } } }, "isstream": { @@ -1323,8 +1345,7 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", - "dev": true, - "optional": true + "dev": true }, "json-schema": { "version": "0.2.3", @@ -1388,7 +1409,7 @@ }, "kind-of": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz", "integrity": "sha1-FAo9LUGjbS78+pN3tiwk+ElaXEQ=", "dev": true }, @@ -1435,9 +1456,9 @@ "dev": true }, "map-stream": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", - "integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=", + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.0.7.tgz", + "integrity": "sha1-ih8HiW2CsQkmvTdEokIACfiJdKg=", "dev": true }, "markdown-it": { @@ -1562,19 +1583,80 @@ }, "minimist": { "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "dev": true }, "mkdirp": { "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, "requires": { "minimist": "0.0.8" } }, + "mocha": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-4.1.0.tgz", + "integrity": "sha512-0RVnjg1HJsXY2YFDoTNzcc1NKhYuXKRrBAG2gDygmJJA136Cs2QlRliZG1mA0ap7cuaT30mw16luAeln+4RiNA==", + "dev": true, + "requires": { + "browser-stdout": "1.3.0", + "commander": "2.11.0", + "debug": "3.1.0", + "diff": "3.3.1", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.3", + "he": "1.1.1", + "mkdirp": "0.5.1", + "supports-color": "4.4.0" + }, + "dependencies": { + "commander": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", + "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", + "dev": true + }, + "diff": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.3.1.tgz", + "integrity": "sha512-MKPHZDMB0o6yHyDryUOScqZibp914ksXwAMYMTHj6KO8UeKsRYNJD3oNCKjTqZon+V488P7N/HzXF8t7ZR95ww==", + "dev": true + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "dev": true + }, + "supports-color": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", + "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", + "dev": true, + "requires": { + "has-flag": "^2.0.0" + } + } + } + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -1776,19 +1858,11 @@ "dev": true, "requires": { "isarray": "0.0.1" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - } } }, "pause-stream": { "version": "0.0.11", - "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", + "resolved": "http://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", "integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=", "dev": true, "requires": { @@ -1857,9 +1931,9 @@ "dev": true }, "querystringify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.0.0.tgz", - "integrity": "sha512-eTPo5t/4bgaMNZxyjWx6N2a6AuE0mq51KWvpc7nU/MAqixcI6v6KrGUKES0HaomdnolQBBXU/++X6/QQ9KL4tw==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.0.tgz", + "integrity": "sha512-sluvZZ1YiTLD5jsqZcDmFyV2EwToyXZBfpoVOmktMmW+VEnhgakFHnasVph65fOjGPTWN0Nw3+XQaSeMayr0kg==", "dev": true }, "queue": { @@ -1907,7 +1981,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { @@ -1918,6 +1992,14 @@ "safe-buffer": "~5.1.1", "string_decoder": "~1.1.1", "util-deprecate": "~1.0.1" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + } } }, "regex-cache": { @@ -2014,9 +2096,9 @@ "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" }, "semver": { - "version": "5.5.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.1.tgz", - "integrity": "sha512-PqpAxfrEhlSUWge8dwIp4tZnQ25DIOthpiaHNIthsjEFQD6EvqUKUDM7L8O2rShkFccYo1VjJR0coWfNkCubRw==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", "dev": true }, "sinon": { @@ -2034,17 +2116,6 @@ "nise": "^1.4.5", "supports-color": "^5.5.0", "type-detect": "^4.0.8" - }, - "dependencies": { - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - } } }, "source-map": { @@ -2064,9 +2135,9 @@ } }, "split": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", - "integrity": "sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", + "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", "dev": true, "requires": { "through": "2" @@ -2079,9 +2150,9 @@ "dev": true }, "sshpk": { - "version": "1.14.2", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.2.tgz", - "integrity": "sha1-xvxhZIo9nE52T9P8306hBeSSupg=", + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.15.1.tgz", + "integrity": "sha512-mSdgNUaidk+dRU5MhYtN9zebdzF2iG0cNPWy8HG+W8y+fT1JnSkh0fzzpjOa0L7P8i1Rscz38t0h4gPcKz43xA==", "dev": true, "requires": { "asn1": "~0.2.3", @@ -2102,12 +2173,13 @@ "dev": true }, "stream-combiner": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", - "integrity": "sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ=", + "version": "0.2.2", + "resolved": "http://registry.npmjs.org/stream-combiner/-/stream-combiner-0.2.2.tgz", + "integrity": "sha1-rsjLrBd7Vrb0+kec7YwZEs7lKFg=", "dev": true, "requires": { - "duplexer": "~0.1.1" + "duplexer": "~0.1.1", + "through": "~2.3.4" } }, "stream-shift": { @@ -2159,6 +2231,15 @@ "strip-bom": "^2.0.0" } }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, "tar": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz", @@ -2178,7 +2259,7 @@ }, "through": { "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, @@ -2248,7 +2329,7 @@ }, "tunnel": { "version": "0.0.4", - "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.4.tgz", + "resolved": "http://registry.npmjs.org/tunnel/-/tunnel-0.0.4.tgz", "integrity": "sha1-LTeFoVjBdMmhbcLARuxfxfF0IhM=", "dev": true }, @@ -2265,8 +2346,7 @@ "version": "0.14.5", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", - "dev": true, - "optional": true + "dev": true }, "type-detect": { "version": "4.0.8", @@ -2442,9 +2522,9 @@ } }, "vsce": { - "version": "1.51.1", - "resolved": "https://registry.npmjs.org/vsce/-/vsce-1.51.1.tgz", - "integrity": "sha512-Hf2HE9O/MRQHxUUgWHAm7mOkz0K5swuF2smaE/sP7+OWp/5DdIPFwmLEYCCZHxG25l3GBRoO0dAL8S5w//et+g==", + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/vsce/-/vsce-1.52.0.tgz", + "integrity": "sha512-k+KYoTx1sacpYf2BHTA7GN82MNSlf2N4EuppFWwtTN/Sh6fWzIJafxxCNBCDK0H+5NDWfRGZheBY8C3/HOE2ZA==", "dev": true, "requires": { "cheerio": "^1.0.0-rc.1", @@ -2486,81 +2566,6 @@ "source-map-support": "^0.5.0", "url-parse": "^1.4.3", "vinyl-source-stream": "^1.1.0" - }, - "dependencies": { - "browser-stdout": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", - "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=", - "dev": true - }, - "commander": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", - "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", - "dev": true - }, - "diff": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.3.1.tgz", - "integrity": "sha512-MKPHZDMB0o6yHyDryUOScqZibp914ksXwAMYMTHj6KO8UeKsRYNJD3oNCKjTqZon+V488P7N/HzXF8t7ZR95ww==", - "dev": true - }, - "growl": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", - "dev": true - }, - "has-flag": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", - "dev": true - }, - "mocha": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-4.1.0.tgz", - "integrity": "sha512-0RVnjg1HJsXY2YFDoTNzcc1NKhYuXKRrBAG2gDygmJJA136Cs2QlRliZG1mA0ap7cuaT30mw16luAeln+4RiNA==", - "dev": true, - "requires": { - "browser-stdout": "1.3.0", - "commander": "2.11.0", - "debug": "3.1.0", - "diff": "3.3.1", - "escape-string-regexp": "1.0.5", - "glob": "7.1.2", - "growl": "1.10.3", - "he": "1.1.1", - "mkdirp": "0.5.1", - "supports-color": "4.4.0" - }, - "dependencies": { - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - } - } - }, - "supports-color": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", - "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", - "dev": true, - "requires": { - "has-flag": "^2.0.0" - } - } } }, "vscode-test-adapter-api": { @@ -2606,7 +2611,7 @@ }, "xmlbuilder": { "version": "9.0.7", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", + "resolved": "http://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=" }, "xtend": { diff --git a/package.json b/package.json index bf376e2b..c19c6d26 100644 --- a/package.json +++ b/package.json @@ -52,9 +52,10 @@ "@types/xml-parser": "^1.2.29", "@types/xml2js": "^0.4.3", "@types/mocha": "^5.2.5", - "@types/chai": "^4.1.2", "@types/fs-extra": "^5.0.4", "fs-extra": "^7.0.0", + "@types/deep-equal": "^1.0.1", + "deep-equal": "^1.0.1", "sinon": "^7.0.0", "typescript": "^2.9.2", "vsce": "^1.51.1", diff --git a/src/C2TestSuiteInfo.ts b/src/C2TestSuiteInfo.ts index 3b348013..4f5135a3 100644 --- a/src/C2TestSuiteInfo.ts +++ b/src/C2TestSuiteInfo.ts @@ -50,7 +50,7 @@ export class C2TestSuiteInfo implements TestSuiteInfo { return test; } - acquireSlot(): boolean { + private acquireSlot(): boolean { let i: number = 0; while (i < this.taskPools.length && this.taskPools[i].acquire()) ++i; @@ -61,7 +61,7 @@ export class C2TestSuiteInfo implements TestSuiteInfo { return false; } - releaseSlot(): void { + private releaseSlot(): void { let i: number = this.taskPools.length; while (--i >= 0) this.taskPools[i].release(); @@ -108,6 +108,9 @@ export class C2TestSuiteInfo implements TestSuiteInfo { }); } + this.adapter.testStatesEmitter.fire( + {type: 'suite', suite: this, state: 'running'}); + const execParams: string[] = []; if (childrenToRun != 'all') { let testNames: string[] = []; @@ -138,8 +141,10 @@ export class C2TestSuiteInfo implements TestSuiteInfo { this.proc = spawn(this.execPath, execParams, this.execOptions); let pResolver: Function|undefined = undefined; + let pRejecter: Function|undefined = undefined; const p = new Promise((resolve, reject) => { pResolver = resolve; + pRejecter = reject; }); const data = new class { @@ -190,7 +195,7 @@ export class C2TestSuiteInfo implements TestSuiteInfo { const ev = data.currentChild.getStartEvent(); this.adapter.testStatesEmitter.fire(ev); } else { - this.adapter.log.error('Tescase not found in children: ' + name); + this.adapter.log.error('TestCase not found in children: ' + name); } data.buffer = data.buffer.substr(b); @@ -226,12 +231,12 @@ export class C2TestSuiteInfo implements TestSuiteInfo { }); this.proc.on('close', (code: number) => { - if (pResolver != undefined) pResolver(); + if (data.inTestCase) + (pRejecter != undefined) && pRejecter(); + else + (pResolver != undefined) && pResolver(); }); - this.adapter.testStatesEmitter.fire( - {type: 'suite', suite: this, state: 'running'}); - return p .then(() => { this.releaseSlot(); diff --git a/src/test/C2TestAdapter.test.ts b/src/test/C2TestAdapter.test.ts index 188390f9..3d058d2e 100644 --- a/src/test/C2TestAdapter.test.ts +++ b/src/test/C2TestAdapter.test.ts @@ -1,7 +1,8 @@ const sinon = require('sinon'); const child_process = require('child_process'); +const deepEqual = require('deep-equal'); -// import * as path from 'path'; +import * as path from 'path'; import * as fs from 'fs-extra'; import * as assert from 'assert'; import {EventEmitter} from 'events'; @@ -11,166 +12,608 @@ import {Log} from 'vscode-test-adapter-util'; import {C2AllTestSuiteInfo} from '../C2AllTestSuiteInfo'; import * as myExtension from '../C2TestAdapter'; -import {C2TestSuiteInfo} from '../C2TestSuiteInfo'; +import {Stream} from 'stream'; +import {inspect} from 'util'; -const disposable: vscode.Disposable[] = []; +assert.notEqual(vscode.workspace.workspaceFolders, undefined); +assert.equal(vscode.workspace.workspaceFolders!.length, 1); -const workspaceFolderPath = 'out/vscode-catch2-test/'; -fs.removeSync(workspaceFolderPath); -fs.ensureDirSync(workspaceFolderPath); +const workspaceFolderUri = vscode.workspace.workspaceFolders![0].uri; -// const setupSettings = function(json: any) { -// const p = path.join(workspaceFolderPath, '.vscode', 'settings.json'); -// fs.removeSync(p); -// fs.ensureFileSync(p); -// fs.writeJSON(p, json); -// }; - -const workspaceFolderUri = vscode.Uri.file(workspaceFolderPath); -vscode.workspace.updateWorkspaceFolders( - 0, 0, {uri: workspaceFolderUri, name: undefined}); const workspaceFolder = vscode.workspace.getWorkspaceFolder(workspaceFolderUri)!; const logger = new Log('Catch2TestAdapter', workspaceFolder, 'Catch2TestAdapter'); -const adapter = new myExtension.C2TestAdapter(workspaceFolder, logger); - -const testsEvents: (TestLoadStartedEvent|TestLoadFinishedEvent)[] = []; -disposable.push( - adapter.tests((e: TestLoadStartedEvent|TestLoadFinishedEvent) => { - testsEvents.push(e); - })); - -const testStatesEvents: (TestRunStartedEvent|TestRunFinishedEvent| - TestSuiteEvent|TestEvent)[] = []; -disposable.push(adapter.testStates( - (e: TestRunStartedEvent|TestRunFinishedEvent|TestSuiteEvent|TestEvent) => { - testStatesEvents.push(e); - })); - -const setupTemlateTestTree = function() { - return adapter.load() - .then(() => { - const suite = (testsEvents[1]).suite; - assert.notEqual(undefined, suite); - return suite!; - }) - .then((suite: TestSuiteInfo) => { - const allTests = suite; - const suite1 = allTests.createChildSuite('suite1', 'execPath', {}); - const s1t1 = suite1.createChildTest('test1', 'd', ['t1'], 'file', 1); - const s1t2 = suite1.createChildTest('test2', 'd', ['t1'], 'file', 1); - const suite2 = allTests.createChildSuite('suite2', 'execPath', {}); - const s2t1 = suite2.createChildTest('test1', 'd', ['t1'], 'file', 1); - const s2t2 = suite2.createChildTest('test2', 'd', ['t1'], 'file', 1); - - return { - allTests: allTests, suite1: suite1, s1t1: s1t1, s1t2: s1t2, - suite2: suite2, s2t1: s2t1, s2t2: s2t2 - } - }); -}; + +const spawnStub = sinon.stub(child_process, 'spawn'); + +const dotVscodePath = path.join(workspaceFolderUri.path, '.vscode'); /// describe('C2TestAdapter', function() { - beforeEach(function() { - while (testsEvents.length > 0) testsEvents.pop(); - while (testStatesEvents.length > 0) testStatesEvents.pop(); + const config = vscode.workspace.getConfiguration( + 'catch2TestExplorer', workspaceFolderUri); + + const disposable: vscode.Disposable[] = []; + + let adapter: myExtension.C2TestAdapter; + let testsEvents: (TestLoadStartedEvent|TestLoadFinishedEvent)[]; + let testStatesEvents: (TestRunStartedEvent|TestRunFinishedEvent| + TestSuiteEvent|TestEvent)[]; + + const createAdapterAndSubscribe = function() { + adapter = new myExtension.C2TestAdapter(workspaceFolder, logger); + testsEvents = []; + testStatesEvents = []; + + spawnStub.throws(); + + disposable.push( + adapter.tests((e: TestLoadStartedEvent|TestLoadFinishedEvent) => { + testsEvents.push(e); + })); + disposable.push(adapter.testStates( + (e: TestRunStartedEvent|TestRunFinishedEvent|TestSuiteEvent| + TestEvent) => { + testStatesEvents.push(e); + })); + }; + + beforeEach(() => { + fs.removeSync(dotVscodePath); + return config.update('defaultRngSeed', undefined); }); - after(() => { + afterEach(() => { while (disposable.length > 0) disposable.pop()!.dispose(); - }) - - it('empty config load', function() { - return adapter.load().then(() => { - assert.equal(2, testsEvents.length); - assert.equal('started', testsEvents[0].type); - assert.equal('finished', testsEvents[1].type); - const suite = (testsEvents[1]).suite; - assert.notEqual(undefined, suite); - assert.equal(0, suite!.children.length); - }); }); - it('run1', function() { - this.timeout(10000); - return setupTemlateTestTree().then((s) => { - const spawnEvent: any = new EventEmitter(); - spawnEvent.stdout = new EventEmitter(); - - const stub = sinon.stub(child_process, 'spawn'); - stub.throws(); - stub.withArgs( - s.suite1.execPath, - [s.s1t1.testNameFull, '--reporter', 'xml', '--durations', 'yes'], - s.suite1.execOptions) - .returns(spawnEvent); - - const d = adapter.testStates( - (e: TestRunStartedEvent|TestRunFinishedEvent|TestSuiteEvent| - TestEvent) => { - if (e.type == 'suite' && e.state == 'running' && - (e.suite) === s.suite1) { - spawnEvent.stdout.emit( - 'data', - ` - - - - - - - - 1 == x % 2 - - - 1 == 0 - - - - - - - - `); - spawnEvent.emit('close', 1); + describe('detect config change', function() { + const waitForReloadAndAssert = () => { + const waitForReloadAndAssertInner = + (tryCount: number = 20): Promise => { + if (testsEvents.length < 2) + return new Promise(r => setTimeout(r, 20)) + .then(() => {waitForReloadAndAssertInner(tryCount - 1)}); + else { + assert.equal(testsEvents.length, 2); + assert.equal(testsEvents[0].type, 'started'); + assert.equal(testsEvents[1].type, 'finished'); + const suite = (testsEvents[1]).suite; + assert.notEqual(suite, undefined); + assert.equal(suite!.children.length, 0); + return Promise.resolve(); } - }); + }; + return waitForReloadAndAssertInner(); + }; - return adapter.run([s.s1t1.id]).then(() => { - assert.equal(6, testStatesEvents.length); - assert.equal('started', testStatesEvents[0].type); + it('workerMaxNumber', () => { + createAdapterAndSubscribe(); + assert.deepEqual(testsEvents, []); + return config.update('workerMaxNumber', 42).then(waitForReloadAndAssert); + }); + + it('defaultEnv', () => { + createAdapterAndSubscribe(); + assert.deepEqual(testsEvents, []); + return config.update('defaultEnv', {'APPLE': 'apple'}) + .then(waitForReloadAndAssert); + }); - assert.equal('suite', testStatesEvents[1].type); - assert.equal('running', (testStatesEvents[1]).state); - assert.equal(s.suite1, (testStatesEvents[1]).suite); + it('defaultCwd', () => { + createAdapterAndSubscribe(); + assert.deepEqual(testsEvents, []); + return config.update('defaultCwd', 'apple/peach') + .then(waitForReloadAndAssert); + }); + + it('enableSourceDecoration', () => { + createAdapterAndSubscribe(); + assert.deepEqual(testsEvents, []); + return config.update('enableSourceDecoration', false).then(() => { + assert.ok(!adapter.getIsEnabledSourceDecoration()); + }); + }); + + it('defaultRngSeed', () => { + createAdapterAndSubscribe(); + assert.deepEqual(testsEvents, []); + return config.update('defaultRngSeed', 987).then(() => { + assert.equal(adapter.getRngSeed(), 987); + }); + }); + }); + + describe('adapter:', () => { + beforeEach(() => { + createAdapterAndSubscribe(); + }); + + it('load: empty config', function() { + return adapter.load().then(() => { + assert.equal(testsEvents.length, 2); + assert.equal(testsEvents[0].type, 'started'); + assert.equal(testsEvents[1].type, 'finished'); + const suite = (testsEvents[1]).suite; + assert.notEqual(suite, undefined); + assert.equal(suite!.children.length, 0); + }); + }); + + describe('load: example1', function() { + let tests: any; + + beforeEach(() => { + return adapter.load() + .then(() => { + const root = (testsEvents[1]).suite; + assert.notEqual(undefined, root); + return root!; + }) + .then((suite: TestSuiteInfo) => { + const root = suite; + const s1 = root.createChildSuite('s1', 'execPath1', {}); + const s1t1 = + s1.createChildTest('s1t1', 'd', ['tag1'], 'suite1.cpp', 1); + const s1t2 = + s1.createChildTest('s1t2', 'd', ['tag1'], 'suite1.cpp', 2); + const s2 = root.createChildSuite('s2', 'execPath2', {}); + const s2t1 = + s2.createChildTest('s2t1', 'd', ['tag1'], 'suite2.cpp', 1); + const s2t2 = + s2.createChildTest('s2t2', 'd', ['[.]'], 'suite2.cpp', 2); + const s2t3 = + s2.createChildTest('s2t3', 'd', ['tag1'], 'suite2.cpp', 3); + + tests = { + root: root, + s1: s1, + s1t1: s1t1, + s1t2: s1t2, + s2: s2, + s2t1: s2t1, + s2t2: s2t2, + s2t3: s2t3 + } + }); + }); - assert.equal('test', testStatesEvents[2].type); - assert.equal('running', (testStatesEvents[2]).state); - assert.equal(s.s1t1, (testStatesEvents[2]).test); + it('run: 1 test (succ)', function() { + const stdout = new Stream.Readable(); + const spawnEvent: any = new EventEmitter(); + spawnEvent.stdout = stdout; + stdout.on('end', () => { + spawnEvent.emit('close', 1); + }); + stdout.push( + ` + + + + + + + + + + `); + stdout.push(null); + spawnStub + .withArgs( + tests.s1.execPath, + [ + tests.s1t1.testNameFull, '--reporter', 'xml', '--durations', + 'yes' + ], + tests.s1.execOptions) + .returns(spawnEvent); + + return adapter.run([tests.s1t1.id]).then(() => { + assert.deepEqual(testStatesEvents, [ + {type: 'started', tests: [tests.s1t1.id]}, + {type: 'suite', state: 'running', suite: tests.s1}, + {type: 'test', state: 'running', test: tests.s1t1}, + { + type: 'test', + state: 'passed', + test: tests.s1t1, + decorations: undefined, + message: 'Randomness seeded to: 2\n' + }, + {type: 'suite', state: 'completed', suite: tests.s1}, + {type: 'finished'}, + ]); + }); + }); + + it('run: 1 test (fails)', function() { + const stdout = new Stream.Readable(); + const spawnEvent: any = new EventEmitter(); + spawnEvent.stdout = stdout; + stdout.on('end', () => { + spawnEvent.emit('close', 1); + }); + stdout.push( + ` + + + + + + + 1 == x % 2 + + + 1 == 0 + + + + + + + + `); + stdout.push(null); + + spawnStub + .withArgs( + tests.s1.execPath, + [ + tests.s1t1.testNameFull, '--reporter', 'xml', '--durations', + 'yes' + ], + tests.s1.execOptions) + .returns(spawnEvent); + + return adapter.run([tests.s1t1.id]).then(() => { + assert.deepEqual(testStatesEvents, [ + {type: 'started', tests: [tests.s1t1.id]}, + {type: 'suite', state: 'running', suite: tests.s1}, + {type: 'test', state: 'running', test: tests.s1t1}, + { + type: 'test', + state: 'failed', + test: tests.s1t1, + decorations: [{line: 213, message: 'Expanded: 1 == 0'}], + message: + 'Randomness seeded to: 2\n>>> s1t1(line: 211) REQUIRE (line: 214) \n Original:\n 1 == x % 2\n Expanded:\n 1 == 0\n<<<\n' + }, + {type: 'suite', state: 'completed', suite: tests.s1}, + {type: 'finished'}, + ]); + }); + }); + + it('run: 1 test (fails) with chunks', function() { + const stdout = new Stream.Readable(); + const spawnEvent: any = new EventEmitter(); + spawnEvent.stdout = stdout; + stdout.on('end', () => { + spawnEvent.emit('close', 1); + }); + + spawnStub + .withArgs( + tests.s1.execPath, + [ + tests.s1t1.testNameFull, '--reporter', 'xml', '--durations', + 'yes' + ], + tests.s1.execOptions) + .returns(spawnEvent); + + stdout.push('\n'); + stdout.push('\n'); + stdout.push(' \n'); + stdout.push(' \n'); + stdout.push( + ' \n'); + stdout.push( + ' \n'); + stdout.push(' \n'); + stdout.push(' 1 == x % 2\n'); + stdout.push(' \n'); + stdout.push(' \n'); + stdout.push(' 1 == 0\n'); + stdout.push(' \n'); + stdout.push(' \n'); + stdout.push(' \n'); + stdout.push(' \n'); + stdout.push( + ' \n'); + stdout.push(' \n'); + stdout.push( + ' \n'); + stdout.push('\n'); + stdout.push(null); + + return adapter.run([tests.s1t1.id]).then(() => { + assert.deepEqual(testStatesEvents, [ + {type: 'started', tests: [tests.s1t1.id]}, + {type: 'suite', state: 'running', suite: tests.s1}, + {type: 'test', state: 'running', test: tests.s1t1}, + { + type: 'test', + state: 'failed', + test: tests.s1t1, + decorations: [{line: 213, message: 'Expanded: 1 == 0'}], + message: + 'Randomness seeded to: 2\n>>> s1t1(line: 211) REQUIRE (line: 214) \n Original:\n 1 == x % 2\n Expanded:\n 1 == 0\n<<<\n' + }, + {type: 'suite', state: 'completed', suite: tests.s1}, + {type: 'finished'}, + ]); + }); + }); + + it('run: 1 suite (1 succ 1 fails)', function() { + const stdout = new Stream.Readable(); + const spawnEvent: any = new EventEmitter(); + spawnEvent.stdout = stdout; + stdout.on('end', () => { + spawnEvent.emit('close', 1); + }); + stdout.push(` + + + + + + + + + + std::false_type::value + + + false + + + + + + + + `); + stdout.push(null); + + spawnStub + .withArgs( + tests.s1.execPath, ['--reporter', 'xml', '--durations', 'yes'], + tests.s1.execOptions) + .returns(spawnEvent); + + return adapter.run([tests.s1.id]).then(() => { + assert.deepEqual(testStatesEvents, [ + {type: 'started', tests: [tests.s1.id]}, + {type: 'suite', state: 'running', suite: tests.s1}, + {type: 'test', state: 'running', test: tests.s1t1}, + { + type: 'test', + state: 'passed', + test: tests.s1t1, + decorations: undefined, + message: 'Randomness seeded to: 2\nDuration: 0.000174 second(s)\n' + }, + {type: 'test', state: 'running', test: tests.s1t2}, + { + type: 'test', + state: 'failed', + test: tests.s1t2, + decorations: [{line: 14, message: 'Expanded: false'}], + message: + 'Randomness seeded to: 2\nDuration: 0.000255 second(s)\n>>> s1t2(line: 13) REQUIRE (line: 15) \n Original:\n std::false_type::value\n Expanded:\n false\n<<<\n' + }, + {type: 'suite', state: 'completed', suite: tests.s1}, + {type: 'finished'}, + ]); + }); + }); + + it('run: tests (1 succ 1 skipps 1 fails) [at least 2 slots]', function() { + { + const stdout = new Stream.Readable(); + const spawnEvent: any = new EventEmitter(); + spawnEvent.stdout = stdout; + stdout.on('end', () => { + spawnEvent.emit('close', 1); + }); + stdout.push(` + + + + + + + + + + std::false_type::value + + + false + + + + + + + + `); + stdout.push(null); + + spawnStub + .withArgs( + tests.s1.execPath, + ['--reporter', 'xml', '--durations', 'yes'], + tests.s1.execOptions) + .returns(spawnEvent); + } { - assert.equal('test', testStatesEvents[3].type); - const res = (testStatesEvents[3]); - assert.equal('failed', res.state); - assert.equal(s.s1t1, res.test); - assert.ok(undefined != res.decorations); - assert.equal(1, res.decorations!.length); - assert.equal(213, res.decorations![0].line); - assert.equal('Expanded: 1 == 0', res.decorations![0].message); + const stdout = new Stream.Readable(); + const spawnEvent: any = new EventEmitter(); + spawnEvent.stdout = stdout; + stdout.on('end', () => { + spawnEvent.emit('close', 1); + }); + stdout.push(` + + + + + + + + + + std::false_type::value + + + false + + + + + + + + `); + stdout.push(null); + + spawnStub + .withArgs( + tests.s2.execPath, + ['--reporter', 'xml', '--durations', 'yes'], + tests.s2.execOptions) + .returns(spawnEvent); } - assert.equal('suite', testStatesEvents[4].type); - assert.equal('completed', (testStatesEvents[4]).state); - assert.equal(s.suite1, (testStatesEvents[4]).suite); + return adapter.run([tests.root.id]).then(() => { + assert.deepEqual( + {type: 'started', tests: [tests.root.id]}, testStatesEvents[0]); + assert.deepEqual( + {type: 'finished'}, + testStatesEvents[testStatesEvents.length - 1]); + + const findIndex = function(o: any) { + const i = testStatesEvents.findIndex((v) => { + return deepEqual(o, v); + }); + assert.notEqual(i, -1, 'findIndex failed to find: ' + inspect(o)); + return i; + }; + + const s1running = {type: 'suite', state: 'running', suite: tests.s1}; + const s1finished = { + type: 'suite', + state: 'completed', + suite: tests.s1 + }; + assert.ok(findIndex(s1running) < findIndex(s1finished)); + + const s2running = {type: 'suite', state: 'running', suite: tests.s2}; + const s2finished = { + type: 'suite', + state: 'completed', + suite: tests.s2 + }; + assert.ok(findIndex(s2running) < findIndex(s2finished)); + + const s1t1running = { + type: 'test', + state: 'running', + test: tests.s1t1 + }; + assert.ok(findIndex(s1running) < findIndex(s1t1running)); + + const s1t1finished = { + type: 'test', + state: 'passed', + test: tests.s1t1, + decorations: undefined, + message: 'Randomness seeded to: 2\nDuration: 0.000174 second(s)\n' + }; + assert.ok(findIndex(s1t1running) < findIndex(s1t1finished)); + assert.ok(findIndex(s1t1finished) < findIndex(s1finished)); + + const s1t2running = { + type: 'test', + state: 'running', + test: tests.s1t2 + }; + assert.ok(findIndex(s1running) < findIndex(s1t2running)); + + const s1t2finished = { + type: 'test', + state: 'failed', + test: tests.s1t2, + decorations: [{line: 14, message: 'Expanded: false'}], + message: + 'Randomness seeded to: 2\nDuration: 0.000255 second(s)\n>>> s1t2(line: 13) REQUIRE (line: 15) \n Original:\n std::false_type::value\n Expanded:\n false\n<<<\n' + }; + assert.ok(findIndex(s1t2running) < findIndex(s1t2finished)); + assert.ok(findIndex(s1t2finished) < findIndex(s1finished)); + + const s2t1running = { + type: 'test', + state: 'running', + test: tests.s2t1 + }; + assert.ok(findIndex(s2running) < findIndex(s2t1running)); + + const s2t1finished = { + type: 'test', + state: 'passed', + test: tests.s2t1, + decorations: undefined, + message: 'Randomness seeded to: 2\nDuration: 0.000165 second(s)\n' + }; + assert.ok(findIndex(s2t1running) < findIndex(s2t1finished)); + assert.ok(findIndex(s2t1finished) < findIndex(s2finished)); + + const s2t2running = { + type: 'test', + state: 'running', + test: tests.s2t2 + }; + assert.ok(findIndex(s2running) < findIndex(s2t2running)); + + const s2t2finished = { + type: 'test', + state: 'skipped', + test: tests.s2t2 + }; + assert.ok(findIndex(s2t2running) < findIndex(s2t2finished)); + assert.ok(findIndex(s2t2finished) < findIndex(s2finished)); + + const s2t3running = { + type: 'test', + state: 'running', + test: tests.s2t3 + }; + assert.ok(findIndex(s2running) < findIndex(s2t3running)); - assert.equal('finished', testStatesEvents[5].type); + const s2t3finished = { + type: 'test', + state: 'failed', + test: tests.s2t3, + decorations: [{line: 20, message: 'Expanded: false'}], + message: + 'Randomness seeded to: 2\nDuration: 0.000199 second(s)\n>>> s2t3(line: 19) REQUIRE (line: 21) \n Original:\n std::false_type::value\n Expanded:\n false\n<<<\n' + }; + assert.ok(findIndex(s2t3running) < findIndex(s2t3finished)); + assert.ok(findIndex(s2t3finished) < findIndex(s2finished)); - d.dispose(); + assert.equal(testStatesEvents.length, 16, inspect(testStatesEvents)); + }); }); }); }); -}); +}); \ No newline at end of file diff --git a/src/test/suite1.cpp b/src/test/suite1.cpp new file mode 100644 index 00000000..2882a71e --- /dev/null +++ b/src/test/suite1.cpp @@ -0,0 +1,17 @@ +#define CATCH_CONFIG_MAIN +#include + +// c++ -x c++ -std=c++17 -I ../Catch2/single_include -O0 -g -o suite1 +// ../vscode-catch2-test-adapter/src/test/suite1.cpp + +TEST_CASE("s1t1", "tag1") { + // + REQUIRE(std::true_type::value); + // +} + +TEST_CASE("s1t2", "tag1") { + // + REQUIRE(std::false_type::value); + // +} \ No newline at end of file diff --git a/src/test/suite2.cpp b/src/test/suite2.cpp new file mode 100644 index 00000000..9f2a5515 --- /dev/null +++ b/src/test/suite2.cpp @@ -0,0 +1,23 @@ +#define CATCH_CONFIG_MAIN +#include + +// c++ -x c++ -std=c++17 -I ../Catch2/single_include -O0 -g -o suite2 +// ../vscode-catch2-test-adapter/src/test/suite2.cpp + +TEST_CASE("s2t1", "tag1") { + // + REQUIRE(std::true_type::value); + // +} + +TEST_CASE("s2t2", "tag1 [.]") { + // + REQUIRE(std::true_type::value); + // +} + +TEST_CASE("s2t3", "tag1") { + // + REQUIRE(std::false_type::value); + // +} \ No newline at end of file From d72f0b12a3e67022f36a19e9b95b29273a3d7d9e Mon Sep 17 00:00:00 2001 From: Mate Pek Date: Thu, 18 Oct 2018 23:33:10 +0200 Subject: [PATCH 2/5] travis --- .gitignore | 3 ++- .travis.yml | 19 +++++++++++++++++++ package.json | 4 ++-- 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 .travis.yml diff --git a/.gitignore b/.gitignore index 1581edf2..f683c593 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules out -*.vsix \ No newline at end of file +*.vsix +.vscode-test diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..a1d93af8 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +sudo: false + +os: + - osx + - linux + +before_install: + - if [ $TRAVIS_OS_NAME == "linux" ]; then + export CXX="g++-4.9" CC="gcc-4.9" DISPLAY=:99.0; + sh -e /etc/init.d/xvfb start; + sleep 3; + fi + +install: + - npm install + #- npm run vscode:prepublish + +script: + - npm test --silent \ No newline at end of file diff --git a/package.json b/package.json index c19c6d26..5f1f0e91 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "icon": "icon.png", "author": "Mate Pek", "publisher": "matepek", - "version": "1.1.1", + "version": "1.1.2", "license": "Unlicense", "homepage": "https://github.com/matepek/vscode-catch2-test-adapter", "repository": { @@ -150,4 +150,4 @@ } } } -} +} \ No newline at end of file From c090c1632cb86143083fe1030794e7459d90b298 Mon Sep 17 00:00:00 2001 From: Mate Pek Date: Thu, 18 Oct 2018 23:35:18 +0200 Subject: [PATCH 3/5] README update --- README.md | 2 ++ src/test/C2TestAdapter.test.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 125d744b..10cc2f9f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Catch2 Test Explorer for Visual Studio Code +[![Build Status](https://travis-ci.org/matepek/vscode-catch2-test-adapter.svg?branch=master)](https://travis-ci.org/matepek/vscode-catch2-test-adapter) + This extension allows you to run your [Catch2 tests](https://github.com/catchorg/Catch2) using the [Test Explorer for VS Code](https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-test-explorer). diff --git a/src/test/C2TestAdapter.test.ts b/src/test/C2TestAdapter.test.ts index 3d058d2e..bced92e6 100644 --- a/src/test/C2TestAdapter.test.ts +++ b/src/test/C2TestAdapter.test.ts @@ -33,7 +33,7 @@ const dotVscodePath = path.join(workspaceFolderUri.path, '.vscode'); describe('C2TestAdapter', function() { const config = vscode.workspace.getConfiguration( - 'catch2TestExplorer', workspaceFolderUri); + 'catch2TestExplorer', workspaceFolderUri); const disposable: vscode.Disposable[] = []; From 0bb0ae0a61ba42adba81097a6c4c44d7320ff5fa Mon Sep 17 00:00:00 2001 From: Mate Pek Date: Thu, 18 Oct 2018 23:42:38 +0200 Subject: [PATCH 4/5] travis.yml fix --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a1d93af8..f6565979 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ before_install: install: - npm install + - npm run compile #- npm run vscode:prepublish script: From b2c7d752e2289e6cbb39b42abe68d77f57bd447a Mon Sep 17 00:00:00 2001 From: Mate Pek Date: Fri, 19 Oct 2018 09:00:10 +0200 Subject: [PATCH 5/5] More tests and refactors --- src/C2TestSuiteInfo.ts | 37 ++- src/test/C2TestAdapter.test.ts | 499 ++++++++++++++++++++++++--------- 2 files changed, 384 insertions(+), 152 deletions(-) diff --git a/src/C2TestSuiteInfo.ts b/src/C2TestSuiteInfo.ts index 4f5135a3..448e36e4 100644 --- a/src/C2TestSuiteInfo.ts +++ b/src/C2TestSuiteInfo.ts @@ -150,16 +150,18 @@ export class C2TestSuiteInfo implements TestSuiteInfo { const data = new class { buffer: string = ''; currentChild: C2TestInfo|undefined = undefined; - inTestCase: boolean = false; beforeFirstTestCase: boolean = true; rngSeed: number|undefined = undefined; + inTestCase(): boolean { + return this.currentChild != undefined; + }; } (); const processChunk = (chunk: string) => { data.buffer = data.buffer + chunk; do { - if (!data.inTestCase) { + if (!data.inTestCase()) { const b = data.buffer.indexOf(' { return v.testNameTrimmed == name; }); @@ -218,7 +218,6 @@ export class C2TestSuiteInfo implements TestSuiteInfo { } } - data.inTestCase = false; data.currentChild = undefined; data.buffer = data.buffer.substr(b + endTestCase.length); } @@ -231,24 +230,34 @@ export class C2TestSuiteInfo implements TestSuiteInfo { }); this.proc.on('close', (code: number) => { - if (data.inTestCase) + if (data.inTestCase()) { (pRejecter != undefined) && pRejecter(); - else + } else { (pResolver != undefined) && pResolver(); + } }); + const suiteFinally = () => { + this.proc = undefined; + this.releaseSlot(); + this.adapter.testStatesEmitter.fire( + {type: 'suite', suite: this, state: 'completed'}); + }; return p .then(() => { - this.releaseSlot(); - this.proc = undefined; + suiteFinally(); }) .catch((err: Error) => { - this.releaseSlot(); + if (data.inTestCase()) { + this.adapter.testStatesEmitter.fire({ + type: 'test', + test: data.currentChild!, + state: 'failed', + message: 'Unexpected test error. (Is Catch2 crashed?)\n' + }); + } this.adapter.log.error(err.message); - }) - .then(() => { - this.adapter.testStatesEmitter.fire( - {type: 'suite', suite: this, state: 'completed'}); + suiteFinally(); }); } diff --git a/src/test/C2TestAdapter.test.ts b/src/test/C2TestAdapter.test.ts index bced92e6..3b421e11 100644 --- a/src/test/C2TestAdapter.test.ts +++ b/src/test/C2TestAdapter.test.ts @@ -42,6 +42,22 @@ describe('C2TestAdapter', function() { let testStatesEvents: (TestRunStartedEvent|TestRunFinishedEvent| TestSuiteEvent|TestEvent)[]; + const resetConfig = function(): Thenable { + const packageJson = fs.readJSONSync( + path.join(workspaceFolderUri.path, '../..', 'package.json')); + const properties: {[prop: string]: any}[] = + packageJson['contributes']['configuration']['properties']; + let t: Thenable = Promise.resolve(); + Object.keys(properties).forEach(key => { + assert.ok(key.startsWith('catch2TestExplorer.')); + const k = key.replace('catch2TestExplorer.', '') + t = t.then(() => { + return config.update(k, undefined); + }); + }); + return t; + }; + const createAdapterAndSubscribe = function() { adapter = new myExtension.C2TestAdapter(workspaceFolder, logger); testsEvents = []; @@ -62,7 +78,7 @@ describe('C2TestAdapter', function() { beforeEach(() => { fs.removeSync(dotVscodePath); - return config.update('defaultRngSeed', undefined); + return resetConfig(); }); afterEach(() => { @@ -126,6 +142,8 @@ describe('C2TestAdapter', function() { }); }); + // describe('example1' + describe('adapter:', () => { beforeEach(() => { createAdapterAndSubscribe(); @@ -145,6 +163,72 @@ describe('C2TestAdapter', function() { describe('load: example1', function() { let tests: any; + const randomnessXml = ``; + + const s1t1Xml = ` + + + `; + + const s1t2Xml = ` + + + + std::false_type::value + + + false + + + + ;`; + + const s1HeaderXml = ` + + + `; + + const s1Xml = s1HeaderXml + s1t1Xml + s1t2Xml + ` + + + + `; + + const s2t1Xml = ` + + + `; + + const s2t2Xml = ` + + + `; + + const s2t3Xml = ` + + + + std::false_type::value + + + false + + + + `; + + const s2HeaderXml = ` + + ` + + randomnessXml + ` + `; + + const s2Xml = s2HeaderXml + s2t1Xml + /* s2t2 is skipped */ s2t3Xml + ` + + + + `; + beforeEach(() => { return adapter.load() .then(() => { @@ -188,19 +272,11 @@ describe('C2TestAdapter', function() { spawnEvent.emit('close', 1); }); stdout.push( - ` - - - - - - - - - - `); + s1HeaderXml + s1t1Xml + + ` + + + `); stdout.push(null); spawnStub @@ -223,15 +299,16 @@ describe('C2TestAdapter', function() { state: 'passed', test: tests.s1t1, decorations: undefined, - message: 'Randomness seeded to: 2\n' + message: 'Randomness seeded to: 2\nDuration: 0.000174 second(s)\n' }, {type: 'suite', state: 'completed', suite: tests.s1}, {type: 'finished'}, ]); }); }); + // it('run: 1 test (succ)' - it('run: 1 test (fails)', function() { + it('run: 1 test (missing)', function() { const stdout = new Stream.Readable(); const spawnEvent: any = new EventEmitter(); spawnEvent.stdout = stdout; @@ -239,26 +316,11 @@ describe('C2TestAdapter', function() { spawnEvent.emit('close', 1); }); stdout.push( - ` - - - - - - - 1 == x % 2 - - - 1 == 0 - - - - - - - - `); + s1HeaderXml + + ` + + + `); stdout.push(null); spawnStub @@ -275,20 +337,100 @@ describe('C2TestAdapter', function() { assert.deepEqual(testStatesEvents, [ {type: 'started', tests: [tests.s1t1.id]}, {type: 'suite', state: 'running', suite: tests.s1}, - {type: 'test', state: 'running', test: tests.s1t1}, + {type: 'suite', state: 'completed', suite: tests.s1}, + {type: 'finished'}, + ]); + }); + }); + // it('run: 1 test (missing)' + + it('run: 1 test (skipped)', function() { + const stdout = new Stream.Readable(); + const spawnEvent: any = new EventEmitter(); + spawnEvent.stdout = stdout; + stdout.on('end', () => { + spawnEvent.emit('close', 1); + }); + stdout.push(s2HeaderXml + s2t2Xml + ` + + + + `); + stdout.push(null); + + spawnStub + .withArgs( + tests.s2.execPath, + [ + tests.s2t2.testNameFull, '--reporter', 'xml', '--durations', + 'yes' + ], + tests.s2.execOptions) + .returns(spawnEvent); + + return adapter.run([tests.s2t2.id]).then(() => { + assert.deepEqual(testStatesEvents, [ + {type: 'started', tests: [tests.s2t2.id]}, + {type: 'suite', state: 'running', suite: tests.s2}, + {type: 'test', state: 'running', test: tests.s2t2}, + { + type: 'test', + state: 'passed', + test: tests.s2t2, + decorations: undefined, + message: 'Randomness seeded to: 2\n' + }, + {type: 'suite', state: 'completed', suite: tests.s2}, + {type: 'finished'}, + ]); + }); + }); + // it('run: 1 test (skipped)' + + it('run: 1 test (fails)', function() { + const stdout = new Stream.Readable(); + const spawnEvent: any = new EventEmitter(); + spawnEvent.stdout = stdout; + stdout.on('end', () => { + spawnEvent.emit('close', 1); + }); + stdout.push( + s2HeaderXml + s2t3Xml + + ` + + + `); + stdout.push(null); + + spawnStub + .withArgs( + tests.s2.execPath, + [ + tests.s2t3.testNameFull, '--reporter', 'xml', '--durations', + 'yes' + ], + tests.s2.execOptions) + .returns(spawnEvent); + + return adapter.run([tests.s2t3.id]).then(() => { + assert.deepEqual(testStatesEvents, [ + {type: 'started', tests: [tests.s2t3.id]}, + {type: 'suite', state: 'running', suite: tests.s2}, + {type: 'test', state: 'running', test: tests.s2t3}, { type: 'test', state: 'failed', - test: tests.s1t1, - decorations: [{line: 213, message: 'Expanded: 1 == 0'}], + test: tests.s2t3, + decorations: [{line: 20, message: 'Expanded: false'}], message: - 'Randomness seeded to: 2\n>>> s1t1(line: 211) REQUIRE (line: 214) \n Original:\n 1 == x % 2\n Expanded:\n 1 == 0\n<<<\n' + 'Randomness seeded to: 2\nDuration: 0.000199 second(s)\n>>> s2t3(line: 19) REQUIRE (line: 21) \n Original:\n std::false_type::value\n Expanded:\n false\n<<<\n' }, - {type: 'suite', state: 'completed', suite: tests.s1}, + {type: 'suite', state: 'completed', suite: tests.s2}, {type: 'finished'}, ]); }); }); + // it('run: 1 test (fails)' it('run: 1 test (fails) with chunks', function() { const stdout = new Stream.Readable(); @@ -300,32 +442,16 @@ describe('C2TestAdapter', function() { spawnStub .withArgs( - tests.s1.execPath, + tests.s2.execPath, [ - tests.s1t1.testNameFull, '--reporter', 'xml', '--durations', + tests.s2t3.testNameFull, '--reporter', 'xml', '--durations', 'yes' ], tests.s1.execOptions) .returns(spawnEvent); - stdout.push('\n'); - stdout.push('\n'); - stdout.push(' \n'); - stdout.push(' \n'); - stdout.push( - ' \n'); - stdout.push( - ' \n'); - stdout.push(' \n'); - stdout.push(' 1 == x % 2\n'); - stdout.push(' \n'); - stdout.push(' \n'); - stdout.push(' 1 == 0\n'); - stdout.push(' \n'); - stdout.push(' \n'); - stdout.push(' \n'); - stdout.push(' \n'); + s2HeaderXml.split('\n').forEach((l: string) => {stdout.push(l)}); + s2t3Xml.split('\n').forEach((l: string) => {stdout.push(l)}); stdout.push( ' \n'); stdout.push(' \n'); @@ -334,54 +460,34 @@ describe('C2TestAdapter', function() { stdout.push('\n'); stdout.push(null); - return adapter.run([tests.s1t1.id]).then(() => { + return adapter.run([tests.s2t3.id]).then(() => { assert.deepEqual(testStatesEvents, [ - {type: 'started', tests: [tests.s1t1.id]}, - {type: 'suite', state: 'running', suite: tests.s1}, - {type: 'test', state: 'running', test: tests.s1t1}, + {type: 'started', tests: [tests.s2t3.id]}, + {type: 'suite', state: 'running', suite: tests.s2}, + {type: 'test', state: 'running', test: tests.s2t3}, { type: 'test', state: 'failed', - test: tests.s1t1, - decorations: [{line: 213, message: 'Expanded: 1 == 0'}], + test: tests.s2t3, + decorations: [{line: 20, message: 'Expanded: false'}], message: - 'Randomness seeded to: 2\n>>> s1t1(line: 211) REQUIRE (line: 214) \n Original:\n 1 == x % 2\n Expanded:\n 1 == 0\n<<<\n' + 'Randomness seeded to: 2\nDuration: 0.000199 second(s)\n>>> s2t3(line: 19) REQUIRE (line: 21) \n Original:\n std::false_type::value\n Expanded:\n false\n<<<\n' }, - {type: 'suite', state: 'completed', suite: tests.s1}, + {type: 'suite', state: 'completed', suite: tests.s2}, {type: 'finished'}, ]); }); }); + // it('run: 1 test (fails) with chunks' - it('run: 1 suite (1 succ 1 fails)', function() { + it('run: suite1 (1 succ 1 fails)', function() { const stdout = new Stream.Readable(); const spawnEvent: any = new EventEmitter(); spawnEvent.stdout = stdout; stdout.on('end', () => { spawnEvent.emit('close', 1); }); - stdout.push(` - - - - - - - - - - std::false_type::value - - - false - - - - - - - - `); + stdout.push(s1Xml); stdout.push(null); spawnStub @@ -416,8 +522,9 @@ describe('C2TestAdapter', function() { ]); }); }); + // it('run: suite1 (1 succ 1 fails)' - it('run: tests (1 succ 1 skipps 1 fails) [at least 2 slots]', function() { + it('run: root (at least 2 slots)', function() { { const stdout = new Stream.Readable(); const spawnEvent: any = new EventEmitter(); @@ -425,28 +532,7 @@ describe('C2TestAdapter', function() { stdout.on('end', () => { spawnEvent.emit('close', 1); }); - stdout.push(` - - - - - - - - - - std::false_type::value - - - false - - - - - - - - `); + stdout.push(s1Xml); stdout.push(null); spawnStub @@ -463,28 +549,7 @@ describe('C2TestAdapter', function() { stdout.on('end', () => { spawnEvent.emit('close', 1); }); - stdout.push(` - - - - - - - - - - std::false_type::value - - - false - - - - - - - - `); + stdout.push(s2Xml); stdout.push(null); spawnStub @@ -614,6 +679,164 @@ describe('C2TestAdapter', function() { assert.equal(testStatesEvents.length, 16, inspect(testStatesEvents)); }); }); + // it('run: root (at least 2 slots)' + + it('run: wrong xml 1', function() { + const stdout = new Stream.Readable(); + const spawnEvent: any = new EventEmitter(); + spawnEvent.stdout = stdout; + stdout.on('end', () => { + spawnEvent.emit('close', 1); + }); + const testCaseBegin = s1t1Xml.split('\n')[1]; + assert.ok(testCaseBegin.indexOf(' { + assert.deepEqual(testStatesEvents, [ + {type: 'started', tests: [tests.s1t1.id]}, + {type: 'suite', state: 'running', suite: tests.s1}, + {type: 'test', state:'running', test: tests.s1t1}, + + { + type: 'test', + state: 'failed', + test: tests.s1t1, + message: 'Unexpected test error. (Is Catch2 crashed?)\n' + }, + + //{type: 'suite', state: 'completed', suite: tests.s1}, + {type: 'finished'}, + ]); + }); + }); + // it('run: wrong xml 1' + + it('cancel: empty', function() { + adapter.cancel(); + }); + // it('cancel: empty' + + it('cancel', function() { + const suite1Kill = sinon.spy(); + const suite2Kill = sinon.spy(); + { + const stdout = new Stream.Readable(); + const spawnEvent: any = new EventEmitter(); + spawnEvent.kill = suite1Kill; + spawnEvent.stdout = stdout; + stdout.on('end', () => { + spawnEvent.emit('close', 1); + }); + stdout.push(s1Xml); + stdout.push(null); + + spawnStub + .withArgs( + tests.s1.execPath, + ['--reporter', 'xml', '--durations', 'yes'], + tests.s1.execOptions) + .returns(spawnEvent); + } + { + const stdout = new Stream.Readable(); + const spawnEvent: any = new EventEmitter(); + spawnEvent.kill = suite2Kill; + spawnEvent.stdout = stdout; + stdout.on('end', () => { + spawnEvent.emit('close', 1); + }); + stdout.push(s2Xml); + stdout.push(null); + + spawnStub + .withArgs( + tests.s2.execPath, + ['--reporter', 'xml', '--durations', 'yes'], + tests.s2.execOptions) + .returns(spawnEvent); + } + const run = adapter.run([tests.root.id]); + adapter.cancel(); + run.then(() => { + assert.deepEqual( + testStatesEvents, + [{type: 'started', tests: [tests.root.id]}, {type: 'finished'}]); + assert.equal(suite1Kill.callCount, 1); + assert.equal(suite2Kill.callCount, 1); + }); + }); + // it('cancel' + + it('cancel: after run finished', function() { + const suite1Kill = sinon.spy(); + const suite2Kill = sinon.spy(); + { + const stdout = new Stream.Readable(); + const spawnEvent: any = new EventEmitter(); + spawnEvent.kill = suite1Kill; + spawnEvent.stdout = stdout; + stdout.on('end', () => { + spawnEvent.emit('close', 1); + }); + stdout.push(s1Xml); + stdout.push(null); + + spawnStub + .withArgs( + tests.s1.execPath, + ['--reporter', 'xml', '--durations', 'yes'], + tests.s1.execOptions) + .returns(spawnEvent); + } + { + const stdout = new Stream.Readable(); + const spawnEvent: any = new EventEmitter(); + spawnEvent.kill = suite2Kill; + spawnEvent.stdout = stdout; + stdout.on('end', () => { + spawnEvent.emit('close', 1); + }); + stdout.push(s2Xml); + stdout.push(null); + + spawnStub + .withArgs( + tests.s2.execPath, + ['--reporter', 'xml', '--durations', 'yes'], + tests.s2.execOptions) + .returns(spawnEvent); + } + const run = adapter.run([tests.root.id]); + run.then(() => { + adapter.cancel(); + assert.equal(suite1Kill.callCount, 0); + assert.equal(suite2Kill.callCount, 0); + }); + }); + // it('cancel: after run finished' }); + // describe('load: example1' }); -}); \ No newline at end of file + // describe('adapter:' +}); +// describe('C2TestAdapter' + +// fswatcher test aztan atiras vscode workspace watcherre +// bonyolultabb teszteset parsoleasa de az mehet kulon fileba c2testinfo +// mock getExecutables regex meg sima minden test +// cancel test +// ExecutableConfig +// execOptions +// writing xml \ No newline at end of file