Skip to content
Permalink
Browse files

refactor: make running tests better with --fast and --match utils

  • Loading branch information
MarshallOfSound committed Nov 24, 2018
1 parent a05e2dc commit fb776e19aebf377a53f240a644f9c3a8ca44bfe6
@@ -13,4 +13,4 @@ bolt
bolt build
bolt lint

DEBUG=electron-installer-snap:snapcraft CI=true bolt ws test -- --installer=$NODE_INSTALLER
DEBUG=electron-installer-snap:snapcraft CI=true bolt test -- --installer=$NODE_INSTALLER
@@ -1,3 +1,5 @@
--require ts-node/register
--require @babel/register
--require ../../../tools/test-setup.js
--require ../../../tools/test-setup.ts
--timeout 800000
--recursive
@@ -34,7 +34,7 @@
"docs:deploy": "ts-node tools/sync-readmes.ts && bolt docs && ts-node tools/copy-now.ts && cd docs && now && now alias",
"docs:deploy:ci": "ts-node tools/sync-readmes.ts && bolt docs && ts-node tools/copy-now.ts && cd docs && now --token $NOW_TOKEN && now alias --token $NOW_TOKEN",
"lint": "ts-node tools/link-ts.ts && bolt ws exec -- node_modules/.bin/tslint src/**/*.ts test/**/*.ts",
"test": "bolt ws run test"
"test": "TS_NODE_FILES=true yarn run mocha './tools/test-globber.ts' --opts mocha.opts"
},
"dependencies": {
"@octokit/rest": "^15.2.6",
@@ -112,6 +112,7 @@
"@types/lodash.template": "^4.4.4",
"@types/log-symbols": "^2.0.0",
"@types/mime-types": "^2.1.0",
"@types/minimist": "^1.2.0",
"@types/mocha": "^5.1.0",
"@types/node": "10.12.0",
"@types/node-fetch": "^2.1.2",
@@ -122,6 +123,7 @@
"@types/proxyquire": "^1.3.28",
"@types/semver": "^5.5.0",
"@types/sinon": "5.0.5",
"@types/username": "^3.0.0",
"@types/webpack": "4.4.17",
"@types/webpack-dev-middleware": "^2.0.1",
"@types/webpack-hot-middleware": "^2.16.3",
@@ -134,12 +136,10 @@
"coveralls": "^3.0.0",
"cross-env": "^5.0.0",
"cz-customizable": "^5.0.0",
"esdoc": "^1.0.1",
"esdoc-importpath-plugin": "^1.0.0",
"esdoc-standard-plugin": "^1.0.0",
"fetch-mock": "^6.0.0",
"generate-changelog": "^1.0.2",
"listr": "^0.14.1",
"minimist": "^1.2.0",
"mocha": "^5.0.0",
"nodemon": "^1.11.0",
"nyc": "^13.0.1",

This file was deleted.

@@ -5,11 +5,6 @@
"repository": "https://github.com/electron-userland/electron-forge",
"main": "dist/api/index.js",
"typings": "dist/api/index.d.ts",
"scripts": {
"docs": "esdoc",
"test:fast": "mocha --require ts-node/register test/**/*_spec.ts test/**/**/*_spec.ts --opts ../../../mocha.opts",
"test": "mocha --require ts-node/register test/**/*_spec.ts test/**/**/*_spec.ts test/slow/*_spec_slow.ts --opts ../../../mocha.opts"
},
"author": "Samuel Attard",
"license": "MIT",
"devDependencies": {
@@ -25,9 +20,6 @@
"asar": "^0.14.0",
"chai": "4.2.0",
"chai-as-promised": "^7.0.0",
"esdoc": "^1.0.1",
"esdoc-importpath-plugin": "^1.0.0",
"esdoc-standard-plugin": "^1.0.0",
"fetch-mock": "^6.0.0",
"mocha": "^5.0.0",
"proxyquire": "^2.0.1",
@@ -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;
}
@@ -1,6 +0,0 @@
declare module 'sudo-prompt' {
type Exec = (command: string, app: {
name: string;
}) => void;
export const exec: Exec;
}
@@ -1,6 +0,0 @@
declare module 'sudo-prompt' {
type Exec = (command: string, app: {
name: string;
}) => void;
export const exec: Exec;
}
@@ -1,4 +1,8 @@
import parseAuthor, { AuthorType } from 'parse-author';
import parseAuthor from 'parse-author';

type AuthorType = string | {
name: string;
} | undefined;

export default function getNameFromAuthor(author: AuthorType) {
let publisher: AuthorType = author || '';
@@ -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;
}
@@ -1,4 +1,8 @@
import parseAuthor, { AuthorType } from 'parse-author';
import parseAuthor from 'parse-author';

type AuthorType = string | {
name: string;
} | undefined;

export default function getNameFromAuthor(author: AuthorType) {
let publisher: AuthorType = author || '';
@@ -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;
}
@@ -1,24 +1,18 @@
import * as fs from 'fs-extra';
import Glob from 'glob';
import * as path from 'path';
import { getPackageInfo } from './utils';

const DOCS_PATH = path.resolve(__dirname, '..', 'docs');
const BASE_DIR = path.resolve(__dirname, '..');
const PACKAGES_DIR = path.resolve(BASE_DIR, 'packages');

(async () => {
const packageDirs = [];

for (const subDir of await fs.readdir(PACKAGES_DIR)) {
for (const packageDir of await fs.readdir(path.resolve(PACKAGES_DIR, subDir))) {
packageDirs.push(path.resolve(PACKAGES_DIR, subDir, packageDir));
}
}
const packages = await getPackageInfo();

let copiedAssets = false;
await fs.remove(path.resolve(DOCS_PATH, 'assets'));
await fs.remove(path.resolve(DOCS_PATH));
for (const dir of packageDirs) {
for (const p of packages) {
const dir = p.path;
const subPath = path.posix.join(path.basename(path.dirname(dir)), path.basename(dir));
const docPath = path.resolve(DOCS_PATH, subPath);
if (!copiedAssets) {
@@ -38,7 +32,7 @@ const PACKAGES_DIR = path.resolve(BASE_DIR, 'packages');
.replace(/=\"[^"]*assets\//gi, '="/assets/')
.replace(/(<a href="(?!(?:https?:\/\/)|\/|\#))(.+?)"/gi, (subString, m1: string, m2: string) => {
return `${m1}/${path.posix.join(subPath, relative, m2)}"`;
})
}),
);
}
}
@@ -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.

@@ -0,0 +1,4 @@
import * as chai from 'chai';
import chaiAsPromised from 'chai-as-promised';

chai.use(chaiAsPromised);
@@ -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;
};
@@ -9,7 +9,7 @@
"es7"
],
"sourceMap": true,
"rootDir": "src",
"rootDir": ".",
"experimentalDecorators": true,
"strict": true,
"esModuleInterop": true,
@@ -0,0 +1 @@
declare module 'cross-spawn/lib/util/resolveCommand';
@@ -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;
}
}
@@ -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;
}
@@ -0,0 +1,4 @@
declare module 'resolve-package' {
const resolve: (packageName: string) => Promise<string>;
export default resolve;
}
@@ -0,0 +1,3 @@
declare module 'sudo-prompt' {
export const exec: () => void;
}
@@ -0,0 +1,4 @@
declare module 'yarn-or-npm' {
const yon: () => 'yarn' | 'npm';
export default yon;
}

0 comments on commit fb776e1

Please sign in to comment.
You can’t perform that action at this time.