diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-04-03 15:43:32 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-04-03 15:45:57 +0200 |
commit | 71e285b94c7edaa43aa8115965cf5a36b8e0f80a (patch) | |
tree | 7d4aa9d0d5aff686b106cd5da72ba77960c4af43 /deps/node/deps/npm/scripts/maketest | |
parent | 7dadf9356b4f3f4137ce982ea5bb960283116e9a (diff) | |
download | akono-71e285b94c7edaa43aa8115965cf5a36b8e0f80a.tar.gz akono-71e285b94c7edaa43aa8115965cf5a36b8e0f80a.tar.bz2 akono-71e285b94c7edaa43aa8115965cf5a36b8e0f80a.zip |
Node.js v11.13.0
Diffstat (limited to 'deps/node/deps/npm/scripts/maketest')
-rwxr-xr-x | deps/node/deps/npm/scripts/maketest | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/deps/node/deps/npm/scripts/maketest b/deps/node/deps/npm/scripts/maketest new file mode 100755 index 00000000..bf0c2c5f --- /dev/null +++ b/deps/node/deps/npm/scripts/maketest @@ -0,0 +1,85 @@ +#!/usr/bin/env node +'use strict' +const loadFromDir = require('tacks/load-from-dir.js') + +process.exit(main(process.argv.slice(2))) + +function main (argv) { + if (argv.length !== 1) { + console.error('Usage: maketest <fixturedir>') + return 1 + } + const fixturedir = process.argv[2] + + console.log(generateFromDir(fixturedir)) + return 0 +} + +function indent (ind, str) { + return str.replace(/\n/g, '\n' + ind) +} + +function generateFromDir (dir) { + const tacks = loadFromDir(dir) + return `'use strict' +const path = require('path') +const test = require('tap').test +const Tacks = require('tacks') +const File = Tacks.File +const Symlink = Tacks.Symlink +const Dir = Tacks.Dir +const common = require('../common-tap.js') + +const basedir = path.join(__dirname, path.basename(__filename, '.js')) +const testdir = path.join(basedir, 'testdir') +const cachedir = path.join(basedir, 'cache') +const globaldir = path.join(basedir, 'global') +const tmpdir = path.join(basedir, 'tmp') + +const conf = { + cwd: testdir, + env: common.newEnv().extend({ + npm_config_cache: cachedir, + npm_config_tmp: tmpdir, + npm_config_prefix: globaldir, + npm_config_registry: common.registry, + npm_config_loglevel: 'warn' + }) +} + +const fixture = new Tacks(Dir({ + cache: Dir(), + global: Dir(), + tmp: Dir(), + testdir: ${indent(' ', tacks.fixture.toSource())} +})) + +function setup () { + cleanup() + fixture.create(basedir) +} + +function cleanup () { + fixture.remove(basedir) +} + +test('setup', t => { + setup() + return common.fakeRegistry.listen() +}) + +test('example', t => { + return common.npm(['install'], conf).then((code, stdout, stderr) => { + t.is(code, 0, 'command ran ok') + t.comment(stdout.trim()) + t.comment(stderr.trim()) + // your assertions here + }) +}) + +test('cleanup', t => { + common.fakeRegistry.close() + cleanup() + t.done() +})\n` +} |