From 0aeb53435ecfd305b5896d60bc99e8189d9dfa0e Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Wed, 5 Oct 2016 21:31:51 -0700 Subject: [PATCH 1/8] add tips for testing --- docs/development/build-instructions-osx.md | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/docs/development/build-instructions-osx.md b/docs/development/build-instructions-osx.md index bca4dd61090e..0cf7a40d415a 100644 --- a/docs/development/build-instructions-osx.md +++ b/docs/development/build-instructions-osx.md @@ -16,7 +16,7 @@ the following Python modules: ## Getting the Code ```bash -$ git clone https://github.com/electron/electron.git +$ git clone https://github.com/electron/electron ``` ## Bootstrapping @@ -64,11 +64,28 @@ $ npm run clean Test your changes conform to the project coding style using: ```bash -$ ./script/cpplint.py +$ npm run lint ``` Test functionality using: ```bash -$ ./script/test.py +$ npm test +``` + +You can make the test suite run faster by isolating the specific test or block +you're currently working on using Mocha's +[exclusive tests](https://mochajs.org/#exclusive-tests) feature: + +```js +describe.only('some feature', function () { + // ... only tests in this block will be run +}) +``` + +Alternatively, you can use mocha's `grep` option to only run tests matching the +given regular expression pattern: + +```sh +npm test -- --grep child_process ``` From 45d9cc6405c3eb921b8aa9710c81bf9e75f869c9 Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Wed, 5 Oct 2016 21:34:13 -0700 Subject: [PATCH 2/8] update test dependencies --- spec/package.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/package.json b/spec/package.json index 32b41b55c74c..8cc1614a27ec 100644 --- a/spec/package.json +++ b/spec/package.json @@ -4,16 +4,16 @@ "main": "static/main.js", "version": "0.1.0", "devDependencies": { - "basic-auth": "^1.0.0", - "graceful-fs": "3.0.5", - "mocha": "2.1.0", - "mkdirp": "0.5.1", - "multiparty": "4.1.2", - "q": "0.9.7", - "temp": "0.8.1", - "walkdir": "0.0.7", - "ws": "0.7.2", - "yargs": "^4.7.1" + "basic-auth": "^1.0.4", + "graceful-fs": "^4.1.9", + "mkdirp": "^0.5.1", + "mocha": "^3.1.0", + "multiparty": "^4.1.2", + "q": "^1.4.1", + "temp": "^0.8.3", + "walkdir": "0.0.11", + "ws": "^1.1.1", + "yargs": "^6.0.0" }, "optionalDependencies": { "ffi": "2.0.0", From 156d823b7f72aa35e5d020a683ca8728ad6204b4 Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Wed, 5 Oct 2016 21:38:09 -0700 Subject: [PATCH 3/8] remove badge after setBadgeCount test finishes --- spec/api-app-spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/api-app-spec.js b/spec/api-app-spec.js index 6cc6f777739a..69a0ecad455f 100644 --- a/spec/api-app-spec.js +++ b/spec/api-app-spec.js @@ -285,6 +285,7 @@ describe('app module', function () { it('should set a badge count', function () { app.setBadgeCount(42) assert.equal(app.getBadgeCount(), shouldFail ? 0 : 42) + app.setBadgeCount(0) }) }) From a4832c304e29dedf5e0ba3be52610acd15c24a3e Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Wed, 5 Oct 2016 22:21:42 -0700 Subject: [PATCH 4/8] unify testing docs for all platforms --- docs/development/build-instructions-linux.md | 12 +----- docs/development/build-instructions-osx.md | 29 +------------ .../development/build-instructions-windows.md | 22 +--------- docs/development/build-system-overview.md | 41 +++++++++++++++++++ 4 files changed, 44 insertions(+), 60 deletions(-) diff --git a/docs/development/build-instructions-linux.md b/docs/development/build-instructions-linux.md index e6f9b3382666..376b2c8c2d72 100644 --- a/docs/development/build-instructions-linux.md +++ b/docs/development/build-instructions-linux.md @@ -121,17 +121,7 @@ $ sudo ln -s /usr/lib/libncurses.so.5 /usr/lib/libtinfo.so.5 ## Tests -Test your changes conform to the project coding style using: - -```bash -$ npm run lint -``` - -Test functionality using: - -```bash -$ ./script/test.py -``` +See [Build System Overview: Tests](docs/development/build-system-overview.md#tests) ## Advanced topics diff --git a/docs/development/build-instructions-osx.md b/docs/development/build-instructions-osx.md index 0cf7a40d415a..87e66669009f 100644 --- a/docs/development/build-instructions-osx.md +++ b/docs/development/build-instructions-osx.md @@ -61,31 +61,4 @@ $ npm run clean ## Tests -Test your changes conform to the project coding style using: - -```bash -$ npm run lint -``` - -Test functionality using: - -```bash -$ npm test -``` - -You can make the test suite run faster by isolating the specific test or block -you're currently working on using Mocha's -[exclusive tests](https://mochajs.org/#exclusive-tests) feature: - -```js -describe.only('some feature', function () { - // ... only tests in this block will be run -}) -``` - -Alternatively, you can use mocha's `grep` option to only run tests matching the -given regular expression pattern: - -```sh -npm test -- --grep child_process -``` +See [Build System Overview: Tests](docs/development/build-system-overview.md#tests) diff --git a/docs/development/build-instructions-windows.md b/docs/development/build-instructions-windows.md index d66ca18867d2..2aab866a7f35 100644 --- a/docs/development/build-instructions-windows.md +++ b/docs/development/build-instructions-windows.md @@ -87,27 +87,7 @@ $ npm run clean ## Tests -Test your changes conform to the project coding style using: - -```powershell -$ python script\cpplint.py -``` - -Test functionality using: - -```powershell -$ python script\test.py -``` - -Tests that include native modules (e.g. `runas`) can't be executed with the -debug build (see [#2558](https://github.com/electron/electron/issues/2558) for -details), but they will work with the release build. - -To run the tests with the release build use: - -```powershell -$ python script\test.py -R -``` +See [Build System Overview: Tests](docs/development/build-system-overview.md#tests) ## Troubleshooting diff --git a/docs/development/build-system-overview.md b/docs/development/build-system-overview.md index 4336092b7213..4a755dddeeb6 100644 --- a/docs/development/build-system-overview.md +++ b/docs/development/build-system-overview.md @@ -71,3 +71,44 @@ to generate one target at a time as stated above. This only affects developers, if you are just building Electron for rebranding you are not affected. + +## Tests + +Test your changes conform to the project coding style using: + +```bash +$ npm run lint +``` + +Test functionality using: + +```bash +$ npm test +``` + +You can make the test suite run faster by isolating the specific test or block +you're currently working on using Mocha's +[exclusive tests](https://mochajs.org/#exclusive-tests) feature: + +```js +describe.only('some feature', function () { + // ... only tests in this block will be run +}) +``` + +Alternatively, you can use mocha's `grep` option to only run tests matching the +given regular expression pattern: + +```sh +$ npm test -- --grep child_process +``` + +Tests that include native modules (e.g. `runas`) can't be executed with the +debug build (see [#2558](https://github.com/electron/electron/issues/2558) for +details), but they will work with the release build. + +To run the tests with the release build use: + +```bash +$ npm test -- -R +``` From 57852366bb60120a2aacaa47d34f4915dec0a1ea Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Wed, 5 Oct 2016 22:22:01 -0700 Subject: [PATCH 5/8] mention building before testing --- docs/development/build-system-overview.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/development/build-system-overview.md b/docs/development/build-system-overview.md index 4a755dddeeb6..e2d1d7f8f3c3 100644 --- a/docs/development/build-system-overview.md +++ b/docs/development/build-system-overview.md @@ -86,6 +86,13 @@ Test functionality using: $ npm test ``` +Whenever you make changes to Electron source code, you'll need to re-run the +build before the tests: + +```bash +$ npm run build && npm test +``` + You can make the test suite run faster by isolating the specific test or block you're currently working on using Mocha's [exclusive tests](https://mochajs.org/#exclusive-tests) feature: From a8e59ccd3dd2ffe473299f594b919dc6847a07a7 Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Thu, 6 Oct 2016 10:25:33 -0700 Subject: [PATCH 6/8] fix links to testing docs --- docs/development/build-instructions-linux.md | 2 +- docs/development/build-instructions-osx.md | 2 +- docs/development/build-instructions-windows.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/development/build-instructions-linux.md b/docs/development/build-instructions-linux.md index 376b2c8c2d72..2cdfbc73d7d0 100644 --- a/docs/development/build-instructions-linux.md +++ b/docs/development/build-instructions-linux.md @@ -121,7 +121,7 @@ $ sudo ln -s /usr/lib/libncurses.so.5 /usr/lib/libtinfo.so.5 ## Tests -See [Build System Overview: Tests](docs/development/build-system-overview.md#tests) +See [Build System Overview: Tests](build-system-overview.md#tests) ## Advanced topics diff --git a/docs/development/build-instructions-osx.md b/docs/development/build-instructions-osx.md index 87e66669009f..2bf706dba877 100644 --- a/docs/development/build-instructions-osx.md +++ b/docs/development/build-instructions-osx.md @@ -61,4 +61,4 @@ $ npm run clean ## Tests -See [Build System Overview: Tests](docs/development/build-system-overview.md#tests) +See [Build System Overview: Tests](build-system-overview.md#tests) diff --git a/docs/development/build-instructions-windows.md b/docs/development/build-instructions-windows.md index 2aab866a7f35..a506bb295924 100644 --- a/docs/development/build-instructions-windows.md +++ b/docs/development/build-instructions-windows.md @@ -87,7 +87,7 @@ $ npm run clean ## Tests -See [Build System Overview: Tests](docs/development/build-system-overview.md#tests) +See [Build System Overview: Tests](build-system-overview.md#tests) ## Troubleshooting From 37c53f2e09709304bfee803652580960b6791151 Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Thu, 6 Oct 2016 10:27:33 -0700 Subject: [PATCH 7/8] clarify mocha test exclusion --- docs/development/build-system-overview.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/development/build-system-overview.md b/docs/development/build-system-overview.md index e2d1d7f8f3c3..df12df6ae970 100644 --- a/docs/development/build-system-overview.md +++ b/docs/development/build-system-overview.md @@ -95,7 +95,8 @@ $ npm run build && npm test You can make the test suite run faster by isolating the specific test or block you're currently working on using Mocha's -[exclusive tests](https://mochajs.org/#exclusive-tests) feature: +[exclusive tests](https://mochajs.org/#exclusive-tests) feature. Just append +`.only` to any `describe` or `it` function call: ```js describe.only('some feature', function () { From af0098f064d7084b9fe305a1a1e52403ed5061de Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Thu, 6 Oct 2016 10:29:55 -0700 Subject: [PATCH 8/8] remove badge count after each setBadgeCount test --- spec/api-app-spec.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/api-app-spec.js b/spec/api-app-spec.js index 69a0ecad455f..2afce4dc1672 100644 --- a/spec/api-app-spec.js +++ b/spec/api-app-spec.js @@ -278,6 +278,10 @@ describe('app module', function () { const shouldFail = process.platform === 'win32' || (process.platform === 'linux' && !app.isUnityRunning()) + afterEach(function () { + app.setBadgeCount(0) + }) + it('returns false when failed', function () { assert.equal(app.setBadgeCount(42), !shouldFail) }) @@ -285,7 +289,6 @@ describe('app module', function () { it('should set a badge count', function () { app.setBadgeCount(42) assert.equal(app.getBadgeCount(), shouldFail ? 0 : 42) - app.setBadgeCount(0) }) })