From deffadca09fc4003aaa81553cea660868d427e0b Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Sun, 4 Nov 2018 21:36:22 +0100 Subject: [PATCH] Removes special handling of `npm test` PR-URL: https://github.com/npm/cli/pull/91 Credit: @deiga Close: #91 Reviewed-by: @isaacs NOTE: The functional part of this was actually done in ac255616d, with the refactoring of lib/run-script.js, but this PR also adds the updates to the tests that go along with that change. --- AUTHORS | 1 + test/need-npm5-update/rm-linked.js | 9 --------- test/tap/install-test-cli-without-package-lock.js | 2 +- test/tap/legacy-test-package.js | 2 +- test/tap/link.js | 12 ------------ test/tap/no-global-warns.js | 3 --- test/tap/run-script.js | 3 ++- test/tap/sorted-package-json.js | 3 --- test/tap/symlink-cycle.js | 3 --- 9 files changed, 5 insertions(+), 33 deletions(-) diff --git a/AUTHORS b/AUTHORS index 08cade33b6ff1..5658ac7fd4cf3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -695,3 +695,4 @@ Jarda Snajdr Naix Geng <1308363651@qq.com> Dylan Treisman mum-never-proud +Timo Sand diff --git a/test/need-npm5-update/rm-linked.js b/test/need-npm5-update/rm-linked.js index 9123b8760ecb4..f80421b9892cd 100644 --- a/test/need-npm5-update/rm-linked.js +++ b/test/need-npm5-update/rm-linked.js @@ -26,9 +26,6 @@ var linkedJSON = { version: '1.0.0', description: '', main: 'index.js', - scripts: { - test: 'echo "Error: no test specified" && exit 1' - }, dependencies: { 'baz': '1.0.0' }, @@ -41,9 +38,6 @@ var linkedDepJSON = { version: '1.0.0', description: '', main: 'index.js', - scripts: { - test: 'echo "Error: no test specified" && exit 1' - }, author: '', license: 'ISC' } @@ -53,9 +47,6 @@ var installJSON = { version: '1.0.0', description: '', main: 'index.js', - scripts: { - test: 'echo "Error: no test specified" && exit 1' - }, dependencies: { 'foo': '1.0.0' }, diff --git a/test/tap/install-test-cli-without-package-lock.js b/test/tap/install-test-cli-without-package-lock.js index 603043af8fd38..5cfc86f94c6e8 100644 --- a/test/tap/install-test-cli-without-package-lock.js +++ b/test/tap/install-test-cli-without-package-lock.js @@ -51,7 +51,7 @@ test('\'npm install-test\' should not generate package-lock.json.*', function (t if (err) throw err t.comment(stdout.trim()) t.comment(stderr.trim()) - t.is(code, 0, 'npm install did not raise error code') + t.is(code, 1, 'npm install-test w/o test defined should return error') var files = fs.readdirSync(pkg).filter(function (f) { return f.indexOf('package-lock.json.') === 0 }) diff --git a/test/tap/legacy-test-package.js b/test/tap/legacy-test-package.js index 3c807e50491c7..5fd591b098728 100644 --- a/test/tap/legacy-test-package.js +++ b/test/tap/legacy-test-package.js @@ -42,7 +42,7 @@ test('test-package', function (t) { function testCheckAndRemove (err, code, stdout, stderr) { if (err) throw err - t.is(code, 0, 'npm test w/o test is ok') + t.is(code, 1, 'npm test w/o test should return error') common.npm(['rm', fixturepath], {cwd: basepath}, removeCheckAndDone) } diff --git a/test/tap/link.js b/test/tap/link.js index 2d2d63de21415..adb24b44f3d72 100644 --- a/test/tap/link.js +++ b/test/tap/link.js @@ -26,9 +26,6 @@ var readJSON = { version: '1.0.0', description: '', main: 'index.js', - scripts: { - test: 'echo "Error: no test specified" && exit 1' - }, author: '', license: 'ISC' } @@ -38,9 +35,6 @@ var readScopedJSON = { version: '1.0.0', description: '', main: 'index.js', - scripts: { - test: 'echo "Error: no test specified" && exit 1' - }, author: '', license: 'ISC' } @@ -50,9 +44,6 @@ var installJSON = { version: '1.0.0', description: '', main: 'index.js', - scripts: { - test: 'echo "Error: no test specified" && exit 1' - }, author: '', license: 'ISC' } @@ -62,9 +53,6 @@ var insideInstallJSON = { version: '1.0.0', description: '', main: 'index.js', - scripts: { - test: 'echo "Error: no test specified" && exit 1' - }, author: '', license: 'ISC' } diff --git a/test/tap/no-global-warns.js b/test/tap/no-global-warns.js index 1c39fd79549c0..27963ea50f95e 100644 --- a/test/tap/no-global-warns.js +++ b/test/tap/no-global-warns.js @@ -28,9 +28,6 @@ var installJSON = { version: '1.0.0', description: '', main: 'index.js', - scripts: { - test: 'echo "Error: no test specified" && exit 1' - }, author: '', license: 'ISC' } diff --git a/test/tap/run-script.js b/test/tap/run-script.js index 75b714002e2c8..52798c03a3d81 100644 --- a/test/tap/run-script.js +++ b/test/tap/run-script.js @@ -166,8 +166,9 @@ test('npm run-script explicitly call pre script with arg', function (t) { test('npm run-script test', function (t) { common.npm(['run-script', 'test'], opts, function (er, code, stdout, stderr) { + t.match(stderr, /npm ERR! missing script: test/) t.ifError(er, 'npm run-script test ran without issue') - t.notOk(stderr, 'should not generate errors') + t.ok(stderr, 'should generate errors') t.end() }) }) diff --git a/test/tap/sorted-package-json.js b/test/tap/sorted-package-json.js index f802bfd9e5605..dd62247d9709a 100644 --- a/test/tap/sorted-package-json.js +++ b/test/tap/sorted-package-json.js @@ -13,9 +13,6 @@ fs.writeFileSync(packageJson, JSON.stringify({ 'version': '0.0.0', 'description': '', 'main': 'index.js', - 'scripts': { - 'test': 'echo \'Error: no test specified\' && exit 1' - }, 'author': 'Rocko Artischocko', 'license': 'ISC', 'dependencies': { diff --git a/test/tap/symlink-cycle.js b/test/tap/symlink-cycle.js index ea0c0f5359443..de2c8247cd123 100644 --- a/test/tap/symlink-cycle.js +++ b/test/tap/symlink-cycle.js @@ -14,9 +14,6 @@ var cycleJSON = { version: '1.0.0', description: '', main: 'index.js', - scripts: { - test: 'echo "Error: no test specified" && exit 1' - }, dependencies: { 'cycle': '*' },