Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(duplicated-defaults-keys): Fix Duplicated Default Keys Assigned via Object.assigbn #217

Merged
merged 4 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/Code Quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: ['ubuntu-latest']
node: ['14.x']
node: ['15.x']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
Expand All @@ -35,7 +35,7 @@ jobs:
strategy:
matrix:
os: ['ubuntu-latest']
node: ['14.x']
node: ['15.x']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
Expand Down
29 changes: 25 additions & 4 deletions .github/workflows/Push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ on:
- master

jobs:
Test:
name: Tests
IntegrationTest:
name: Integration Tests
strategy:
matrix:
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
Expand All @@ -27,5 +27,26 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Run Tests
run: npm run test
- name: Run Integration Tests
run: npm run test:integration

# UnitTests:
# name: Unit Tests
# strategy:
# matrix:
# os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
# node: ['13.9', '13.10', '13.11', '14.1', '14.4', '14.15.1', '>=14.15.0']
# runs-on: ${{ matrix.os }}
# steps:
# - uses: actions/checkout@v2

# - uses: actions/[email protected]
# with:
# node-version: ${{ matrix.node }}
# registry-url: 'https://registry.npmjs.org'

# - name: Install dependencies
# run: npm ci

# - name: Run Unit Tests
# run: npm run test:integration
40 changes: 40 additions & 0 deletions Testing/Runner/Utils/findTests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Testing/Runner/Utils/findTests.ts
import { promises as fs } from 'fs';
import { resolve } from 'path';
import { resolvePath } from './resolvePath';

interface TestFolder {
testName: string;

testFolderPath: string;
}

export async function findTestFolders(): Promise<TestFolder[]> {
const testsFolderPath = resolvePath('../../Tests/', import.meta.url);

const testFolders = await fs.readdir(testsFolderPath, {
encoding: 'utf-8',
withFileTypes: false,
});

return Promise.all(
testFolders.map(async (testFolderName) => {
const testFolderPath = resolve(testsFolderPath, testFolderName);

try {
const packageJSONFile = await fs.readFile(
resolve(testFolderPath, 'package.json'),
);

const packageJSON = JSON.parse(packageJSONFile.toString());

return {
testName: packageJSON.name,
testFolderPath: testFolderPath,
} as TestFolder;
} catch {
return undefined;
}
}),
);
}
52 changes: 52 additions & 0 deletions Testing/Runner/Utils/moduleFileFinder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Testing/Runner/Utils/moduleFileFinder.ts
import { promises as fs } from 'fs';
import { resolvePath } from './resolvePath';
import { resolve } from 'path';
import { pathToFileURL } from 'url';
type FileMatcher = RegExp;

const coreModulesDir = resolvePath('../Modules', import.meta.url);

/**
* Finds module files that match the fileMatcher
* @param
*/
export async function findModuleFiles<T>(
fileMatcher: FileMatcher,
rootDir: string = coreModulesDir,
): Promise<T[]> {
const timerKey = `findModuleFiles-${rootDir}`;

console.time(timerKey);

async function processDirectory(directoryPath: string): Promise<T[]> {
const directoryContents = await fs.readdir(directoryPath, {
encoding: 'utf-8',
withFileTypes: true,
});

return Promise.all(
directoryContents.flatMap((directoryContent) => {
const contentPath = resolve(directoryPath, directoryContent.name);

if (directoryContent.isDirectory()) {
return processDirectory(contentPath);
}

if (fileMatcher.test(directoryContent.name) === true) {
return import(pathToFileURL(contentPath).href) as Promise<T>;
}

return [];
}),
);
}

const results = await processDirectory(rootDir);

const flatResults = results.flat(50);

console.timeEnd(timerKey);

return flatResults;
}
30 changes: 23 additions & 7 deletions Testing/Runner/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
// Testing/Runner/index.ts
import { installTestsDependencies } from './Utils/installTestsDependencies';
import { run } from './Utils/run';
import { promises as fs } from 'fs';
import { findTestFolders } from './Utils/findTests';

async function runTests(): Promise<void> {
await installTestsDependencies();
const testFolders = await findTestFolders();

try {
await fs.symlink(process.cwd(), 'node_modules/@k-foss/ts-esnode', 'dir');
} catch {}

try {
await run('npx ts-estest ./Testing/Tests', {
cwd: process.cwd(),
const errs: Error[] = [];

for (const testFolder of testFolders) {
console.log(`Starting Test Folder: ${testFolder.testName}`);

await run('npm ci', {
cwd: testFolder.testFolderPath,
});
} catch {
process.exit(1);

console.log(`Packages installed`);

try {
await run('npx ts-estest ./src', {
cwd: testFolder.testFolderPath,
});
} catch (err) {
errs.push(err);
}
}

if (errs.length > 0) {
throw errs;
}
}

Expand Down
4 changes: 1 addition & 3 deletions Testing/Tests/TSConfig/src/TSConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ export class TSConfigTestSuite extends TestSuite {
'renderModule(App)',
);

process.env.TS_CONFIG_PATH = resolve(
'Testing/Tests/TSConfig/tsconfig.random.json',
);
process.env.TS_CONFIG_PATH = resolve('tsconfig.random.json');

const { Main } = await import('./Main');

Expand Down
4 changes: 1 addition & 3 deletions Testing/Tests/TSConfigExtends/src/TSConfigExtends.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ export class TSConfigExtendsTestSuite extends TestSuite {
'renderModule(App)',
);

process.env.TS_CONFIG_PATH = resolve(
'Testing/Tests/TSConfigExtends/tsconfig.random.json',
);
process.env.TS_CONFIG_PATH = resolve('tsconfig.random.json');

const { Main } = await import('./Main');

Expand Down
Loading