-
-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: make running tests better with --fast and --match utils
- Loading branch information
1 parent
a05e2dc
commit fb776e1
Showing
25 changed files
with
185 additions
and
723 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
--require ts-node/register | ||
--require @babel/register | ||
--require ../../../tools/test-setup.js | ||
--require ../../../tools/test-setup.ts | ||
--timeout 800000 | ||
--recursive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +0,0 @@ | ||
declare module 'yarn-or-npm' { | ||
const yon: () => 'yarn' | 'npm'; | ||
export default yon; | ||
} | ||
|
||
declare module 'sudo-prompt' { | ||
export const exec: () => void; | ||
} | ||
|
||
declare module 'resolve-package' { | ||
const resolve: (packageName: string) => Promise<string>; | ||
export default resolve; | ||
} | ||
|
||
declare module 'username' { | ||
const username: () => Promise<string>; | ||
export default username; | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +0,0 @@ | ||
declare module 'sudo-prompt' { | ||
type Exec = (command: string, app: { | ||
name: string; | ||
}) => void; | ||
export const exec: Exec; | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +0,0 @@ | ||
declare module 'sudo-prompt' { | ||
type Exec = (command: string, app: { | ||
name: string; | ||
}) => void; | ||
export const exec: Exec; | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +0,0 @@ | ||
declare module 'parse-author' { | ||
export type AuthorType = string | { | ||
name: string; | ||
} | undefined; | ||
interface ParseAuthor { | ||
(author: AuthorType): AuthorType; | ||
} | ||
const parseAuthor: ParseAuthor; | ||
export default parseAuthor; | ||
} | ||
|
||
declare module 'electron-windows-store' { | ||
const run: (opts: any) => Promise<void>; | ||
export default run; | ||
} | ||
|
||
declare module 'electron-windows-store/lib/sign' { | ||
export const isValidPublisherName: (name: string) => boolean; | ||
export const makeCert: (opts: MakerCertOptions) => Promise<string>; | ||
|
||
interface MakerCertOptions { | ||
publisherName: string; | ||
certFilePath: string; | ||
certFileName: string; | ||
install: boolean; | ||
program: any; | ||
} | ||
} | ||
|
||
declare module 'cross-spawn/lib/util/resolveCommand' { | ||
interface Opts { | ||
command: string; | ||
options: { | ||
cwd: string | null; | ||
}; | ||
} | ||
const resolveCommand: (opts: Opts, work: boolean) => string; | ||
export default resolveCommand; | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +0,0 @@ | ||
declare module 'parse-author' { | ||
export type AuthorType = string | { | ||
name: string; | ||
} | undefined; | ||
interface ParseAuthor { | ||
(author: AuthorType): AuthorType; | ||
} | ||
const parseAuthor: ParseAuthor; | ||
export default parseAuthor; | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import minimist from 'minimist'; | ||
import * as path from 'path'; | ||
import { getPackageInfoSync } from './utils'; | ||
import Glob from 'glob'; | ||
|
||
const argv = minimist( | ||
process.argv.slice( | ||
process.argv.findIndex(arg => arg === 'mocha.opts'), | ||
), | ||
); | ||
|
||
const isFast = argv.fast; | ||
|
||
const packages = getPackageInfoSync(); | ||
const testFiles: string[] = []; | ||
|
||
for (const p of packages) { | ||
if (argv.match && !p.name.includes(argv.match)) continue; | ||
|
||
testFiles.push(...Glob.sync(path.resolve(p.path, 'test', '**', `*_spec${isFast ? '' : '*'}.ts`))); | ||
} | ||
|
||
for (const f of testFiles) { | ||
require(f); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import * as chai from 'chai'; | ||
import chaiAsPromised from 'chai-as-promised'; | ||
|
||
chai.use(chaiAsPromised); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import * as fs from 'fs-extra'; | ||
import * as path from 'path'; | ||
|
||
const BASE_DIR = path.resolve(__dirname, '..'); | ||
const PACKAGES_DIR = path.resolve(BASE_DIR, 'packages'); | ||
|
||
export interface Package { | ||
path: string; | ||
name: string; | ||
} | ||
|
||
export const getPackageInfo = async () => { | ||
const packages: Package[] = []; | ||
|
||
for (const subDir of await fs.readdir(PACKAGES_DIR)) { | ||
for (const packageDir of await fs.readdir(path.resolve(PACKAGES_DIR, subDir))) { | ||
const packagePath = path.resolve(PACKAGES_DIR, subDir, packageDir); | ||
packages.push({ | ||
path: packagePath, | ||
name: (await fs.readJson(path.resolve(packagePath, 'package.json'))).name, | ||
}); | ||
} | ||
} | ||
|
||
return packages; | ||
}; | ||
|
||
export const getPackageInfoSync = () => { | ||
const packages: Package[] = []; | ||
|
||
for (const subDir of fs.readdirSync(PACKAGES_DIR)) { | ||
for (const packageDir of fs.readdirSync(path.resolve(PACKAGES_DIR, subDir))) { | ||
const packagePath = path.resolve(PACKAGES_DIR, subDir, packageDir); | ||
packages.push({ | ||
path: packagePath, | ||
name: (fs.readJsonSync(path.resolve(packagePath, 'package.json'))).name, | ||
}); | ||
} | ||
} | ||
|
||
return packages; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module 'cross-spawn/lib/util/resolveCommand'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
declare module 'electron-windows-store' { | ||
const run: (opts: any) => Promise<void>; | ||
export default run; | ||
} | ||
|
||
declare module 'electron-windows-store/lib/sign' { | ||
export const isValidPublisherName: (name: string) => boolean; | ||
export const makeCert: (opts: MakerCertOptions) => Promise<string>; | ||
|
||
interface MakerCertOptions { | ||
publisherName: string; | ||
certFilePath: string; | ||
certFileName: string; | ||
install: boolean; | ||
program: any; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
declare module 'parse-author' { | ||
type AuthorType = string | { | ||
name: string; | ||
} | undefined; | ||
interface ParseAuthor { | ||
(author: AuthorType): AuthorType; | ||
} | ||
const parseAuthor: ParseAuthor; | ||
export default parseAuthor; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
declare module 'resolve-package' { | ||
const resolve: (packageName: string) => Promise<string>; | ||
export default resolve; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
declare module 'sudo-prompt' { | ||
export const exec: () => void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
declare module 'yarn-or-npm' { | ||
const yon: () => 'yarn' | 'npm'; | ||
export default yon; | ||
} |
Oops, something went wrong.