polendina 3.3.1 → 3.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/dependabot.yml +1 -130
- package/.github/workflows/test-and-release.yml +1 -3
- package/AGENTS.md +400 -0
- package/CHANGELOG.md +16 -0
- package/CLAUDE.md +1 -0
- package/lib/webpack.config.js +5 -2
- package/package.json +3 -4
- package/polendina.js +7 -3
- package/test/common.js +27 -10
- package/test/consumer/package.json +11 -0
- package/test/fixtures/bare-async/package.json +1 -14
- package/test/fixtures/bare-async-esm/package.json +2 -15
- package/test/fixtures/bare-async-failure/package.json +1 -14
- package/test/fixtures/bare-async-failure-esm/package.json +2 -15
- package/test/fixtures/bare-sync/package.json +1 -14
- package/test/fixtures/bare-sync-esm/package.json +2 -15
- package/test/fixtures/bare-sync-failure/package.json +1 -14
- package/test/fixtures/bare-sync-failure-esm/package.json +2 -15
- package/test/fixtures/mocha/package.json +1 -15
- package/test/fixtures/mocha-esm/package.json +2 -16
- package/test/fixtures/mocha-failure/package.json +1 -15
- package/test/fixtures/mocha-failure-esm/package.json +2 -16
- package/test/fixtures/tape/package.json +1 -14
- package/test/fixtures/tape-esm/package.json +2 -15
- package/test/fixtures/tape-failure/package.json +1 -14
- package/test/fixtures/tape-failure-esm/package.json +2 -15
- package/test/fixtures/webpack-merge/package.json +1 -14
- package/test/setup.js +96 -0
- package/test/test-bare-async.js +10 -14
- package/test/test-bare-sync.js +10 -14
- package/test/test-mocha.js +23 -23
- package/test/test-packed-install.js +47 -0
- package/test/test-polendina-node.js +9 -19
- package/test/test-tape.js +10 -14
- package/test/test-webpack-merge.js +3 -7
package/test/common.js
CHANGED
|
@@ -1,19 +1,37 @@
|
|
|
1
1
|
import path from 'path'
|
|
2
2
|
import assert from 'assert'
|
|
3
3
|
import { execFile } from 'child_process'
|
|
4
|
-
import { fileURLToPath } from 'url'
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
// consumers installed by setup.js, one per runner, named by its variants table
|
|
6
|
+
export function consumers () {
|
|
7
|
+
return JSON.parse(process.env.POLENDINA_CONSUMERS)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function consumer (name) {
|
|
11
|
+
const dir = consumers()[name]
|
|
12
|
+
if (!dir) {
|
|
13
|
+
throw new Error(`no consumer named ${name}`)
|
|
14
|
+
}
|
|
15
|
+
return dir
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// runs the installed polendina CLI from inside a copied fixture directory;
|
|
19
|
+
// resolved at call time because consumers exist only once setup.js has run
|
|
20
|
+
export async function runCli (consumerName, fixture, args = []) {
|
|
21
|
+
const dir = consumer(consumerName)
|
|
22
|
+
const cli = path.join(dir, 'node_modules/polendina/polendina-cli.js')
|
|
23
|
+
return runCommand(cli, ['test*.js', 'test/test*.js', '--cleanup', ...args], path.join(dir, 'fixtures', fixture))
|
|
24
|
+
}
|
|
8
25
|
|
|
9
|
-
export async function
|
|
10
|
-
|
|
26
|
+
export async function runNodeCli (consumerName, fixture, mode) {
|
|
27
|
+
const dir = consumer(consumerName)
|
|
28
|
+
const cli = path.join(dir, 'node_modules/polendina/polendina-node-cli.js')
|
|
29
|
+
return runCommand(cli, [mode, 'test*.js'], path.join(dir, 'fixtures', fixture))
|
|
11
30
|
}
|
|
12
31
|
|
|
13
|
-
export async function runCommand (
|
|
32
|
+
export async function runCommand (script, args, cwd) {
|
|
14
33
|
return new Promise((resolve, reject) => {
|
|
15
|
-
|
|
16
|
-
execFile(process.execPath, args, { cwd }, (err, stdout, stderr) => {
|
|
34
|
+
execFile(process.execPath, [script, ...args], { cwd }, (err, stdout, stderr) => {
|
|
17
35
|
const code = err ? err.code : 0
|
|
18
36
|
if (!code) {
|
|
19
37
|
try {
|
|
@@ -22,8 +40,7 @@ export async function runCommand (command, cwd) {
|
|
|
22
40
|
return reject(e)
|
|
23
41
|
}
|
|
24
42
|
}
|
|
25
|
-
|
|
26
|
-
resolve(out)
|
|
43
|
+
resolve({ stdout: stdout.toString(), stderr: stderr.toString(), code })
|
|
27
44
|
})
|
|
28
45
|
})
|
|
29
46
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "polendina-test-consumer",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Version ranges for the test frameworks that test/setup.js installs, one runner per temporary consumer, alongside a packed polendina",
|
|
6
|
+
"devDependencies": {
|
|
7
|
+
"chai": "^6.0.1",
|
|
8
|
+
"mocha": "^12.0.2",
|
|
9
|
+
"tape": "^5.6.3"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-bare-async",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "node test-1.js && node test-2.js"
|
|
8
|
-
},
|
|
9
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
13
|
-
},
|
|
14
|
-
"license": "Apache-2.0",
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"chai": "^6.0.1"
|
|
17
|
-
}
|
|
4
|
+
"private": true
|
|
18
5
|
}
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-bare-async",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"type": "module",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "node test-1.js && node test-2.js"
|
|
9
|
-
},
|
|
10
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
14
|
-
},
|
|
15
|
-
"license": "Apache-2.0",
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"chai": "^6.0.1"
|
|
18
|
-
}
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module"
|
|
19
6
|
}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-bare-async-failure",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "node test-1.js && node test-2.js"
|
|
8
|
-
},
|
|
9
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
13
|
-
},
|
|
14
|
-
"license": "Apache-2.0",
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"chai": "^6.0.1"
|
|
17
|
-
}
|
|
4
|
+
"private": true
|
|
18
5
|
}
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-bare-async-failure",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"type": "module",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "node test-1.js && node test-2.js"
|
|
9
|
-
},
|
|
10
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
14
|
-
},
|
|
15
|
-
"license": "Apache-2.0",
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"chai": "^6.0.1"
|
|
18
|
-
}
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module"
|
|
19
6
|
}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-bare-sync",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "node test-1.js && node test-2.js"
|
|
8
|
-
},
|
|
9
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
13
|
-
},
|
|
14
|
-
"license": "Apache-2.0",
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"chai": "^6.0.1"
|
|
17
|
-
}
|
|
4
|
+
"private": true
|
|
18
5
|
}
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-bare-sync",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"type": "module",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "node test-1.js && node test-2.js"
|
|
9
|
-
},
|
|
10
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
14
|
-
},
|
|
15
|
-
"license": "Apache-2.0",
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"chai": "^6.0.1"
|
|
18
|
-
}
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module"
|
|
19
6
|
}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-bare-sync-failure",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "node test-1.js && node test-2.js"
|
|
8
|
-
},
|
|
9
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
13
|
-
},
|
|
14
|
-
"license": "Apache-2.0",
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"chai": "^6.0.1"
|
|
17
|
-
}
|
|
4
|
+
"private": true
|
|
18
5
|
}
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-bare-sync-failure",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"type": "module",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "node test-1.js && node test-2.js"
|
|
9
|
-
},
|
|
10
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
14
|
-
},
|
|
15
|
-
"license": "Apache-2.0",
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"chai": "^6.0.1"
|
|
18
|
-
}
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module"
|
|
19
6
|
}
|
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-mocha",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "mocha test-*.js"
|
|
8
|
-
},
|
|
9
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
10
|
-
"license": "Apache-2.0",
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
14
|
-
},
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"chai": "^6.0.1",
|
|
17
|
-
"mocha": "^12.0.2"
|
|
18
|
-
}
|
|
4
|
+
"private": true
|
|
19
5
|
}
|
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-mocha",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"type": "module",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "mocha test-*.js"
|
|
9
|
-
},
|
|
10
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
11
|
-
"license": "Apache-2.0",
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
15
|
-
},
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"chai": "^6.0.1",
|
|
18
|
-
"mocha": "^12.0.2"
|
|
19
|
-
}
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module"
|
|
20
6
|
}
|
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-mocha-failure",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "mocha test-*.js"
|
|
8
|
-
},
|
|
9
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
10
|
-
"license": "Apache-2.0",
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
14
|
-
},
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"chai": "^6.0.1",
|
|
17
|
-
"mocha": "^12.0.2"
|
|
18
|
-
}
|
|
4
|
+
"private": true
|
|
19
5
|
}
|
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-mocha-failure",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"type": "module",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "mocha test-*.js"
|
|
9
|
-
},
|
|
10
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
11
|
-
"license": "Apache-2.0",
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
15
|
-
},
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"chai": "^6.0.1",
|
|
18
|
-
"mocha": "^12.0.2"
|
|
19
|
-
}
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module"
|
|
20
6
|
}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-tape",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "tape test.js"
|
|
8
|
-
},
|
|
9
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
10
|
-
"license": "Apache-2.0",
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
14
|
-
},
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"tape": "^5.6.3"
|
|
17
|
-
}
|
|
4
|
+
"private": true
|
|
18
5
|
}
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-tape",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"type": "module",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "tape test.js"
|
|
9
|
-
},
|
|
10
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
11
|
-
"license": "Apache-2.0",
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
15
|
-
},
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"tape": "^5.6.3"
|
|
18
|
-
}
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module"
|
|
19
6
|
}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-tape-failure",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "tape test.js"
|
|
8
|
-
},
|
|
9
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
10
|
-
"license": "Apache-2.0",
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
14
|
-
},
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"tape": "^5.6.3"
|
|
17
|
-
}
|
|
4
|
+
"private": true
|
|
18
5
|
}
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-tape-failure",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"type": "module",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "tape test.js"
|
|
9
|
-
},
|
|
10
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
11
|
-
"license": "Apache-2.0",
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
15
|
-
},
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"tape": "^5.6.3"
|
|
18
|
-
}
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module"
|
|
19
6
|
}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-webpack-merge",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "node test.js"
|
|
8
|
-
},
|
|
9
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
13
|
-
},
|
|
14
|
-
"license": "Apache-2.0",
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"chai": "^6.0.1"
|
|
17
|
-
}
|
|
4
|
+
"private": true
|
|
18
5
|
}
|
package/test/setup.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// Mocha global fixtures. Packs polendina and installs it into temporary
|
|
2
|
+
// consumer directories outside the repository, one per test runner, each with
|
|
3
|
+
// only the frameworks that runner's fixtures import at the versions in
|
|
4
|
+
// test/consumer/package.json, then copies test/fixtures in. npm hoists polendina's dependencies into each consumer's node_modules,
|
|
5
|
+
// the layout a real install has and one the fixtures cannot produce from
|
|
6
|
+
// inside this tree. Keeping the runners apart means no runner's dependency
|
|
7
|
+
// tree can shadow or nest another's.
|
|
8
|
+
//
|
|
9
|
+
// Tests find the consumers through POLENDINA_CONSUMERS, a JSON object of
|
|
10
|
+
// name to directory. Set POLENDINA_KEEP_CONSUMERS to leave them behind.
|
|
11
|
+
|
|
12
|
+
import fs from 'fs'
|
|
13
|
+
import os from 'os'
|
|
14
|
+
import path from 'path'
|
|
15
|
+
import { exec } from 'child_process'
|
|
16
|
+
import { fileURLToPath } from 'url'
|
|
17
|
+
|
|
18
|
+
const __dirname = fileURLToPath(path.dirname(import.meta.url))
|
|
19
|
+
const root = path.join(__dirname, '..')
|
|
20
|
+
const puppeteerVersion = JSON.parse(fs.readFileSync(path.join(root, 'node_modules/puppeteer/package.json'))).version
|
|
21
|
+
const template = JSON.parse(fs.readFileSync(path.join(__dirname, 'consumer/package.json'))).devDependencies
|
|
22
|
+
|
|
23
|
+
// consumer name to the packages it installs alongside polendina; a bare name
|
|
24
|
+
// takes its version range from test/consumer/package.json, name@range pins one
|
|
25
|
+
const variants = {
|
|
26
|
+
mocha: ['mocha', 'chai'],
|
|
27
|
+
mocha11: ['mocha@11', 'chai'],
|
|
28
|
+
tape: ['tape'],
|
|
29
|
+
bare: ['chai']
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const consumers = {}
|
|
33
|
+
|
|
34
|
+
function dependency (pkg) {
|
|
35
|
+
const at = pkg.indexOf('@', 1)
|
|
36
|
+
if (at > 0) {
|
|
37
|
+
return [pkg.slice(0, at), pkg.slice(at + 1)]
|
|
38
|
+
}
|
|
39
|
+
if (!template[pkg]) {
|
|
40
|
+
throw new Error(`${pkg} is not in test/consumer/package.json`)
|
|
41
|
+
}
|
|
42
|
+
return [pkg, template[pkg]]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function sh (command, cwd) {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
const env = { ...process.env, PUPPETEER_SKIP_DOWNLOAD: '1' }
|
|
48
|
+
exec(command, { cwd, env }, (err, stdout, stderr) => {
|
|
49
|
+
if (err) {
|
|
50
|
+
return reject(new Error(`${command}\n${stderr}`))
|
|
51
|
+
}
|
|
52
|
+
resolve(stdout.toString())
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function installConsumer (name, tarball, packages) {
|
|
58
|
+
const dir = await fs.promises.mkdtemp(path.join(os.tmpdir(), `polendina-consumer-${name}-`))
|
|
59
|
+
const pkg = {
|
|
60
|
+
name: `polendina-consumer-${name}`,
|
|
61
|
+
private: true,
|
|
62
|
+
devDependencies: {
|
|
63
|
+
polendina: `file:${tarball}`,
|
|
64
|
+
puppeteer: puppeteerVersion,
|
|
65
|
+
...Object.fromEntries(packages.map(dependency))
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
await fs.promises.writeFile(path.join(dir, 'package.json'), JSON.stringify(pkg, null, 2))
|
|
69
|
+
await fs.promises.cp(path.join(__dirname, 'fixtures'), path.join(dir, 'fixtures'), {
|
|
70
|
+
recursive: true,
|
|
71
|
+
filter: (src) => path.basename(src) !== 'node_modules'
|
|
72
|
+
})
|
|
73
|
+
await sh('npm install --no-audit --no-fund --no-package-lock --prefer-offline', dir)
|
|
74
|
+
return dir
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export async function mochaGlobalSetup () {
|
|
78
|
+
const packDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'polendina-pack-'))
|
|
79
|
+
const [{ filename }] = JSON.parse(await sh(`npm pack --json --pack-destination "${packDir}"`, root))
|
|
80
|
+
const tarball = path.join(packDir, filename)
|
|
81
|
+
await Promise.all(Object.entries(variants).map(async ([name, packages]) => {
|
|
82
|
+
consumers[name] = await installConsumer(name, tarball, packages)
|
|
83
|
+
}))
|
|
84
|
+
await fs.promises.rm(packDir, { recursive: true, force: true })
|
|
85
|
+
process.env.POLENDINA_CONSUMERS = JSON.stringify(consumers)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export async function mochaGlobalTeardown () {
|
|
89
|
+
if (process.env.POLENDINA_KEEP_CONSUMERS) {
|
|
90
|
+
console.log('Keeping consumers:', consumers)
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
for (const dir of Object.values(consumers)) {
|
|
94
|
+
await fs.promises.rm(dir, { recursive: true, force: true })
|
|
95
|
+
}
|
|
96
|
+
}
|
package/test/test-bare-async.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
/* globals describe it */
|
|
2
2
|
|
|
3
3
|
import assert from 'assert'
|
|
4
|
-
import path from 'path'
|
|
5
|
-
import { fileURLToPath } from 'url'
|
|
6
4
|
import { runCli } from './common.js'
|
|
7
5
|
|
|
8
|
-
const __dirname = fileURLToPath(path.dirname(import.meta.url))
|
|
9
|
-
|
|
10
6
|
for (const type of ['cjs', 'esm']) {
|
|
11
|
-
const bareAsyncFixture =
|
|
12
|
-
const bareAsyncFailureFixture =
|
|
7
|
+
const bareAsyncFixture = `bare-async${type === 'esm' ? '-esm' : ''}`
|
|
8
|
+
const bareAsyncFailureFixture = `bare-async-failure${type === 'esm' ? '-esm' : ''}`
|
|
13
9
|
|
|
14
10
|
describe(`basic bare-async (${type})`, function () {
|
|
15
11
|
this.timeout(60000)
|
|
@@ -27,7 +23,7 @@ testing bare fixture subdir
|
|
|
27
23
|
`
|
|
28
24
|
|
|
29
25
|
it('should run in page', async () => {
|
|
30
|
-
const { stdout, stderr, code } = await runCli(bareAsyncFixture, '--runner=bare-async')
|
|
26
|
+
const { stdout, stderr, code } = await runCli('bare', bareAsyncFixture, ['--runner=bare-async'])
|
|
31
27
|
if (code !== 0) {
|
|
32
28
|
console.error(stderr)
|
|
33
29
|
}
|
|
@@ -41,7 +37,7 @@ testing bare fixture subdir
|
|
|
41
37
|
})
|
|
42
38
|
|
|
43
39
|
it('should run in worker', async () => {
|
|
44
|
-
const { stdout, stderr, code } = await runCli(bareAsyncFixture, '--runner=bare-async --worker --page=false')
|
|
40
|
+
const { stdout, stderr, code } = await runCli('bare', bareAsyncFixture, ['--runner=bare-async', '--worker', '--page=false'])
|
|
45
41
|
if (code !== 0) {
|
|
46
42
|
console.error(stderr)
|
|
47
43
|
}
|
|
@@ -55,7 +51,7 @@ testing bare fixture subdir
|
|
|
55
51
|
})
|
|
56
52
|
|
|
57
53
|
it('should run in serviceworker', async () => {
|
|
58
|
-
const { stdout, stderr, code } = await runCli(bareAsyncFixture, '--runner=bare-async --serviceworker --page=false')
|
|
54
|
+
const { stdout, stderr, code } = await runCli('bare', bareAsyncFixture, ['--runner=bare-async', '--serviceworker', '--page=false'])
|
|
59
55
|
if (code !== 0) {
|
|
60
56
|
console.error(stderr)
|
|
61
57
|
}
|
|
@@ -69,7 +65,7 @@ testing bare fixture subdir
|
|
|
69
65
|
})
|
|
70
66
|
|
|
71
67
|
it('should run in page, worker and serviceworker', async () => {
|
|
72
|
-
const { stdout, stderr, code } = await runCli(bareAsyncFixture, '--runner=bare-async --worker --serviceworker')
|
|
68
|
+
const { stdout, stderr, code } = await runCli('bare', bareAsyncFixture, ['--runner=bare-async', '--worker', '--serviceworker'])
|
|
73
69
|
if (code !== 0) {
|
|
74
70
|
console.error(stderr)
|
|
75
71
|
}
|
|
@@ -111,7 +107,7 @@ testing bare fixture
|
|
|
111
107
|
const expectedStderr = 'AssertionError: faily mcfailface'
|
|
112
108
|
|
|
113
109
|
it('should fail in page', async () => {
|
|
114
|
-
let { stdout, stderr, code } = await runCli(bareAsyncFailureFixture, '--runner=bare-async')
|
|
110
|
+
let { stdout, stderr, code } = await runCli('bare', bareAsyncFailureFixture, ['--runner=bare-async'])
|
|
115
111
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
116
112
|
stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
|
|
117
113
|
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
|
@@ -124,7 +120,7 @@ testing bare fixture
|
|
|
124
120
|
})
|
|
125
121
|
|
|
126
122
|
it('should fail in worker', async () => {
|
|
127
|
-
let { stdout, stderr, code } = await runCli(bareAsyncFailureFixture, '--runner=bare-async --worker --page=false')
|
|
123
|
+
let { stdout, stderr, code } = await runCli('bare', bareAsyncFailureFixture, ['--runner=bare-async', '--worker', '--page=false'])
|
|
128
124
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
129
125
|
stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
|
|
130
126
|
const expected = expectedTemplate.replace(/WORKER/, 'in worker')
|
|
@@ -137,7 +133,7 @@ testing bare fixture
|
|
|
137
133
|
})
|
|
138
134
|
|
|
139
135
|
it('should fail in serviceworker', async () => {
|
|
140
|
-
let { stdout, stderr, code } = await runCli(bareAsyncFailureFixture, '--runner=bare-async --serviceworker --page=false')
|
|
136
|
+
let { stdout, stderr, code } = await runCli('bare', bareAsyncFailureFixture, ['--runner=bare-async', '--serviceworker', '--page=false'])
|
|
141
137
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
142
138
|
stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
|
|
143
139
|
const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
|
|
@@ -150,7 +146,7 @@ testing bare fixture
|
|
|
150
146
|
})
|
|
151
147
|
|
|
152
148
|
it('should fail in page and not run in worker', async () => {
|
|
153
|
-
let { stdout, stderr, code } = await runCli(bareAsyncFailureFixture, '--runner=bare-async --worker')
|
|
149
|
+
let { stdout, stderr, code } = await runCli('bare', bareAsyncFailureFixture, ['--runner=bare-async', '--worker'])
|
|
154
150
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
155
151
|
stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
|
|
156
152
|
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|