-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: measure codecov, add missing tests
- Loading branch information
1 parent
d7ed8c7
commit f249493
Showing
8 changed files
with
171 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/node_modules/ | ||
package-lock.json | ||
yarn.lock | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2022 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import chalk from 'chalk' | ||
|
||
export {strict as assert} from 'assert' | ||
|
||
let всегоТестов = 0 | ||
|
||
export function test(name) { | ||
let фильтр = process.argv[3] || '.' | ||
if (RegExp(фильтр).test(name)) { | ||
console.log('\n' + chalk.bgGreenBright.black(` ${name} `)) | ||
всегоТестов++ | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
export const testcount = () => всегоТестов |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 2022 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import {assert, test, testcount} from './test-utils.mjs' | ||
import chalk from 'chalk' | ||
|
||
if (test('supports `-v` flag / prints version')) { | ||
let v = (await $`node zx.mjs -v`).toString().trim() | ||
assert.equal(v, require('../package.json').version) | ||
} | ||
|
||
if (test('prints help')) { | ||
let help | ||
try { | ||
await $`node zx.mjs` | ||
} catch (err) { | ||
help = err.toString().trim() | ||
} | ||
assert(help.includes('print current zx version')) | ||
} | ||
|
||
if (test('supports `--experimental` flag')) { | ||
await $`echo 'echo("test")' | node zx.mjs --experimental` | ||
} | ||
|
||
if (test('supports `--quiet` flag / Quiet mode is working')) { | ||
let p = await $`node zx.mjs --quiet docs/markdown.md` | ||
assert(!p.stdout.includes('whoami')) | ||
} | ||
|
||
if (test('Eval script from https ref')) { | ||
let p = $`node zx.mjs https://medv.io/example-script.mjs` // Need another script | ||
setTimeout(() => p.kill(), 500) | ||
} | ||
|
||
if (test('Scripts with no extension')) { | ||
await $`node zx.mjs test/fixtures/no-extension` | ||
assert.match((await fs.readFile('test/fixtures/no-extension.mjs')).toString(), /Test file to verify no-extension didn't overwrite similarly name .mjs file./) | ||
} | ||
|
||
if (test('The require() is working from stdin')) { | ||
await $`node zx.mjs <<< 'require("./package.json").name'` | ||
} | ||
|
||
if (test('Markdown scripts are working')) { | ||
await $`node zx.mjs docs/markdown.md` | ||
} | ||
|
||
console.log('\n' + | ||
chalk.black.bgYellowBright(` zx version is ${require('../package.json').version} `) + '\n' + | ||
chalk.greenBright(` 🍺 ${testcount()} tests passed `) | ||
) |