Repository: GoogleChrome/lighthouse
Pull request #12415 (2021-04-27 23:16:22)

misc: do not publish lighthouse-cli/test except smokehouse
ref #8084

![image](https://user-images.githubusercontent.com/4071474/116323881-2e546c00-a77c-11eb-8618-0b787b5e1611.png)

afterthought ... would this break something in publisher-ads? maybe we should keep the smokerunner files but get rid of the fixtures n stuff?


brendankenny: > afterthought ... would this break something in publisher-ads?

yes: https://github.com/googleads/publisher-ads-lighthouse-plugin/blob/master/lighthouse-plugin-publisher-ads/test/smoke/run-smoke.js#L50
brendankenny: (they use all their own tests, though)
connorjclark: keeping just the code is an extra ~50KB ✅ 
![image](https://user-images.githubusercontent.com/4071474/116329853-73cb6600-a789-11eb-9ad2-92b160820a8f.png)

brendankenny: @connorjclark any chance you could land this?

Looking at the publisher-ads use of smokehouse in https://github.com/GoogleChrome/lighthouse/pull/12415#issuecomment-828016795 I had an idea to make it less ugly, but it would bump into this PR. Plus it's always a good time to trim our install size :)

Patch:
diff --git a/.npmignore b/.npmignore
index 8ce1a4dbb..b7e1728c5 100644
--- a/.npmignore
+++ b/.npmignore
@@ -22,8 +22,11 @@ lighthouse-logger/
 !lighthouse-core/scripts/manual-chrome-launcher.js
 !lighthouse-core/scripts/download-chrome.sh
 
-# keep smokehouse tests, etc
-!lighthouse-cli/test
+# Exclude the CLI smoketests but keep the smoketest runner that is used
+# by downstream projects (e.g. publisher ads).
+lighthouse-cli/test/cli
+lighthouse-cli/test/fixtures
+lighthouse-cli/test/smokehouse/test-definitions
 
 results/
 lantern-data/


Test patch:
diff --git a/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js b/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js
index b19357d29..64ff9c726 100644
--- a/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js
+++ b/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js
@@ -19,7 +19,7 @@ const log = require('lighthouse-logger');
 const {runSmokehouse} = require('../smokehouse.js');
 const {server, serverForOffline} = require('../../fixtures/static-server.js');
 
-const coreTestDefnsPath = require.resolve('../test-definitions/core-tests.js');
+const coreTestDefnsPath = `${__dirname}/../test-definitions/core-tests.js`;
 
 /**
  * Possible Lighthouse runners. Loaded dynamically so e.g. a CLI run isn't
diff --git a/lighthouse-core/scripts/release/test.sh b/lighthouse-core/scripts/release/test.sh
index 2026e643a..8ae8b24ba 100755
--- a/lighthouse-core/scripts/release/test.sh
+++ b/lighthouse-core/scripts/release/test.sh
@@ -36,8 +36,10 @@ cd /tmp/lighthouse-local-test
 
 npm init -y
 npm install "$LH_PRISTINE_ROOT/lighthouse-$VERSION.tgz"
-cd node_modules/lighthouse/lighthouse-cli/test/ && npm install lodash.clonedeep && cd ../../../../
-npm explore lighthouse -- npm run smoke -- --retries=3
+npx add-dependencies package.json mime-types lodash.clonedeep
+npm install --only=prod
+cp -r "$LH_PRISTINE_ROOT/lighthouse-cli/test/fixtures" node_modules/lighthouse/lighthouse-cli/test
+npm explore lighthouse -- npm run smoke -- --tests-path "$LH_PRISTINE_ROOT/lighthouse-cli/test/smokehouse/test-definitions/core-tests.js" --retries=3
 npm explore lighthouse -- npm run fast -- http://example.com
 
 cd "$LH_PRISTINE_ROOT"