Skip to content

Commit f1e21bf

Browse files
committed
test: test fixtures in parallel
1 parent 8d86f0f commit f1e21bf

File tree

7 files changed

+42
-34
lines changed

7 files changed

+42
-34
lines changed

.github/workflows/CI.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ jobs:
3535
- name: Install dependencies
3636
run: pnpm install
3737

38-
# - name: Format ✨
39-
# run: pnpm run test.format
38+
- name: Format ✨
39+
run: pnpm run test.format
4040

4141
- name: Lint ✨
4242
run: pnpm run test.lint
4343

44-
# - name: Tests
45-
# run: |
46-
# pnpm test
44+
- name: Tests
45+
run: |
46+
pnpm test
4747
4848
# Release:
4949
# needs: [Test]

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ spec/fixtures/atom-community
1616
spec/fixtures/atom-minimap
1717
spec/fixtures/aminya
1818
spec/fixtures/steelbrain
19+
20+
*.tar.gz

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
"*.js"
1515
],
1616
"scripts": {
17-
"dev": "tsc --pretty --watch",
1817
"build": "tsc --pretty",
1918
"bump": "ncu -u -x coffeescript,execa,read-pkg-up,make-synchronous && pnpm update && pnpm dedupe",
2019
"clean": "shx rm -rf ./spec/fixtures/ ./dist",
20+
"dev": "tsc --pretty --watch",
2121
"format": "prettier --write .",
2222
"lint": "eslint ./ --ignore dist --fix",
2323
"prepare": "pnpm run build",

spec/test.cjs

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,42 +45,48 @@ async function testLint(packedPkg, testRepo, isWorkspace = false, isSilent = fal
4545
throw e
4646
}
4747

48-
const result = await execa.command("eslint .", { cwd: distFolder, stdout: !isSilent ? "inherit" : "pipe" })
48+
const result = await execa.command("eslint . --cache", { cwd: distFolder, stdout: !isSilent ? "inherit" : "pipe" })
4949
if (result.failed) {
5050
throw new Error("An error happened")
5151
}
5252
}
5353

5454
/** Main entry */
55-
;(async function main() {
55+
async function main() {
5656
const root = resolve(dirname(__dirname))
5757
const packedPkg = join(root, `${pkg.name}-${pkg.version}.tgz`)
5858
rm("-rf", packedPkg)
5959
await execa.command("pnpm pack", { cwd: root })
6060

6161
const errs = []
62-
for (const testRepo of testRepos) {
63-
try {
64-
// We want to observe the output in order, so we await inside loop
65-
await testLint(packedPkg, testRepo, false) // eslint-disable-line no-await-in-loop
66-
} catch (err) {
67-
console.error(err)
68-
errs.push(err)
69-
}
70-
}
62+
await Promise.all([
63+
...testRepos.map(async (testRepo) => {
64+
try {
65+
await testLint(packedPkg, testRepo, false)
66+
} catch (err) {
67+
console.error(err)
68+
errs.push(err)
69+
}
70+
}),
71+
...testWorkspaces.map(async (testWorkspace) => {
72+
try {
73+
await testLint(packedPkg, testWorkspace, true, true)
74+
} catch (err) {
75+
console.error(err)
76+
errs.push(err)
77+
}
78+
}),
79+
])
7180

72-
for (const testWorkspace of testWorkspaces) {
73-
try {
74-
await testLint(packedPkg, testWorkspace, true, true) // eslint-disable-line no-await-in-loop
75-
} catch (err) {
76-
console.error(err)
77-
errs.push(err)
78-
}
79-
}
8081
if (errs.length !== 0) {
8182
rm("-rf", packedPkg)
8283
throw new Error(`${errs.length} packages failed the tests. See the above.`)
8384
}
8485

8586
rm("-rf", packedPkg)
86-
})()
87+
}
88+
89+
main().catch((err) => {
90+
console.error(err)
91+
process.exit(1)
92+
})

src/index-react.cts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ import type { Linter } from "eslint"
22
import base from "./index.cjs"
33
import { tsConfigs } from "./typescript.cjs"
44
import reactPlugin from "eslint-plugin-react"
5-
import globals from "globals";
5+
import globals from "globals"
66

77
const reactTypeScript: Linter.Config = {
88
...tsConfigs,
9-
...reactPlugin.configs.flat.recommended
10-
};
9+
...reactPlugin.configs.flat.recommended,
10+
}
1111

1212
const nonStrictConfig: Linter.Config[] = [
1313
...base,
1414
// JavaScript:
1515
{
16-
files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
16+
files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"],
1717
...reactPlugin.configs.flat.recommended,
1818
},
1919
{
20-
files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
20+
files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"],
2121
languageOptions: {
2222
globals: {
2323
...globals.serviceworker,

src/index-solid.cts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import solid from "eslint-plugin-solid"
55

66
const solidTypeScript: Linter.Config = {
77
...tsConfig,
8-
...solid.configs["flat/typescript"]
9-
};
8+
...solid.configs["flat/typescript"],
9+
}
1010

1111
const nonStrictConfig: Linter.Config[] = [
1212
...base,

src/typescript.cts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export const tsConfig: Linter.Config = {
148148
...pluginImportTypeScriptRulesExtra,
149149
...importPlugin.configs.recommended.rules,
150150
},
151-
};
151+
}
152152

153153
export const tsConfigs: Linter.Config[] = [
154154
// TypeScript files

0 commit comments

Comments
 (0)