Improve code quality and write tests

This commit is contained in:
Shivam Mathur
2019-09-20 08:11:20 +05:30
parent db44db4b97
commit 43178a7254
3597 changed files with 255478 additions and 785554 deletions

14
node_modules/codecov/.eslintrc.json generated vendored Normal file
View File

@ -0,0 +1,14 @@
{
"extends": ["eslint:recommended", "prettier"],
"env": {
"node": true,
"jest": true
},
"globals": {
"expect": true
},
"rules": {
"no-console": "off",
"no-empty": ["error", { "allowEmptyCatch": true }]
}
}

3
node_modules/codecov/.prettierignore generated vendored Normal file
View File

@ -0,0 +1,3 @@
node_modules/
.git/
coverage/

6
node_modules/codecov/.prettierrc generated vendored Normal file
View File

@ -0,0 +1,6 @@
{
"semi": false,
"trailingComma": "es5",
"singleQuote": true,
"useTabs": false
}

14
node_modules/codecov/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,14 @@
language: node_js
sudo: false
node_js:
- '11'
- '10'
- '9'
- '8'
- '7'
- '6'
after_success:
- ./bin/codecov -e TRAVIS_NODE_VERSION -f coverage/*.json

76
node_modules/codecov/CODE_OF_CONDUCT.md generated vendored Normal file
View File

@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at hello@codecov.io. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq

21
node_modules/codecov/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Gregg Caines
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

108
node_modules/codecov/README.md generated vendored Normal file
View File

@ -0,0 +1,108 @@
# Codecov NodeJS Uploader
[![NPM version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]
[![Build Status][appveyor-image]][appveyor-url]
[![codecov.io](https://codecov.io/github/codecov/codecov-node/coverage.svg?branch=master)](https://codecov.io/github/codecov/codecov-node?branch=master)
[![Dependency Status][depstat-image]][depstat-url]
[![Dev Dependency Status][devdepstat-image]][devdepstat-url]
[Codecov.io](https://codecov.io/) support for node.js.
## Installation:
Add the latest version of `codecov` to your package.json:
```
npm install codecov --save-dev
```
or
```
yarn add codecov --dev
```
## Usage:
This script ( `bin/codecov` ) detect your CI provider and all coverage reports and uploads them to Codecov.
Once your app is instrumented for coverage, and building, simply call `./node_modules/.bin/codecov`.
This library currently supports the following CI companies: [Travis CI](https://travis-ci.org/), [Travis](https://travis-ci.com/), [Appveyor](https://appveyor.com/), [CircleCI](https://circleci.com/), [Cirrus CI](https://cirrus-ci.org/), [Codeship](https://codeship.io/), [Drone](https://drone.io/), [Jenkins](http://jenkins-ci.org/), [Shippable](https://shippable.com/), [Semaphore](https://semaphoreapp.com/), [Wercker](https://wercker.com/), [Snap CI](https://snap-ci.com/), [Buildkite](https://buildkite.com/).
#### Upload repo tokens
> Repo tokens are **not** required for public repos tested on Travis-Org, CircleCI or AppVeyor.
Repo tokens are necessary to distinguish your repository from others. You can find your repo token on your repository page at Codecov. Set this unique uuid to `CODECOV_TOKEN` in your environment variables.
```
export CODECOV_TOKEN=":uuid-repo-token"
# or
./node_modules/.bin/codecov --token=:token
# or
./node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/codecov --pipe
```
#### [Istanbul](https://github.com/gotwarlost/istanbul)
**With Mocha:**
```sh
istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec
./node_modules/.bin/codecov
```
**With Jasmine:**
```sh
istanbul cover jasmine-node --captureExceptions spec/
./node_modules/.bin/codecov
```
**With Tape:**
```sh
istanbul cover test.js
./node_modules/.bin/codecov
```
[travis-image]: https://travis-ci.org/codecov/codecov-node.svg?branch=master
[travis-url]: https://travis-ci.org/codecov/codecov-node
[appveyor-image]: https://ci.appveyor.com/api/projects/status/ea1suiv0tprnq61l?svg=true
[appveyor-url]: https://ci.appveyor.com/project/eddiemoore/codecov-node/branch/master
[npm-url]: https://npmjs.org/package/codecov
[npm-image]: https://img.shields.io/npm/v/codecov.svg
[depstat-url]: https://david-dm.org/codecov/codecov-node
[depstat-image]: https://img.shields.io/david/codecov/codecov-node/master.svg
[devdepstat-url]: https://david-dm.org/codecov/codecov-node#info=devDependencies
[devdepstat-image]: https://img.shields.io/david/dev/codecov/codecov-node/master.svg
**With NYC**
```
nyc npm test
nyc report --reporter=text-lcov > coverage.lcov
./node_modules/.bin/codecov
```
## Change Log
- v2.0.0 No longer supports node v0.10 because of the execSync.
- v2.0.1 Publish as latest instead of next.
- v2.0.2 Display correct version number in console.
- v2.1.0 Flags supported http://docs.codecov.io/docs/flags
- v2.2.0 Support for Jenkins Blue Ocean. Clean reports after upload. Fix for Gitlab.
- v2.3.0 Added support for Windows. Updated dependencies.
- v3.0.0 No longer supports node v0.12 because of new version of request
- v3.0.1 Security fixes
- v3.0.2 Security fixes
- v3.0.3 Support non-git/hg root dirs
- v3.0.4 Security fixes
- v3.1.0 Custom yaml file. Allow codecov token from yml file.
- v3.2.0 Added azure pipelines
- v3.3.0 Added pipe with `--pipe`, `-l`
- v3.4.0 Added Heroku CI support
- v3.5.0 Added TeamCity support
- v3.6.0 Added AWS CodeBuild and Semaphore2

30
node_modules/codecov/appveyor.yml generated vendored Normal file
View File

@ -0,0 +1,30 @@
environment:
matrix:
- nodejs_version: '11'
- nodejs_version: '10'
- nodejs_version: '9'
- nodejs_version: '8'
- nodejs_version: '7'
- nodejs_version: '6'
max_jobs: 4
clone_depth: 50
init:
- git config --global core.autocrlf true
install:
- ps: Install-Product node $env:nodejs_version
- npm install
test_script:
- cmd: SET PATH=C:\MinGW\bin;%PATH%
- npm run test
after_test:
- node .\bin\codecov -f coverage\*.json
build: off
deploy: off

41
node_modules/codecov/bin/codecov generated vendored Normal file
View File

@ -0,0 +1,41 @@
#!/usr/bin/env node
var argv = require('argv');
var codecov = require('../lib/codecov');
var args = argv.option([
{name: 'token', short: 't', type: 'string', description: "Private repository token. Not required for public repos on Travis, CircleCI and AppVeyor"},
{name: 'file', short: 'f', type: 'path', description: "Target a specific file for uploading and disabling automatic detection of coverage files."},
{name: 'env', short: 'e', type: 'string', description: "Store environment variables to help distinguish CI builds. Example: http://bit.ly/1ElohCu", example: "--env=VAR1,VAR2,VAR3"},
{name: 'root', short: 'p', type: 'path', description: "Project root, if not current directory"},
{name: 'gcov-root', type: 'path', description: "Project root directory when preparing gcov"},
{name: 'gcov-glob', type: 'string', description: "Paths to ignore during gcov gathering"},
{name: 'gcov-exec', type: 'string', description: "gcov executable to run. Defaults to 'gcov'"},
{name: 'gcov-args', type: 'string', description: "extra arguments to pass to gcov"},
{name: 'disable', short: 'X', type: 'string', description: "Disable features. Accepting `search` to disable crawling through directories, `detect` to disable detecting CI provider, `gcov` disable gcov commands"},
{name: 'commit', short: 'c', type: 'string', description: "Commit sha, set automatically"},
{name: 'clear', short: 'C', type: 'boolean', description: "Remove all discovered reports after uploading"},
{name: 'branch', short: 'b', type: 'string', description: "Branch name"},
{name: 'build', short: 'B', type: 'string', description: "Specify a custom build number to distinguish ci jobs, provided automatically for supported ci companies"},
{name: 'slug', short: 'r', type: 'string', description: "Specify repository slug for Enterprise ex. owner/repo"},
{name: 'url', short: 'u', type: 'string', description: "Your Codecov endpoint"},
{name: 'flags', short: 'F', type: 'string', description: "Codecov Flags"},
{name: 'dump', type: 'boolean', description: "Dump collected data and do not send to Codecov"},
{name: 'pipe', short: 'l', type: 'boolean', description: "Listen to stdin for coverage data"},
{name: 'yml', short: 'y', type: 'string', description: "Configuration file Used to specify the location of the .codecov.yml config file. Defaults to codecov.yml and .codecov.yml"},
]).run();
if (args.options.pipe) {
process.stdin.setEncoding('utf8');
args.options.pipe = [];
process.stdin.on('data', function(report) {
args.options.pipe.push(report);
});
process.stdin.on('end', function() {
codecov.upload(args);
});
} else {
codecov.upload(args);
}

7
node_modules/codecov/circle.yml generated vendored Normal file
View File

@ -0,0 +1,7 @@
machine:
node:
version: 4
test:
post:
- ./bin/codecov -f coverage/*.json

4
node_modules/codecov/codecov.yml generated vendored Normal file
View File

@ -0,0 +1,4 @@
coverage:
parsers:
javascript:
enable_partials: no

3
node_modules/codecov/index.js generated vendored Normal file
View File

@ -0,0 +1,3 @@
var handleInput = require('./lib/codecov')
exports.handleInput = handleInput

563
node_modules/codecov/lib/codecov.js generated vendored Normal file
View File

@ -0,0 +1,563 @@
var fs = require('fs')
var path = require('path')
var request = require('teeny-request').teenyRequest
var urlgrey = require('urlgrey')
var jsYaml = require('js-yaml')
var walk = require('ignore-walk')
var execSync = require('child_process').execSync
var detectProvider = require('./detect')
var version = 'v' + require('../package.json').version
var patterns,
more_patterns = ''
var isWindows =
process.platform.match(/win32/) || process.platform.match(/win64/)
if (!isWindows) {
patterns =
"-type f \\( -name '*coverage.*' " +
"-or -name 'nosetests.xml' " +
"-or -name 'jacoco*.xml' " +
"-or -name 'clover.xml' " +
"-or -name 'report.xml' " +
"-or -name 'cobertura.xml' " +
"-or -name 'luacov.report.out' " +
"-or -name 'lcov.info' " +
"-or -name '*.lcov' " +
"-or -name 'gcov.info' " +
"-or -name '*.gcov' " +
"-or -name '*.lst' \\) " +
"-not -name '*.sh' " +
"-not -name '*.data' " +
"-not -name '*.py' " +
"-not -name '*.class' " +
"-not -name '*.xcconfig' " +
"-not -name 'Coverage.profdata' " +
"-not -name 'phpunit-code-coverage.xml' " +
"-not -name 'coverage.serialized' " +
"-not -name '*.pyc' " +
"-not -name '*.cfg' " +
"-not -name '*.egg' " +
"-not -name '*.whl' " +
"-not -name '*.html' " +
"-not -name '*.js' " +
"-not -name '*.cpp' " +
"-not -name 'coverage.jade' " +
"-not -name 'include.lst' " +
"-not -name 'inputFiles.lst' " +
"-not -name 'createdFiles.lst' " +
"-not -name 'coverage.html' " +
"-not -name 'scoverage.measurements.*' " +
"-not -name 'test_*_coverage.txt' " +
"-not -path '*/vendor/*' " +
"-not -path '*/htmlcov/*' " +
"-not -path '*/home/cainus/*' " +
"-not -path '*/virtualenv/*' " +
"-not -path '*/js/generated/coverage/*' " +
"-not -path '*/.virtualenv/*' " +
"-not -path '*/virtualenvs/*' " +
"-not -path '*/.virtualenvs/*' " +
"-not -path '*/.env/*' " +
"-not -path '*/.envs/*' " +
"-not -path '*/env/*' " +
"-not -path '*/envs/*' " +
"-not -path '*/.venv/*' " +
"-not -path '*/.venvs/*' " +
"-not -path '*/venv/*' " +
"-not -path '*/venvs/*' " +
"-not -path '*/.git/*' " +
"-not -path '*/.hg/*' " +
"-not -path '*/.tox/*' " +
"-not -path '*/__pycache__/*' " +
"-not -path '*/.egg-info*' " +
"-not -path '*/$bower_components/*' " +
"-not -path '*/node_modules/*' " +
"-not -path '*/conftest_*.c.gcov'"
} else {
patterns =
'/a-d /b /s *coverage.* ' +
'/s nosetests.xml ' +
'/s jacoco*.xml ' +
'/s clover.xml ' +
'/s report.xml ' +
'/s cobertura.xml ' +
'/s luacov.report.out ' +
'/s lcov.info ' +
'/s *.lcov ' +
'/s gcov.info ' +
'/s *.gcov ' +
'/s *.lst' +
'| findstr /i /v \\.sh$ ' +
'| findstr /i /v \\.data$ ' +
'| findstr /i /v \\.py$ ' +
'| findstr /i /v \\.class$ ' +
'| findstr /i /v \\.xcconfig$ ' +
'| findstr /i /v Coverage\\.profdata$ ' +
'| findstr /i /v phpunit-code-coverage\\.xml$ ' +
'| findstr /i /v coverage\\.serialized$ ' +
'| findstr /i /v \\.pyc$ ' +
'| findstr /i /v \\.cfg$ ' +
'| findstr /i /v \\.egg$ ' +
'| findstr /i /v \\.whl$ ' +
'| findstr /i /v \\.html$ ' +
'| findstr /i /v \\.js$ ' +
'| findstr /i /v \\.cpp$ ' +
'| findstr /i /v coverage\\.jade$ ' +
'| findstr /i /v include\\.lst$ ' +
'| findstr /i /v inputFiles\\.lst$ ' +
'| findstr /i /v createdFiles\\.lst$ ' +
'| findstr /i /v coverage\\.html$ ' +
'| findstr /i /v scoverage\\.measurements\\..* ' +
'| findstr /i /v test_.*_coverage\\.txt ' +
'| findstr /i /v \\vendor\\ ' +
'| findstr /i /v \\htmlcov\\ ' +
'| findstr /i /v \\home\\cainus\\ ' +
'| findstr /i /v \\js\\generated\\coverage\\ ' +
'| findstr /i /v \\virtualenv\\ ' +
'| findstr /i /v \\virtualenvs\\ ' +
'| findstr /i /v \\\\.virtualenv\\ ' +
'| findstr /i /v \\\\.virtualenvs\\ ' +
'| findstr /i /v \\\\.env\\ ' +
'| findstr /i /v \\\\.envs\\ ' +
'| findstr /i /v \\env\\ ' +
'| findstr /i /v \\envs\\ ' +
'| findstr /i /v \\\\.venv\\ ' +
'| findstr /i /v \\\\.venvs\\ ' +
'| findstr /i /v \\venv\\ ' +
'| findstr /i /v \\venvs\\ ' +
'| findstr /i /v \\\\.git\\ ' +
'| findstr /i /v \\\\.hg\\ ' +
'| findstr /i /v \\\\.tox\\ ' +
'| findstr /i /v \\__pycache__\\ ' +
'| findstr /i /v \\\\.egg-info* ' +
'| findstr /i /v \\\\$bower_components\\ ' +
'| findstr /i /v \\node_modules\\ ' +
'| findstr /i /v \\conftest_.*\\.c\\.gcov '
}
var sendToCodecovV2 = function(
codecov_endpoint,
query,
upload_body,
on_success,
on_failure
) {
// Direct to Codecov
request(
{
uri: urlgrey(codecov_endpoint + '/upload/v2')
.query(query)
.toString(),
method: 'POST',
body: upload_body,
headers: {
'Content-Type': 'text/plain',
Accept: 'text/plain',
},
},
function(err, response) {
if (err || response.statusCode !== 200) {
console.log(' ' + (err || response.body))
return response
? on_failure(response.statusCode, response.body)
: on_failure(err.code, err.message)
} else {
console.log(' Success!')
console.log(' View report at: ' + response.body)
return on_success(response.body)
}
}
)
}
var sendToCodecovV3 = function(
codecov_endpoint,
query,
upload_body,
on_success,
on_failure
) {
// Direct to S3
request(
{
uri: urlgrey(codecov_endpoint + '/upload/v4')
.query(query)
.toString(),
method: 'POST',
body: '',
headers: {
'Content-Type': 'text/plain',
Accept: 'text/plain',
},
},
function(err, response, result) {
if (err) {
sendToCodecovV2(
codecov_endpoint,
query,
upload_body,
on_success,
on_failure
)
} else {
var codecov_report_url = result.split('\n')[0]
request(
{
uri: result.split('\n')[1],
method: 'PUT',
body: upload_body,
headers: {
'Content-Type': 'text/plain',
'x-amz-acl': 'public-read',
},
},
function(err) {
if (err) {
sendToCodecovV2(
codecov_endpoint,
query,
upload_body,
on_success,
on_failure
)
} else {
console.log(' Success!')
console.log(' View report at: ' + codecov_report_url)
on_success(codecov_report_url)
}
}
)
}
}
)
}
var upload = function(args, on_success, on_failure) {
// Build query
var codecov_endpoint =
args.options.url ||
process.env.codecov_url ||
process.env.CODECOV_URL ||
'https://codecov.io'
var query = {}
var debug = []
var yamlFile =
args.options.yml ||
process.env.codecov_yml ||
process.env.CODECOV_YML ||
'codecov.yml'
console.log(
'' +
' _____ _ \n' +
' / ____| | | \n' +
'| | ___ __| | ___ ___ _____ __ \n' +
'| | / _ \\ / _` |/ _ \\/ __/ _ \\ \\ / / \n' +
'| |___| (_) | (_| | __/ (_| (_) \\ V / \n' +
' \\_____\\___/ \\__,_|\\___|\\___\\___/ \\_/ \n' +
' ' +
version
)
if ((args.options.disable || '').split(',').indexOf('detect') === -1) {
console.log('==> Detecting CI Provider')
query = detectProvider()
} else {
debug.push('disabled detect')
}
query.yaml = [yamlFile, '.codecov.yml'].reduce(function(result, file) {
return (
result ||
(fs.existsSync(path.resolve(process.cwd(), file))
? path.resolve(process.cwd(), file)
: undefined)
)
}, undefined)
if (args.options.build) {
query.build = args.options.build
}
if (args.options.commit) {
query.commit = args.options.commit
}
if (args.options.branch) {
query.branch = args.options.branch
}
if (args.options.slug) {
query.slug = args.options.slug
}
var flags =
args.options.flags || process.env.codecov_flags || process.env.CODECOV_FLAGS
if (flags) {
query.flags = flags
}
var yamlToken
try {
var loadedYamlFile = jsYaml.safeLoad(fs.readFileSync(query.yaml, 'utf8'))
yamlToken =
loadedYamlFile && loadedYamlFile.codecov && loadedYamlFile.codecov.token
} catch (e) {
// silently fail
}
var token =
args.options.token ||
yamlToken ||
process.env.codecov_token ||
process.env.CODECOV_TOKEN
if (token) {
query.token = token
}
query.package = 'node-' + version
console.log('==> Configuration: ')
console.log(' Endpoint: ' + codecov_endpoint)
// Don't output `query` directly as it contains the upload token
console.log({
commit: query.commit,
branch: query.branch,
package: query.package,
})
var upload = ''
// Add specified env vars
var env_found = false
if (args.options.env || process.env.CODECOV_ENV || process.env.codecov_env) {
var env = (
args.options.env +
',' +
(process.env.CODECOV_ENV || '') +
',' +
(process.env.codecov_env || '')
).split(',')
for (var i = env.length - 1; i >= 0; i--) {
if (env[i]) {
upload += env[i] + '=' + (process.env[env[i]] || '').toString() + '\n'
env_found = true
}
}
if (env_found) {
upload += '<<<<<< ENV\n'
}
}
// List git files
var root = path.resolve(args.options.root || query.root || '.')
console.log('==> Building file structure')
try {
upload +=
execSync('git ls-files || hg locate', { cwd: root })
.toString()
.trim() + '\n<<<<<< network\n'
} catch (err) {
// not a git/hg dir, emulating git/hg ignore behavior
upload +=
walk
.sync({ path: root, ignoreFiles: ['.gitignore', '.hgignore'] })
.join('\n')
.trim() + '\n<<<<<< network\n'
}
// Make gcov reports
if ((args.options.disable || '').split(',').indexOf('gcov') === -1) {
try {
console.log('==> Generating gcov reports (skip via --disable=gcov)')
var gcg = args.options['gcov-glob'] || ''
if (gcg) {
if (!isWindows) {
gcg = gcg
.split(' ')
.map(function(p) {
return "-not -path '" + p + "'"
})
.join(' ')
} else {
gcg = gcg
.split(' ')
.map(function(p) {
return '^| findstr /i /v ' + p
})
.join(' ')
}
}
var gcov
if (!isWindows) {
gcov =
'find ' +
(args.options['gcov-root'] || root) +
" -type f -name '*.gcno' " +
gcg +
' -exec ' +
(args.options['gcov-exec'] || 'gcov') +
' ' +
(args.options['gcov-args'] || '') +
' {} +'
} else {
// @TODO support for root
// not straight forward due to nature of windows command dir
gcov =
'for /f "delims=" %g in (\'dir /a-d /b /s *.gcno ' +
gcg +
"') do " +
(args.options['gcov-exec'] || 'gcov') +
' ' +
(args.options['gcov-args'] || '') +
' %g'
}
debug.push(gcov)
console.log(' $ ' + gcov)
execSync(gcov)
} catch (e) {
console.log(' Failed to run gcov command.')
}
} else {
debug.push('disabled gcov')
}
// Detect .bowerrc
var bowerrc
if (!isWindows) {
bowerrc = execSync('test -f .bowerrc && cat .bowerrc || echo ""', {
cwd: root,
})
.toString()
.trim()
} else {
bowerrc = execSync('if exist .bowerrc type .bowerrc', { cwd: root })
.toString()
.trim()
}
if (bowerrc) {
bowerrc = JSON.parse(bowerrc).directory
if (bowerrc) {
if (!isWindows) {
more_patterns =
" -not -path '*/" + bowerrc.toString().replace(/\/$/, '') + "/*'"
} else {
more_patterns =
'| findstr /i /v \\' + bowerrc.toString().replace(/\/$/, '') + '\\'
}
}
}
var files = [],
file = null
if (args.options.pipe) {
// Append piped reports
upload += '# path=piped\n' + args.options.pipe.join('') + '\n<<<<<< EOF\n'
console.log('==> Reading report from stdin')
} else if (args.options.file) {
// Append manually entered reports
file = args.options.file
console.log('==> Targeting specific file')
try {
upload +=
'# path=' +
file +
'\n' +
fs.readFileSync(file, 'utf8').toString() +
'\n<<<<<< EOF\n'
console.log(' + ' + file)
files.push(file)
} catch (e) {
debug.push('failed: ' + file.split('/').pop())
console.log(' X Failed to read file at ' + file)
}
} else if ((args.options.disable || '').split(',').indexOf('search') === -1) {
console.log('==> Scanning for reports')
var _files
if (!isWindows) {
_files = execSync('find ' + root + ' ' + patterns + more_patterns)
.toString()
.trim()
.split('\n')
} else {
// @TODO support for a root directory
// It's not straightforward due to the nature of the dir command
_files = execSync('dir ' + patterns + more_patterns)
.toString()
.trim()
.split('\r\n')
}
if (_files) {
for (var i2 = _files.length - 1; i2 >= 0; i2--) {
file = _files[i2]
try {
upload +=
'# path=' +
file +
'\n' +
fs.readFileSync(file, 'utf8').toString() +
'\n<<<<<< EOF\n'
console.log(' + ' + file)
files.push(file)
} catch (e) {
debug.push('failed: ' + file.split('/').pop())
console.log(' X Failed to read file at ' + file)
}
}
}
} else {
debug.push('disabled search')
}
if (files) {
// Upload to Codecov
if (args.options.dump) {
console.log('-------- DEBUG START --------')
console.log(upload)
console.log('-------- DEBUG END --------')
} else {
console.log('==> Uploading reports')
var _upload
if ((args.options.disable || '').split(',').indexOf('s3') === -1) {
_upload = sendToCodecovV3
} else {
_upload = sendToCodecovV2
}
_upload(
codecov_endpoint,
query,
upload,
function() {
// remove files after Uploading
if (args.options.clear) {
for (var i = files.length - 1; i >= 0; i--) {
try {
fs.unlinkSync(files[i])
} catch (e) {}
}
}
if (on_success) {
on_success.apply(this, arguments)
}
},
on_failure || function() {}
)
}
}
return {
body: upload,
files: files,
query: query,
debug: debug,
url: codecov_endpoint,
}
}
module.exports = {
upload: upload,
version: version,
sendToCodecovV2: sendToCodecovV2,
sendToCodecovV3: sendToCodecovV3,
}

39
node_modules/codecov/lib/detect.js generated vendored Normal file
View File

@ -0,0 +1,39 @@
var services = {
travis: require('./services/travis'),
circle: require('./services/circle'),
cirrus: require('./services/cirrus'),
buildkite: require('./services/buildkite'),
azurePipelines: require('./services/azurePipelines'),
codeship: require('./services/codeship'),
drone: require('./services/drone'),
appveyor: require('./services/appveyor'),
wercker: require('./services/wercker'),
jenkins: require('./services/jenkins'),
semaphore: require('./services/semaphore'),
semaphore2x: require('./services/semaphore2x'),
snap: require('./services/snap'),
gitlab: require('./services/gitlab'),
heroku: require('./services/heroku'),
teamcity: require('./services/teamcity'),
codebuild: require('./services/codebuild'),
}
var detectProvider = function() {
var config
for (var name in services) {
if (services[name].detect()) {
config = services[name].configuration()
break
}
}
if (!config) {
var local = require('./services/localGit')
config = local.configuration()
if (!config) {
throw new Error('Unknown CI service provider. Unable to upload coverage.')
}
}
return config
}
module.exports = detectProvider

15
node_modules/codecov/lib/git.js generated vendored Normal file
View File

@ -0,0 +1,15 @@
var execSync = require('child_process').execSync
module.exports = {
branch: function() {
return execSync('git rev-parse --abbrev-ref HEAD || hg branch')
.toString()
.trim()
},
head: function() {
return execSync("git log -1 --pretty=%H || hg id -i --debug | tr -d '+'")
.toString()
.trim()
},
}

14
node_modules/codecov/lib/offline.js generated vendored Normal file
View File

@ -0,0 +1,14 @@
// see: http://man7.org/linux/man-pages/man2/accept.2.html#ERRORS
var offlineErrorCodes = [
'EAI_AGAIN',
'ENETDOWN',
'EPROTO',
'ENOPROTOOPT',
'EHOSTDOWN',
'ENONET',
'EHOSTUNREACH',
'EOPNOTSUPP',
'ENETUNREACH',
]
module.exports = offlineErrorCodes

23
node_modules/codecov/lib/services/appveyor.js generated vendored Normal file
View File

@ -0,0 +1,23 @@
module.exports = {
detect: function() {
return !!process.env.APPVEYOR
},
configuration: function() {
console.log(' AppVeyor CI Detected')
return {
service: 'appveyor',
commit: process.env.APPVEYOR_REPO_COMMIT,
branch: process.env.APPVEYOR_REPO_BRANCH,
pr: process.env.APPVEYOR_PULL_REQUEST_NUMBER,
job:
process.env.APPVEYOR_ACCOUNT_NAME +
'/' +
process.env.APPVEYOR_PROJECT_SLUG +
'/' +
process.env.APPVEYOR_BUILD_VERSION,
build: process.env.APPVEYOR_JOB_ID,
slug: process.env.APPVEYOR_REPO_NAME,
}
},
}

23
node_modules/codecov/lib/services/azurePipelines.js generated vendored Normal file
View File

@ -0,0 +1,23 @@
module.exports = {
detect: function() {
return !!process.env.TF_BUILD
},
configuration: function() {
console.log(' Azure Pipelines CI Detected')
return {
service: 'azure_pipelines',
commit: process.env.BUILD_SOURCEVERSION,
branch: process.env.BUILD_SOURCEBRANCH,
pr: process.env.SYSTEM_PULLREQUEST_PULLREQUESTNUMBER,
job: process.env.SYSTEM_JOBID,
build: process.env.BUILD_BUILDID,
build_url:
process.env.SYSTEM_TEAMFOUNDATIONSERVERURI +
process.env.SYSTEM_TEAMPROJECT +
'/_build/results?buildId=' +
process.env.BUILD_BUILDID,
slug: process.env.BUILD_REPOSITORY_ID,
}
},
}

18
node_modules/codecov/lib/services/buildkite.js generated vendored Normal file
View File

@ -0,0 +1,18 @@
module.exports = {
detect: function() {
return !!process.env.BUILDKITE
},
configuration: function() {
// https://buildkite.com/docs/guides/environment-variables
console.log(' Buildkite CI Detected')
return {
service: 'buildkite',
build: process.env.BUILDKITE_BUILD_NUMBER,
build_url: process.env.BUILDKITE_BUILD_URL,
commit: process.env.BUILDKITE_COMMIT,
branch: process.env.BUILDKITE_BRANCH,
slug: process.env.BUILDKITE_PROJECT_SLUG,
}
},
}

40
node_modules/codecov/lib/services/circle.js generated vendored Normal file
View File

@ -0,0 +1,40 @@
module.exports = {
detect: function() {
return !!process.env.CIRCLECI
},
configuration: function() {
console.log(' Circle CI Detected')
return {
service: 'circleci',
build: process.env.CIRCLE_BUILD_NUM + '.' + process.env.CIRCLE_NODE_INDEX,
job: process.env.CIRCLE_BUILD_NUM + '.' + process.env.CIRCLE_NODE_INDEX,
commit: process.env.CIRCLE_SHA1,
branch: process.env.CIRCLE_BRANCH,
pr: process.env.CIRCLE_PR_NUMBER,
slug: detectRepoSlug(),
}
function detectRepoSlug() {
if (process.env.CIRCLE_PROJECT_REPONAME) {
// CircleCI 1.0
// CIRCLE_PROJECT_REPONAME=codecov
// CIRCLE_PROJECT_USERNAME=codecov-node
// CIRCLE_REPOSITORY_URL=https://github.com/codecov/codecov-node (note: GitHub Web URL)
return (
process.env.CIRCLE_PROJECT_USERNAME +
'/' +
process.env.CIRCLE_PROJECT_REPONAME
)
}
if (process.env.CIRCLE_REPOSITORY_URL) {
// CircleCI 2.0
// CIRCLE_REPOSITORY_URL=git@github.com:codecov/codecov-node.git (note: Git/SSH URL)
return process.env.CIRCLE_REPOSITORY_URL.replace(/^.*:/, '').replace(
/\.git$/,
''
)
}
throw new Error('Cannot detect repository slug.')
}
},
}

17
node_modules/codecov/lib/services/cirrus.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
module.exports = {
detect: function() {
return !!process.env.CIRRUS_CI
},
configuration: function() {
console.log(' Cirrus CI Detected')
return {
service: 'cirrusci',
build: process.env.CIRRUS_BUILD_ID,
job: process.env.CIRRUS_TASK_ID,
commit: process.env.CIRRUS_CHANGE_IN_REPO,
branch: process.env.CIRRUS_BRANCH,
pr: process.env.CIRRUS_PR,
slug: process.env.CIRRUS_REPO_FULL_NAME,
}
},
}

42
node_modules/codecov/lib/services/codebuild.js generated vendored Normal file
View File

@ -0,0 +1,42 @@
module.exports = {
detect: function() {
return !!process.env.CODEBUILD_CI
},
configuration: function() {
console.log(' AWS CodeBuild Detected')
return {
service: 'codebuild',
build: process.env.CODEBUILD_BUILD_ID,
job: process.env.CODEBUILD_BUILD_ID,
commit: process.env.CODEBUILD_RESOLVED_SOURCE_VERSION,
branch: detectBranchName(),
pr: detectPRNumber(),
slug: detectRepoSlug(),
}
function detectBranchName() {
if (process.env.CODEBUILD_WEBHOOK_HEAD_REF) {
return process.env.CODEBUILD_WEBHOOK_HEAD_REF.replace(
/^refs\/heads\//,
''
)
}
throw new Error('Cannot detect branch name.')
}
function detectPRNumber() {
if (process.env.CODEBUILD_SOURCE_VERSION) {
return process.env.CODEBUILD_SOURCE_VERSION.replace(/^pr\//, '')
}
throw new Error('Cannot detect PR number.')
}
function detectRepoSlug() {
if (process.env.CODEBUILD_SOURCE_REPO_URL) {
return process.env.CODEBUILD_SOURCE_REPO_URL.replace(
/^.*github.com\//,
''
).replace(/\.git$/, '')
}
throw new Error('Cannot detect repository slug.')
}
},
}

16
node_modules/codecov/lib/services/codeship.js generated vendored Normal file
View File

@ -0,0 +1,16 @@
module.exports = {
detect: function() {
return process.env.CI_NAME && process.env.CI_NAME === 'codeship'
},
configuration: function() {
console.log(' Codeship CI Detected')
return {
service: 'codeship',
build: process.env.CI_BUILD_NUMBER,
build_url: process.env.CI_BUILD_URL,
commit: process.env.CI_COMMIT_ID,
branch: process.env.CI_BRANCH,
}
},
}

19
node_modules/codecov/lib/services/drone.js generated vendored Normal file
View File

@ -0,0 +1,19 @@
var git = require('../git')
module.exports = {
detect: function() {
return !!process.env.DRONE
},
configuration: function() {
console.log(' Drone.io CI Detected')
return {
service: 'drone.io',
build: process.env.DRONE_BUILD_NUMBER,
commit: git.head(),
build_url: process.env.DRONE_BUILD_URL,
branch: process.env.DRONE_BRANCH,
root: process.env.DRONE_BUILD_DIR,
}
},
}

25
node_modules/codecov/lib/services/gitlab.js generated vendored Normal file
View File

@ -0,0 +1,25 @@
// https://docs.gitlab.com/ce/ci/variables/README.html
module.exports = {
detect: function() {
return !!process.env.GITLAB_CI
},
configuration: function() {
console.log(' Gitlab CI Detected')
var remote =
process.env.CI_BUILD_REPO || process.env.CI_REPOSITORY_URL || ''
return {
service: 'gitlab',
build: process.env.CI_BUILD_ID,
commit: process.env.CI_BUILD_REF,
branch: process.env.CI_BUILD_REF_NAME,
root: process.env.CI_PROJECT_DIR,
slug: remote
.split('/')
.slice(3, 5)
.join('/')
.replace('.git', ''),
}
},
}

17
node_modules/codecov/lib/services/heroku.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
// https://devcenter.heroku.com/articles/heroku-ci
module.exports = {
detect: function() {
return !!process.env.HEROKU_TEST_RUN_ID
},
configuration: function() {
console.log(' heroku CI Detected')
return {
service: 'heroku',
build: process.env.HEROKU_TEST_RUN_ID,
commit: process.env.HEROKU_TEST_RUN_COMMIT_VERSION,
branch: process.env.HEROKU_TEST_RUN_BRANCH,
}
},
}

24
node_modules/codecov/lib/services/jenkins.js generated vendored Normal file
View File

@ -0,0 +1,24 @@
var git = require('../git')
module.exports = {
detect: function() {
return !!process.env.JENKINS_URL
},
configuration: function() {
console.log(' Jenkins CI Detected')
return {
service: 'jenkins',
commit:
process.env.ghprbActualCommit || process.env.GIT_COMMIT || git.head(),
branch:
process.env.ghprbSourceBranch ||
process.env.GIT_BRANCH ||
process.env.BRANCH_NAME,
build: process.env.BUILD_NUMBER,
build_url: process.env.BUILD_URL,
root: process.env.WORKSPACE,
pr: process.env.ghprbPullId || process.env.CHANGE_ID,
}
},
}

16
node_modules/codecov/lib/services/localGit.js generated vendored Normal file
View File

@ -0,0 +1,16 @@
var git = require('../git')
module.exports = {
configuration: function() {
console.log(' No CI Detected. Using git/mercurial')
var branch = git.branch()
if (branch === 'HEAD') {
branch = 'master'
}
var head = git.head()
return {
commit: head,
branch: branch,
}
},
}

19
node_modules/codecov/lib/services/semaphore.js generated vendored Normal file
View File

@ -0,0 +1,19 @@
module.exports = {
detect: function() {
return !!process.env.SEMAPHORE && !!process.env.SEMAPHORE_REPO_SLUG
},
configuration: function() {
console.log(' Semaphore 1.x CI Detected')
return {
service: 'semaphore1x',
build:
process.env.SEMAPHORE_BUILD_NUMBER +
'.' +
process.env.SEMAPHORE_CURRENT_THREAD,
commit: process.env.REVISION,
branch: process.env.BRANCH_NAME,
slug: process.env.SEMAPHORE_REPO_SLUG,
}
},
}

15
node_modules/codecov/lib/services/semaphore2x.js generated vendored Normal file
View File

@ -0,0 +1,15 @@
module.exports = {
detect: function() {
return !!process.env.SEMAPHORE && !!process.env.SEMAPHORE_WORKFLOW_ID
},
configuration: function() {
console.log(' Semaphore 2.x CI Detected')
return {
service: 'semaphore2x',
branch: process.env.SEMAPHORE_GIT_BRANCH,
build: process.env.SEMAPHORE_WORKFLOW_ID,
commit: process.env.SEMAPHORE_GIT_SHA,
}
},
}

19
node_modules/codecov/lib/services/shippable.js generated vendored Normal file
View File

@ -0,0 +1,19 @@
module.exports = {
detect: function() {
return !!process.env.SHIPPABLE
},
configuration: function() {
// http://docs.shippable.com/en/latest/config.html#common-environment-variables
console.log(' Shippable CI Detected')
return {
service: 'shippable',
build: process.env.BUILD_NUMBER,
build_url: process.env.BUILD_URL,
pr: process.env.PULL_REQUEST,
commit: process.env.COMMIT,
branch: process.env.BRANCH,
slug: process.env.REPO_NAME,
}
},
}

16
node_modules/codecov/lib/services/snap.js generated vendored Normal file
View File

@ -0,0 +1,16 @@
module.exports = {
detect: function() {
return !!process.env.SNAP_CI
},
configuration: function() {
console.log(' Snap CI Detected')
return {
service: 'snap',
build: process.env.SNAP_PIPELINE_COUNTER,
commit: process.env.SNAP_COMMIT || process.env.SNAP_UPSTREAM_COMMIT,
branch: process.env.SNAP_BRANCH || process.env.SNAP_UPSTREAM_BRANCH,
pr: process.env.SNAP_PULL_REQUEST_NUMBER,
}
},
}

17
node_modules/codecov/lib/services/teamcity.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
module.exports = {
detect: function () {
return !!process.env.TEAMCITY_VERSION;
},
configuration: function () {
console.log(' TeamCity CI Detected');
return {
service: 'teamcity',
commit: process.env.BUILD_VCS_NUMBER,
branch: process.env.BRANCH_NAME,
build: process.env.BUILD_NUMBER
};
}
};

19
node_modules/codecov/lib/services/travis.js generated vendored Normal file
View File

@ -0,0 +1,19 @@
module.exports = {
detect: function() {
return !!process.env.TRAVIS
},
configuration: function() {
console.log(' Travis CI Detected')
return {
service: 'travis',
commit: process.env.TRAVIS_COMMIT,
build: process.env.TRAVIS_JOB_NUMBER,
branch: process.env.TRAVIS_BRANCH,
job: process.env.TRAVIS_JOB_ID,
pr: process.env.TRAVIS_PULL_REQUEST,
slug: process.env.TRAVIS_REPO_SLUG,
root: process.env.TRAVIS_BUILD_DIR,
}
},
}

22
node_modules/codecov/lib/services/wercker.js generated vendored Normal file
View File

@ -0,0 +1,22 @@
// http://devcenter.wercker.com/articles/steps/variables.html
module.exports = {
detect: function() {
return !!process.env.WERCKER_MAIN_PIPELINE_STARTED
},
configuration: function() {
console.log(' Wercker CI Detected')
return {
service: 'wercker',
build: process.env.WERCKER_MAIN_PIPELINE_STARTED,
commit: process.env.WERCKER_GIT_COMMIT,
build_url: process.env.WERCKER_BUILD_URL,
branch: process.env.WERCKER_GIT_BRANCH,
slug:
process.env.WERCKER_GIT_OWNER +
'/' +
process.env.WERCKER_GIT_REPOSITORY,
}
},
}

92
node_modules/codecov/package.json generated vendored Normal file
View File

@ -0,0 +1,92 @@
{
"_args": [
[
"codecov@3.6.0",
"E:\\python\\setup-php"
]
],
"_from": "codecov@3.6.0",
"_id": "codecov@3.6.0",
"_inBundle": false,
"_integrity": "sha512-d9SEDdgEZ1PDXLY52itsk5pMmxVbqmT4+8OCzmZOHUUOxWpmnPK2Fgz35yYUipT8QqkrDRihIvIJKjRynUdk4g==",
"_location": "/codecov",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "codecov@3.6.0",
"name": "codecov",
"escapedName": "codecov",
"rawSpec": "3.6.0",
"saveSpec": null,
"fetchSpec": "3.6.0"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/codecov/-/codecov-3.6.0.tgz",
"_spec": "3.6.0",
"_where": "E:\\python\\setup-php",
"author": {
"name": "Codecov",
"email": "hello@codecov.io"
},
"bin": {
"codecov": "./bin/codecov"
},
"bugs": {
"url": "https://github.com/codecov/codecov-node/issues"
},
"dependencies": {
"argv": "^0.0.2",
"ignore-walk": "^3.0.1",
"js-yaml": "^3.13.1",
"teeny-request": "^3.11.3",
"urlgrey": "^0.4.4"
},
"description": "Uploading report to Codecov: https://codecov.io",
"devDependencies": {
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.1.0",
"husky": "^1.3.1",
"jest": "^24.8.0",
"lint-staged": "^8.1.5",
"mock-fs": "^4.8.0",
"prettier": "^1.16.4"
},
"engines": {
"node": ">=4.0"
},
"homepage": "https://github.com/codecov/codecov-node",
"husky": {
"hooks": {
"pre-commit": "npm run lint && lint-staged",
"pre-push": "npm test"
}
},
"keywords": [
"coverage",
"code-coverage",
"codecov.io",
"codecov"
],
"license": "MIT",
"lint-staged": {
"*.{ts,js,json,md}": [
"prettier --write",
"git add"
]
},
"main": "index.js",
"name": "codecov",
"repository": {
"type": "git",
"url": "git+https://github.com/codecov/codecov-node.git"
},
"scripts": {
"lint": "eslint .",
"pretest": "npm run lint",
"test": "jest --coverage"
},
"version": "3.6.0"
}

17
node_modules/codecov/test/detect.test.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
var detect = require('../lib/detect')
var git = require('../lib/git')
describe('Codecov', function() {
it('can detect existing appveyor service', function() {
process.env.TRAVIS = 'true'
expect(detect().service).toBe('travis')
process.env.TRAVIS = ''
})
it('can select local git service if no service is found', function() {
expect(detect().commit).toMatch(/^\w{40}$/)
expect(detect().commit).toBe(git.head())
})
})

1
node_modules/codecov/test/example.coverage.txt generated vendored Normal file
View File

@ -0,0 +1 @@
this file is intentionally left blank

20
node_modules/codecov/test/git.test.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
var git = require('../lib/git')
var execSync = require('child_process').execSync
describe('Git', function() {
it('can get the branch', function() {
expect(git.branch()).toEqual(
execSync('git rev-parse --abbrev-ref HEAD || hg branch')
.toString()
.trim()
)
})
it('can get the head', function() {
expect(git.head()).toEqual(
execSync("git log -1 --pretty=%H || hg id -i --debug | tr -d '+'")
.toString()
.trim()
)
})
})

279
node_modules/codecov/test/index.test.js generated vendored Normal file
View File

@ -0,0 +1,279 @@
var fs = require('fs')
var mockFs = require('mock-fs')
var codecov = require('../lib/codecov')
var isWindows =
process.platform.match(/win32/) || process.platform.match(/win64/)
var pathSeparator = !isWindows ? '/' : '\\'
describe('Codecov', function() {
beforeEach(function() {
try {
fs.unlinkSync('.bowerrc')
} catch (e) {}
})
afterAll(function() {
try {
fs.unlinkSync('.bowerrc')
} catch (e) {}
})
it('can get a token passed via env variable', function() {
jest.setTimeout(10000)
process.env.codecov_token = 'abc123'
expect(codecov.upload({ options: { dump: true } }).query.token).toBe(
'abc123'
)
delete process.env.codecov_token
process.env.CODECOV_TOKEN = 'ABC123'
expect(codecov.upload({ options: { dump: true } }).query.token).toBe(
'ABC123'
)
delete process.env.CODECOV_TOKEN
})
it('can get a token passed in cli', function() {
expect(
codecov.upload({ options: { dump: true, token: 'qwerty' } }).query.token
).toBe('qwerty')
})
it('can read a codecov.yml file', function() {
mockFs({
'codecov.yml': 'codecov:\n token: fake-token',
})
expect(codecov.upload({ options: { dump: true } }).query.token).toBe(
'fake-token'
)
mockFs.restore()
})
it('can read a .codecov.yml file', function() {
mockFs({
'.codecov.yml': 'codecov:\n token: fake-token-dotfile',
})
expect(codecov.upload({ options: { dump: true } }).query.token).toBe(
'fake-token-dotfile'
)
mockFs.restore()
})
it('should have no token if yaml file does not supplied', function() {
mockFs({
'.codecov.yml': 'codecov:\n noconfig: true',
})
expect(codecov.upload({ options: { dump: true } }).query.token).toBe(
undefined
)
mockFs.restore()
})
it('token precedence should be respected', function() {
// options.token || .codecov.yml/codecov.yml file || codecov_token || CODECOV_TOKEN
mockFs({
'.codecov.yml': 'codecov:\n token: fake-token-dotfile',
})
var upload = codecov.upload({ options: { dump: true, token: 'qwerty' } })
expect(upload.query.token).toBe('qwerty')
mockFs.restore()
process.env.codecov_token = 'abc123'
upload = codecov.upload({ options: { dump: true, token: 'qwerty2' } })
expect(upload.query.token).toBe('qwerty2')
delete process.env.codecov_token
process.env.CODECOV_TOKEN = 'ABC123'
upload = codecov.upload({ options: { dump: true, token: 'qwerty3' } })
expect(upload.query.token).toBe('qwerty3')
delete process.env.CODECOV_TOKEN
mockFs({
'.codecov.yml': 'codecov:\n token: fake-token-dotfile',
})
process.env.codecov_token = 'abc123'
upload = codecov.upload({ options: { dump: true } })
expect(upload.query.token).toBe('fake-token-dotfile')
mockFs.restore()
process.env.codecov_token = 'abc123'
process.env.CODECOV_TOKEN = 'ABC123'
upload = codecov.upload({ options: { dump: true } })
expect(upload.query.token).toBe('abc123')
delete process.env.codecov_token
delete process.env.CODECOV_TOKEN
})
it('can auto detect reports', function() {
var res = codecov.upload({ options: { dump: true } })
expect(res.files[0].split(pathSeparator).pop()).toBe('example.coverage.txt')
expect(res.body).toContain('this file is intentionally left blank')
})
it('can specify report in cli', function() {
var res = codecov.upload({
options: {
dump: true,
file: 'test' + pathSeparator + 'example.coverage.txt',
},
})
expect(res.files[0].split(pathSeparator).pop()).toBe('example.coverage.txt')
expect(res.body).toContain('this file is intentionally left blank')
})
it('can specify report in cli fail', function() {
var res = codecov.upload({ options: { dump: true, file: 'notreal.txt' } })
expect(res.debug).toContain('failed: notreal.txt')
})
// it("can detect .bowerrc with directory", function(){
// fs.writeFileSync('.bowerrc', '{"directory": "test"}');
// var res = codecov.upload({options: {dump: true}});
// expect(res.files).toBe([]);
// });
it('can detect .bowerrc without directory', function() {
fs.writeFileSync('.bowerrc', '{"key": "value"}')
var res = codecov.upload({ options: { dump: true } })
expect(res.files[0].split(pathSeparator).pop()).toBe('example.coverage.txt')
expect(res.body).toContain('this file is intentionally left blank')
})
it('can disable search', function() {
var res = codecov.upload({ options: { dump: true, disable: 'search' } })
expect(res.debug).toContain('disabled search')
expect(res.files).toEqual([])
})
it('can disable gcov', function() {
var res = codecov.upload({ options: { dump: true, disable: 'gcov' } })
console.log(res.debug)
expect(res.debug).toContain('disabled gcov')
})
it('can disable detection', function() {
var res = codecov.upload({ options: { dump: true, disable: 'detect' } })
expect(res.debug).toContain('disabled detect')
})
it('can get build from cli args', function() {
var res = codecov.upload({ options: { dump: true, build: 'value' } })
expect(res.query.build).toBe('value')
})
it('can get commit from cli args', function() {
var res = codecov.upload({ options: { dump: true, commit: 'value' } })
expect(res.query.commit).toBe('value')
})
it('can get branch from cli args', function() {
var res = codecov.upload({ options: { dump: true, branch: 'value' } })
expect(res.query.branch).toBe('value')
})
it('can get slug from cli args', function() {
var res = codecov.upload({ options: { dump: true, slug: 'value' } })
expect(res.query.slug).toBe('value')
})
it('can get flags from cli args', function() {
var res = codecov.upload({ options: { dump: true, flags: 'value' } })
expect(res.query.flags).toBe('value')
})
it('can include env in cli', function() {
process.env.HELLO = 'world'
var res = codecov.upload({ options: { dump: true, env: 'HELLO,VAR1' } })
expect(res.body).toContain('HELLO=world\n')
expect(res.body).toContain('VAR1=\n')
delete process.env.HELLO
})
it('can include env in env', function() {
process.env.HELLO = 'world'
process.env.CODECOV_ENV = 'HELLO,VAR1'
var res = codecov.upload({ options: { dump: true, env: 'VAR2' } })
expect(res.body).toContain('HELLO=world\n')
expect(res.body).toContain('VAR1=\n')
expect(res.body).toContain('VAR2=\n')
delete process.env.HELLO
delete process.env.CODECOV_ENV
})
it('can have custom args for gcov', function() {
var res = codecov.upload({
options: {
dump: true,
'gcov-root': 'folder/path',
'gcov-glob': 'ignore/this/folder',
'gcov-exec': 'llvm-gcov',
'gcov-args': '-o',
},
})
if (!isWindows) {
expect(res.debug).toContain(
"find folder/path -type f -name '*.gcno' -not -path 'ignore/this/folder' -exec llvm-gcov -o {} +"
)
} else {
expect(res.debug).toContain(
'for /f "delims=" %g in (\'dir /a-d /b /s *.gcno ^| findstr /i /v ignore/this/folder\') do llvm-gcov -o %g'
)
}
})
it('can read piped reports', function(done) {
var exec = require('child_process').exec
var childProcess = exec(
'cat test/example.coverage.txt | bin/codecov -l --dump --disable=gcov',
function(err, stdout) {
expect(stdout.toString()).toContain('path=piped')
expect(stdout.toString()).toContain(
'this file is intentionally left blank'
)
childProcess.kill()
done()
}
)
})
it('should have the correct version number', function() {
var version = require('../package.json').version
expect(codecov.version).toBe('v' + version)
})
it('Should use codecov.yml via env variable', function() {
var CWD = process.cwd()
expect(
codecov.upload({ options: { dump: true, disable: 'detect' } }).query.yaml
).toBe(CWD + '/codecov.yml')
mockFs({
'foo.yml': '',
})
process.env.codecov_yml = 'foo.yml'
expect(
codecov.upload({ options: { dump: true, disable: 'detect' } }).query.yaml
).toBe(CWD + '/foo.yml')
mockFs.restore()
delete process.env.codecov_yml
mockFs({
'FOO.yml': '',
})
process.env.CODECOV_YML = 'FOO.yml'
expect(
codecov.upload({ options: { dump: true, disable: 'detect' } }).query.yaml
).toBe(CWD + '/FOO.yml')
mockFs.restore()
delete process.env.CODECOV_YML
})
it('can get config from cli args', function() {
mockFs({
'foo.yml': '',
})
var res = codecov.upload({
options: { dump: true, yml: 'foo.yml', disable: 'detect' },
})
expect(res.query.yaml).toBe(process.cwd() + '/foo.yml')
mockFs.restore()
})
})

29
node_modules/codecov/test/services/appveyor.test.js generated vendored Normal file
View File

@ -0,0 +1,29 @@
var appveyor = require('../../lib/services/appveyor')
describe('AppVeyor CI Provider', function() {
it('can detect appveyor', function() {
process.env.APPVEYOR = 'true'
expect(appveyor.detect()).toBe(true)
})
it('can get appveyor env info', function() {
process.env.APPVEYOR_ACCOUNT_NAME = 'a'
process.env.APPVEYOR_PROJECT_SLUG = 'b'
process.env.APPVEYOR_REPO_COMMIT = '5678'
process.env.APPVEYOR_REPO_BRANCH = 'master'
process.env.APPVEYOR_PULL_REQUEST_NUMBER = '1'
process.env.APPVEYOR_BUILD_VERSION = 'job'
process.env.APPVEYOR_JOB_ID = 'build'
process.env.APPVEYOR_REPO_NAME = 'owner/repo'
expect(appveyor.configuration()).toEqual({
service: 'appveyor',
commit: '5678',
build: 'build',
job: 'a/b/job',
pr: '1',
branch: 'master',
slug: 'owner/repo',
})
})
})

View File

@ -0,0 +1,31 @@
var azurePipelines = require('../../lib/services/azurePipelines')
describe('Azure Pipelines CI Provider', function() {
it('can detect azure pipelines', function() {
process.env.TF_BUILD = '1'
expect(azurePipelines.detect()).toBe(true)
})
it('can get azure pipelines env info', function() {
process.env.BUILD_SOURCEBRANCH = 'master'
process.env.SYSTEM_JOBID = '92a2fa25-f940-5df6-a185-81eb9ae2031d'
process.env.BUILD_BUILDID = '1'
process.env.SYSTEM_TEAMFOUNDATIONSERVERURI =
'https://dev.azure.com/codecov/'
process.env.SYSTEM_TEAMPROJECT = 'repo'
process.env.BUILD_SOURCEVERSION = '743b04806ea677403aa2ff26c6bdeb85005de658'
process.env.BUILD_REPOSITORY_ID = 'owner/repo'
process.env.SYSTEM_PULLREQUEST_PULLREQUESTNUMBER = '1234'
expect(azurePipelines.configuration()).toEqual({
service: 'azure_pipelines',
build: '1',
build_url: 'https://dev.azure.com/codecov/repo/_build/results?buildId=1',
job: '92a2fa25-f940-5df6-a185-81eb9ae2031d',
commit: '743b04806ea677403aa2ff26c6bdeb85005de658',
pr: '1234',
branch: 'master',
slug: 'owner/repo',
})
})
})

25
node_modules/codecov/test/services/buildkite.test.js generated vendored Normal file
View File

@ -0,0 +1,25 @@
var buildkite = require('../../lib/services/buildkite')
describe('Buildkite CI Provider', function() {
it('can detect buildkite', function() {
process.env.BUILDKITE = 'true'
expect(buildkite.detect()).toBe(true)
})
it('can get buildkite env info', function() {
process.env.BUILDKITE_BUILD_NUMBER = '1'
process.env.BUILDKITE_BUILD_URL = 'url'
process.env.BUILDKITE_COMMIT = 'commit'
process.env.BUILDKITE_BRANCH = 'branch'
process.env.BUILDKITE_PROJECT_SLUG = 'slug'
expect(buildkite.configuration()).toEqual({
service: 'buildkite',
build: '1',
build_url: 'url',
commit: 'commit',
branch: 'branch',
slug: 'slug',
})
})
})

63
node_modules/codecov/test/services/circle.test.js generated vendored Normal file
View File

@ -0,0 +1,63 @@
var circle = require('../../lib/services/circle')
describe('Circle CI Provider', function() {
it('can detect circle', function() {
process.env.CIRCLECI = 'true'
expect(circle.detect()).toBe(true)
})
it('can get circle env info (CircleCI 1.0)', function() {
process.env.CIRCLECI = 'true'
process.env.CIRCLE_BUILD_NUM = '1234'
process.env.CIRCLE_SHA1 = '5678'
process.env.CIRCLE_BRANCH = 'master'
process.env.CIRCLE_NODE_INDEX = '1'
process.env.CIRCLE_PR_NUMBER = 'blah'
process.env.CIRCLE_PROJECT_USERNAME = 'owner'
process.env.CIRCLE_PROJECT_REPONAME = 'repo'
expect(circle.configuration()).toEqual({
service: 'circleci',
commit: '5678',
build: '1234.1',
job: '1234.1',
branch: 'master',
pr: 'blah',
slug: 'owner/repo',
})
})
it('can get circle env info (CircleCI 2.0)', function() {
process.env.CIRCLECI = 'true'
process.env.CIRCLE_BRANCH = 'master'
process.env.CIRCLE_BUILD_NUM = '1234'
process.env.CIRCLE_SHA1 = 'abcd'
process.env.CIRCLE_NODE_INDEX = '1'
process.env.CIRCLE_BUILD_URL = 'https://circleci.com/gh/owner/repo/1234'
process.env.CIRCLE_COMPARE_URL =
'https://github.com/owner/repo/2408ca9...3c36cfa'
process.env.CIRCLE_NODE_INDEX = '1'
process.env.CIRCLE_REPOSITORY_URL = 'git@github.com:owner/repo.git'
delete process.env.CIRCLE_PR_NUMBER
delete process.env.CIRCLE_PROJECT_USERNAME
delete process.env.CIRCLE_PROJECT_REPONAME
expect(circle.configuration()).toEqual({
service: 'circleci',
commit: 'abcd',
build: '1234.1',
job: '1234.1',
branch: 'master',
pr: undefined,
slug: 'owner/repo',
})
})
it('throws if repo slug cannot be detected', function() {
delete process.env.CIRCLE_PR_NUMBER
delete process.env.CIRCLE_PROJECT_USERNAME
delete process.env.CIRCLE_PROJECT_REPONAME
delete process.env.CIRCLE_REPOSITORY_URL
expect(function() {
circle.configuration()
}).toThrow()
})
})

27
node_modules/codecov/test/services/cirrus.test.js generated vendored Normal file
View File

@ -0,0 +1,27 @@
var cirrus = require('../../lib/services/cirrus')
describe('Cirrus CI Provider', function() {
it('can detect cirrus', function() {
process.env.CIRRUS_CI = 'true'
expect(cirrus.detect()).toBe(true)
})
it('can get cirrus env info', function() {
process.env.CIRRUS_CI = 'true'
process.env.CIRRUS_BUILD_ID = '1234.1'
process.env.CIRRUS_CHANGE_IN_REPO = '5678'
process.env.CIRRUS_BRANCH = 'master'
process.env.CIRRUS_TASK_ID = '1234.1'
process.env.CIRRUS_PR = 'blah'
process.env.CIRRUS_REPO_FULL_NAME = 'owner/repo'
expect(cirrus.configuration()).toEqual({
service: 'cirrusci',
commit: '5678',
build: '1234.1',
job: '1234.1',
branch: 'master',
pr: 'blah',
slug: 'owner/repo',
})
})
})

53
node_modules/codecov/test/services/codebuild.test.js generated vendored Normal file
View File

@ -0,0 +1,53 @@
var codebuild = require('../../lib/services/codebuild')
describe('AWS CodeBuild Provider', function() {
it('can detect codebuild', function() {
process.env.CODEBUILD_CI = 'true'
expect(codebuild.detect()).toBe(true)
})
it('can get codebuild env info', function() {
process.env.CODEBUILD_CI = 'true'
process.env.CODEBUILD_BUILD_ID =
'my-project:e016b9d9-f2c8-4749-8373-7ca673b6d969'
process.env.CODEBUILD_RESOLVED_SOURCE_VERSION =
'39ec2418eca4c539d765574a1c68f3bd77e8c549'
process.env.CODEBUILD_WEBHOOK_HEAD_REF = 'refs/heads/master'
process.env.CODEBUILD_SOURCE_VERSION = 'pr/1'
process.env.CODEBUILD_SOURCE_REPO_URL =
'https://github.com/my-org/my-project.git'
expect(codebuild.configuration()).toEqual({
service: 'codebuild',
build: 'my-project:e016b9d9-f2c8-4749-8373-7ca673b6d969',
job: 'my-project:e016b9d9-f2c8-4749-8373-7ca673b6d969',
commit: '39ec2418eca4c539d765574a1c68f3bd77e8c549',
branch: 'master',
pr: '1',
slug: 'my-org/my-project',
})
})
it('throws if branch name cannot be detected', function() {
delete process.env.CODEBUILD_WEBHOOK_HEAD_REF
expect(function() {
codebuild.configuration()
}).toThrow()
})
it('throws if pr number cannot be detected', function() {
process.env.CODEBUILD_WEBHOOK_HEAD_REF = 'refs/heads/master'
delete process.env.CODEBUILD_SOURCE_VERSION
expect(function() {
codebuild.configuration()
}).toThrow()
})
it('throws if slug cannot be detected', function() {
process.env.CODEBUILD_RESOLVED_SOURCE_VERSION =
'39ec2418eca4c539d765574a1c68f3bd77e8c549'
delete process.env.CODEBUILD_SOURCE_REPO_URL
expect(function() {
codebuild.configuration()
}).toThrow()
})
})

23
node_modules/codecov/test/services/codeship.test.js generated vendored Normal file
View File

@ -0,0 +1,23 @@
var codeship = require('../../lib/services/codeship')
describe('Codeship CI Provider', function() {
it('can detect codeship', function() {
process.env.CI_NAME = 'codeship'
expect(codeship.detect()).toBe(true)
})
it('can get codeship env info', function() {
process.env.CI_BUILD_NUMBER = '1234'
process.env.CI_COMMIT_ID = '5678'
process.env.CI_BRANCH = 'master'
process.env.CI_BUILD_URL = 'https://...'
expect(codeship.configuration()).toEqual({
service: 'codeship',
commit: '5678',
build: '1234',
branch: 'master',
build_url: 'https://...',
})
})
})

24
node_modules/codecov/test/services/drone.test.js generated vendored Normal file
View File

@ -0,0 +1,24 @@
var drone = require('../../lib/services/drone')
var git = require('../../lib/git')
describe('Drone.io CI Provider', function() {
it('can detect drone', function() {
process.env.DRONE = 'true'
expect(drone.detect()).toBe(true)
})
it('can get drone env info', function() {
process.env.DRONE_BUILD_NUMBER = '1234'
process.env.DRONE_BRANCH = 'master'
process.env.DRONE_BUILD_URL = 'https://...'
process.env.DRONE_BUILD_DIR = '/'
expect(drone.configuration()).toEqual({
service: 'drone.io',
commit: git.head(),
build: '1234',
root: '/',
branch: 'master',
build_url: 'https://...',
})
})
})

48
node_modules/codecov/test/services/gitlab.test.js generated vendored Normal file
View File

@ -0,0 +1,48 @@
var gitlab = require('../../lib/services/gitlab')
describe('Gitlab CI Provider', function() {
it('can detect gitlab', function() {
process.env.GITLAB_CI = 'true'
expect(gitlab.detect()).toBe(true)
})
it('cannot detect gitlab', function() {
delete process.env.GITLAB_CI
expect(gitlab.detect()).toBe(false)
})
it('can get service env info', function() {
process.env.CI_BUILD_ID = '1234'
process.env.CI_BUILD_REPO = 'https://gitlab.com/owner/repo.git'
process.env.CI_BUILD_REF = '5678'
process.env.CI_BUILD_REF_NAME = 'master'
process.env.CI_PROJECT_DIR = '/'
expect(gitlab.configuration()).toEqual({
service: 'gitlab',
build: '1234',
root: '/',
commit: '5678',
slug: 'owner/repo',
branch: 'master',
})
delete process.env.CI_BUILD_REPO
process.env.CI_REPOSITORY_URL = 'https://gitlab.com/owner/repo2.git'
expect(gitlab.configuration()).toEqual({
service: 'gitlab',
build: '1234',
root: '/',
commit: '5678',
slug: 'owner/repo2',
branch: 'master',
})
delete process.env.CI_REPOSITORY_URL
expect(gitlab.configuration()).toEqual({
service: 'gitlab',
build: '1234',
root: '/',
commit: '5678',
slug: '',
branch: 'master',
})
})
})

21
node_modules/codecov/test/services/heroku.test.js generated vendored Normal file
View File

@ -0,0 +1,21 @@
var heroku = require('../../lib/services/heroku')
describe('Heroku CI Provider', function() {
it('can detect heroku', function() {
process.env.HEROKU_TEST_RUN_ID = '454f5dc9-afa4-433f-bb28-84678a00fd98'
expect(heroku.detect()).toBe(true)
})
it('can get wercker env info', function() {
process.env.HEROKU_TEST_RUN_ID = '454f5dc9-afa4-433f-bb28-84678a00fd98'
process.env.HEROKU_TEST_RUN_COMMIT_VERSION =
'743b04806ea677403aa2ff26c6bdeb85005de658'
process.env.HEROKU_TEST_RUN_BRANCH = 'master'
expect(heroku.configuration()).toEqual({
service: 'heroku',
commit: '743b04806ea677403aa2ff26c6bdeb85005de658',
build: '454f5dc9-afa4-433f-bb28-84678a00fd98',
branch: 'master',
})
})
})

64
node_modules/codecov/test/services/jenkins.test.js generated vendored Normal file
View File

@ -0,0 +1,64 @@
var jenkins = require('../../lib/services/jenkins')
var git = require('../../lib/git')
describe('Jenkins CI Provider', function() {
it('can detect jenkins', function() {
process.env.JENKINS_URL = 'http://jenkins.jenkins.example/'
expect(jenkins.detect()).toBe(true)
})
it('can get service env info', function() {
process.env.BUILD_NUMBER = '1234'
process.env.BUILD_URL = 'http://asdf/'
process.env.GIT_COMMIT = '5678'
process.env.GIT_BRANCH = 'master'
process.env.WORKSPACE = '/'
expect(jenkins.configuration()).toEqual({
service: 'jenkins',
build_url: 'http://asdf/',
build: '1234',
root: '/',
commit: '5678',
pr: undefined,
branch: 'master',
})
})
it('can get service env info when using Blue Ocean', function() {
delete process.env.GIT_COMMIT
delete process.env.GIT_BRANCH
process.env.BUILD_NUMBER = '1234'
process.env.BUILD_URL = 'http://asdf/'
process.env.BRANCH_NAME = 'master'
process.env.WORKSPACE = '/'
expect(jenkins.configuration()).toEqual({
service: 'jenkins',
build_url: 'http://asdf/',
build: '1234',
root: '/',
commit: git.head(),
pr: undefined,
branch: 'master',
})
})
it('github pull request env variables win out over jenkins variables', function() {
process.env.BUILD_NUMBER = '1234'
process.env.BUILD_URL = 'http://asdf/'
process.env.GIT_COMMIT = '5678'
process.env.ghprbActualCommit = '8765'
process.env.GIT_BRANCH = 'master'
process.env.ghprbSourceBranch = 'retsam'
process.env.ghprbPullId = '1111'
process.env.WORKSPACE = '/'
expect(jenkins.configuration()).toEqual({
service: 'jenkins',
build_url: 'http://asdf/',
build: '1234',
root: '/',
commit: '8765',
pr: '1111',
branch: 'retsam',
})
})
})

17
node_modules/codecov/test/services/localGit.test.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
var local = require('../../lib/services/localGit')
var execSync = require('child_process').execSync
describe('Local git/mercurial CI Provider', function() {
it('can get commit', function() {
expect(local.configuration().commit).toMatch(/^\w{40}$/)
expect(local.configuration().commit).toEqual(
execSync("git rev-parse HEAD || hg id -i --debug | tr -d '+'")
.toString()
.trim()
)
})
it('can get branch', function() {
expect(local.configuration().branch).not.toEqual(null)
})
})

40
node_modules/codecov/test/services/semaphore.test.js generated vendored Normal file
View File

@ -0,0 +1,40 @@
var semaphore = require('../../lib/services/semaphore')
describe('Semaphore CI Provider', function() {
var OLD_ENV = process.env
beforeEach(function() {
process.env = Object.assign({}, OLD_ENV)
})
afterEach(function() {
process.env = Object.assign({}, OLD_ENV)
})
it('can detect semaphore', function() {
process.env.SEMAPHORE = 'true'
process.env.SEMAPHORE_REPO_SLUG = 'owner/repo'
expect(semaphore.detect()).toBe(true)
})
it('does not detect semaphore 2.x', function() {
process.env.SEMAPHORE = 'true'
process.env.SEMAPHORE_WORKFLOW_ID = '65c9bb1c-aeb6-41f0-b8d9-6fa177241cdf'
expect(semaphore.detect()).toBe(false)
})
it('can get semaphore env info', function() {
process.env.SEMAPHORE_BUILD_NUMBER = '1234'
process.env.REVISION = '5678'
process.env.SEMAPHORE_CURRENT_THREAD = '1'
process.env.BRANCH_NAME = 'master'
process.env.SEMAPHORE_REPO_SLUG = 'owner/repo'
expect(semaphore.configuration()).toEqual({
service: 'semaphore1x',
commit: '5678',
build: '1234.1',
branch: 'master',
slug: 'owner/repo',
})
})
})

37
node_modules/codecov/test/services/semaphore2x.test.js generated vendored Normal file
View File

@ -0,0 +1,37 @@
var semaphore2 = require('../../lib/services/semaphore2x')
describe('Semaphore 2.x CI Provider', function() {
var OLD_ENV = process.env
beforeEach(function() {
process.env = Object.assign({}, OLD_ENV)
})
afterEach(function() {
process.env = Object.assign({}, OLD_ENV)
})
it('can detect semaphore 2x', function() {
process.env.SEMAPHORE = 'true'
process.env.SEMAPHORE_WORKFLOW_ID = '65c9bb1c-aeb6-41f0-b8d9-6fa177241cdf'
expect(semaphore2.detect()).toBe(true)
})
it('does not detect semaphore 1.x', function() {
process.env.SEMAPHORE = 'true'
process.env.SEMAPHORE_REPO_SLUG = 'owner/repo'
expect(semaphore2.detect()).toBe(false)
})
it('can get semaphore env info', function() {
process.env.SEMAPHORE_GIT_BRANCH = 'development'
process.env.SEMAPHORE_GIT_SHA = '5c84719708b9b649b9ef3b56af214f38cee6acde'
process.env.SEMAPHORE_WORKFLOW_ID = '65c9bb1c-aeb6-41f0-b8d9-6fa177241cdf'
expect(semaphore2.configuration()).toEqual({
service: 'semaphore2x',
branch: 'development',
build: '65c9bb1c-aeb6-41f0-b8d9-6fa177241cdf',
commit: '5c84719708b9b649b9ef3b56af214f38cee6acde',
})
})
})

27
node_modules/codecov/test/services/shippable.test.js generated vendored Normal file
View File

@ -0,0 +1,27 @@
var shippable = require('../../lib/services/shippable')
describe('Shippable CI Provider', function() {
it('can detect shippable', function() {
process.env.SHIPPABLE = 'true'
expect(shippable.detect()).toBe(true)
})
it('can get shippable env info get_commit_status', function() {
process.env.SHIPPABLE = 'true'
process.env.BUILD_URL = 'http://...'
process.env.COMMIT = '5678'
process.env.BUILD_NUMBER = '91011'
process.env.BUILD_URL = 'http://...'
process.env.BRANCH = 'master'
process.env.PULL_REQUEST = '2'
process.env.REPO_NAME = 'owner/repo'
expect(shippable.configuration()).toEqual({
service: 'shippable',
commit: '5678',
build: '91011',
build_url: 'http://...',
branch: 'master',
pr: '2',
slug: 'owner/repo',
})
})
})

40
node_modules/codecov/test/services/snap.test.js generated vendored Normal file
View File

@ -0,0 +1,40 @@
var snap = require('../../lib/services/snap')
describe('Snap CI Provider', function() {
it('can detect snap', function() {
process.env.SNAP_CI = 'true'
expect(snap.detect()).toBe(true)
})
it('can get snap env info get_commit_status', function() {
process.env.SNAP_CI = 'true'
process.env.SNAP_PIPELINE_COUNTER = '1234'
process.env.SNAP_COMMIT = '5678'
process.env.SNAP_BRANCH = 'master'
process.env.SNAP_PULL_REQUEST_NUMBER = 'blah'
expect(snap.configuration()).toEqual({
service: 'snap',
commit: '5678',
build: '1234',
branch: 'master',
pr: 'blah',
})
})
it('can get snap env info get_commit_status for pull requests', function() {
process.env.SNAP_COMMIT = ''
process.env.SNAP_BRANCH = ''
process.env.SNAP_CI = 'true'
process.env.SNAP_PIPELINE_COUNTER = '1234'
process.env.SNAP_UPSTREAM_COMMIT = '5678'
process.env.SNAP_UPSTREAM_BRANCH = 'upstream-branch'
process.env.SNAP_PULL_REQUEST_NUMBER = 'blah'
expect(snap.configuration()).toEqual({
service: 'snap',
commit: '5678',
build: '1234',
branch: 'upstream-branch',
pr: 'blah',
})
})
})

22
node_modules/codecov/test/services/teamcity.test.js generated vendored Normal file
View File

@ -0,0 +1,22 @@
var teamcity = require('../../lib/services/teamcity')
describe('TeamCity CI Provider', function() {
it('can detect teamcity', function() {
process.env.TEAMCITY_VERSION = '8910'
expect(teamcity.detect()).toBe(true)
})
it('can get teamcity env info get_commit_status', function() {
process.env.TEAMCITY_VERSION = '8910'
process.env.BUILD_VCS_NUMBER = '4567'
process.env.BRANCH_NAME = 'ABranch'
process.env.BUILD_NUMBER = '1234'
expect(teamcity.configuration()).toEqual({
service: 'teamcity',
commit: '4567',
branch: 'ABranch',
build: '1234',
})
})
})

28
node_modules/codecov/test/services/travis.test.js generated vendored Normal file
View File

@ -0,0 +1,28 @@
var travis = require('../../lib/services/travis')
describe('Travis CI Provider', function() {
it('can detect travis', function() {
process.env.TRAVIS = 'true'
expect(travis.detect()).toBe(true)
})
it('can get travis env info get_commit_status', function() {
process.env.TRAVIS = 'true'
process.env.TRAVIS_JOB_ID = '1234'
process.env.TRAVIS_COMMIT = '5678'
process.env.TRAVIS_JOB_NUMBER = '91011'
process.env.TRAVIS_BRANCH = 'master'
process.env.TRAVIS_PULL_REQUEST = 'blah'
process.env.TRAVIS_BUILD_DIR = '/'
process.env.TRAVIS_REPO_SLUG = 'owner/repo'
expect(travis.configuration()).toEqual({
service: 'travis',
commit: '5678',
build: '91011',
branch: 'master',
root: '/',
job: '1234',
pr: 'blah',
slug: 'owner/repo',
})
})
})

25
node_modules/codecov/test/services/wercker.test.js generated vendored Normal file
View File

@ -0,0 +1,25 @@
var wercker = require('../../lib/services/wercker')
describe('Wercker CI Provider', function() {
it('can detect wercker', function() {
process.env.WERCKER_MAIN_PIPELINE_STARTED = '1399372237'
expect(wercker.detect()).toBe(true)
})
it('can get wercker env info', function() {
process.env.WERCKER_MAIN_PIPELINE_STARTED = '1399372237'
process.env.WERCKER_GIT_COMMIT = '5678'
process.env.WERCKER_GIT_BRANCH = 'master'
process.env.WERCKER_BUILD_URL = 'https://...'
process.env.WERCKER_GIT_OWNER = 'owner'
process.env.WERCKER_GIT_REPOSITORY = 'repo'
expect(wercker.configuration()).toEqual({
service: 'wercker',
commit: '5678',
build: '1399372237',
branch: 'master',
build_url: 'https://...',
slug: 'owner/repo',
})
})
})

97
node_modules/codecov/test/upload.test.js generated vendored Normal file
View File

@ -0,0 +1,97 @@
var fs = require('fs')
var codecov = require('../lib/codecov')
var offlineErrors = require('../lib/offline')
describe('Codecov', function() {
beforeEach(function() {
try {
fs.unlinkSync('report.tmp')
} catch (e) {}
})
afterAll(function() {
try {
fs.unlinkSync('report.tmp')
} catch (e) {}
})
it('can get upload to v2', function(done) {
var self = this
codecov.sendToCodecovV2(
'https://codecov.io',
{
token: 'f881216b-b5c0-4eb1-8f21-b51887d1d506',
commit: 'c739768fcac68144a3a6d82305b9c4106934d31a',
branch: 'master',
},
'testing node-' + codecov.version,
function(body) {
expect(body).toContain(
'https://codecov.io/github/codecov/ci-repo/commit/c739768fcac68144a3a6d82305b9c4106934d31a'
)
done()
},
function(errCode, errMsg) {
if (offlineErrors.indexOf(errCode) !== -1) {
self.skip() // offline - we can not test upload
return
}
throw new Error(errMsg)
}
)
})
it('can get upload to v3', function(done) {
var self = this
jest.setTimeout(10000) // give this test extra time to run (default is 2000ms)
codecov.sendToCodecovV3(
'https://codecov.io',
{
token: 'f881216b-b5c0-4eb1-8f21-b51887d1d506',
commit: 'c739768fcac68144a3a6d82305b9c4106934d31a',
branch: 'master',
},
'testing node-' + codecov.version,
function(body) {
expect(body).toContain(
'https://codecov.io/github/codecov/ci-repo/commit/c739768fcac68144a3a6d82305b9c4106934d31a'
)
done()
},
function(errCode, errMsg) {
if (offlineErrors.indexOf(errCode) !== -1) {
self.skip() // offline - we can not test upload
return
}
throw new Error(errMsg)
}
)
})
it("upload v2 doesn't throw runtime error", function(done) {
expect(
codecov.sendToCodecovV2.bind(
null,
'https://codecov.io',
{
token: 'f881216b-b5c0-4eb1-8f21-b51887d1d506',
commit: 'c739768fcac68144a3a6d82305b9c4106934d31a',
branch: 'master',
},
'testing node-' + codecov.version,
function(body) {
expect(body).toContain(
'https://codecov.io/github/codecov/ci-repo/commit/c739768fcac68144a3a6d82305b9c4106934d31a'
)
done()
},
function(errCode, errMsg) {
if (offlineErrors.indexOf(errCode) !== -1) {
done()
}
throw new Error(errMsg)
}
)
).not.toThrow()
})
})