Skip to content

Commit

Permalink
Merge pull request #1468 from apiaryio/remove-coveralls
Browse files Browse the repository at this point in the history
chore: removes test coverage
  • Loading branch information
honzajavorek authored Aug 19, 2019
2 parents 31dcefc + 495ddf3 commit 7253741
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 140 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
[![Build Status](https://travis-ci.org/apiaryio/dredd.svg?branch=master)](https://travis-ci.org/apiaryio/dredd)
[![Build Status](https://ci.appveyor.com/api/projects/status/n3ixfxh72qushyr4/branch/master?svg=true)](https://ci.appveyor.com/project/Apiary/dredd/branch/master)
[![Documentation Status](https://readthedocs.org/projects/dredd/badge/?version=latest)](https://readthedocs.org/projects/dredd/builds/)
[![Coverage Status](https://coveralls.io/repos/apiaryio/dredd/badge.svg?branch=master)](https://coveralls.io/github/apiaryio/dredd)
[![Known Vulnerabilities](https://snyk.io/test/npm/dredd/badge.svg)](https://snyk.io/test/npm/dredd)

![Dredd - HTTP API Testing Framework](docs/_static/images/dredd.png?raw=true)
Expand Down
36 changes: 0 additions & 36 deletions bin/dredd
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#!/usr/bin/env node

/* eslint-disable global-require */

const fs = require('fs');
const path = require('path');

// Ignore this block, it's pure magic, temporary fix
// for https://github.com/nodejs/node/issues/6456
[process.stdout, process.stderr].forEach((s) => {
Expand All @@ -22,35 +17,4 @@ const dreddCli = new CLI({
},
});

if (process.env.COVERAGE_DIR) {
process.on('exit', () => {
// Before Dredd exits, we need to collect coverage stats and save them to
// a file. We abuse 'mocha-lcov-reporter' to do this.
const LCov = require('mocha-lcov-reporter');

// Pretending there is Mocha runner
const EventEmitter = require('events').EventEmitter;
const runner = new EventEmitter();

// Monkey-patching 'LCov.prototype.write' to catch all output to a variable
let content = '';
const write = LCov.prototype.write;

LCov.prototype.write = (string) => {
content += string;
};

// Collecting the stats
new LCov(runner);
runner.emit('end');

// Undo the monkey-patching
LCov.prototype.write = write;

// Save stats as lcov file
const file = path.join(process.env.COVERAGE_DIR, 'dredd-bin.info');
fs.appendFileSync(file, content);
});
}

dreddCli.run();
20 changes: 1 addition & 19 deletions docs/internals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,27 +185,9 @@ Coverage

Tests coverage is a metric which helps developer to see which code **is not** tested. This is useful when introducing new code in Pull Requests or when maintaining under-tested old code (coverage shows that changes to such code are without any safety net).

We strive for as much test coverage as possible. `Coveralls <https://coveralls.io/github/apiaryio/dredd>`__ help us to monitor how successful we are in achieving the goal. If a Pull Request introduces drop in coverage, it won’t be accepted unless the author or reviewer provides a good reason why an exception should be made.

.. note::

Currently the integration is broken and while we're sending data to Coveralls, they do not report back under Pull Requests. Multiple sessions to debug the problem were not successful and we are considering to replace the service.

The Travis CI build uses following commands to deliver coverage reports:

- ``npm run test:coverage`` - Tests Dredd and creates the ``./coverage/lcov.info`` file
- ``npm run coveralls`` - Uploads the ``./coverage/lcov.info`` file to Coveralls

The first mentioned command does following:

#. Uses `istanbul <https://github.com/gotwarlost/istanbul>`__ to instrument the JavaScript code
#. Runs the tests on the instrumented code using Mocha with a special lcov reporter, which gives us information about which lines were executed in the standard lcov format
#. Because some integration tests execute the ``bin/dredd`` script in a subprocess, we collect the coverage stats also in this file. The results are appended to a dedicated lcov file
#. All lcov files are then merged into one using the `lcov-result-merger <https://github.com/mweibel/lcov-result-merger>`__ utility and sent to Coveralls

Hand-made combined Mocha reporter is used to achieve running tests and collecting coverage at the same time.

Both Dredd code and the combined reporter decide whether to collect coverage or not according to contents of the ``COVERAGE_DIR`` environment variable, which sets the directory for temporary lcov files created during coverage collection. If the variable is set, collecting takes place.
Due to reoccurring service denial from Coveralls, we have decided to remove any test coverage integration from Dredd. The topic of test coverage usefulness is to be discussed, and a suitable solution to be presented.


.. _hacking-apiary-reporter:
Expand Down
8 changes: 1 addition & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@
"lint": "./scripts/commitlint.sh && eslint . bin/dredd",
"test": "mocha \"./test/**/*-test.js\"",
"test:debug": "mocha --debug-brk \"./test/**/*-test.js\"",
"test:coverage": "bash ./scripts/coverage.sh",
"e2e": "npm run e2e:apib && npm run e2e:openapi2",
"e2e:apib": "cucumber-js",
"e2e:openapi2": "cucumber-js --world-parameters=\"{\\\"apiDescriptionFormat\\\": \\\"application/swagger+yaml\\\"}\"",
"coveralls": "./scripts/coveralls.sh",
"ci:lint": "npm run lint && npm run docs:lint && npm run docs:test-extensions",
"ci:docs": "npm run docs:build",
"ci:test": "npm run test:coverage && npm run coveralls",
"ci:test": "npm test",
"ci:smoke": "bash ./scripts/smoke.sh",
"ci:release": "semantic-release && npm dist-tag add \"dredd@$(npm view dredd version)\" stable"
},
Expand Down Expand Up @@ -68,16 +66,12 @@
"@commitlint/travis-cli": "8.1.0",
"body-parser": "1.19.0",
"coffeescript": "2.4.1",
"coveralls": "3.0.6",
"cucumber": "5.1.0",
"eslint": "5.16.0",
"eslint-config-airbnb-base": "13.2.0",
"eslint-plugin-import": "2.18.2",
"express": "4.17.1",
"istanbul": "0.4.5",
"lcov-result-merger": "3.1.0",
"mocha": "6.2.0",
"mocha-lcov-reporter": "1.3.0",
"nock": "10.0.6",
"ps-node": "0.1.6",
"semantic-release": "15.13.17",
Expand Down
33 changes: 0 additions & 33 deletions scripts/coverage.sh

This file was deleted.

14 changes: 0 additions & 14 deletions scripts/coveralls.sh

This file was deleted.

1 change: 0 additions & 1 deletion test/mocha.opts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
--reporter=test/reporter.js
--timeout=120000
--recursive
29 changes: 0 additions & 29 deletions test/reporter.js

This file was deleted.

0 comments on commit 7253741

Please sign in to comment.