Skip to content

Commit

Permalink
Merge pull request #3269 from terascope/scripts-fix
Browse files Browse the repository at this point in the history
Allow scripts test suite to better run with asset directory structures
  • Loading branch information
jsnoble authored Jun 21, 2022
2 parents 1ad56ff + 7748843 commit 6dce410
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@terascope/scripts",
"displayName": "Scripts",
"version": "0.48.1",
"version": "0.49.0",
"description": "A collection of terascope monorepo scripts",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/scripts#readme",
"bugs": {
Expand Down
5 changes: 4 additions & 1 deletion packages/scripts/src/helpers/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export type PackageConfig = {
testSuite?: string;
allowBumpWhenPrivate?: boolean;
linkToMain?: boolean;
root?: boolean
tests?: Record<string, Record<string, string[]>>
};

export enum Hook {
Expand Down Expand Up @@ -113,7 +115,8 @@ export type RootPackageInfo = {
};

export const AvailablePackageConfigKeys: readonly (keyof PackageConfig)[] = [
'enableTypedoc', 'testSuite', 'main', 'allowBumpWhenPrivate', 'linkToMain'
'enableTypedoc', 'testSuite', 'main', 'allowBumpWhenPrivate',
'linkToMain', 'root', 'tests'
];

export type TSCommands = 'docs';
Expand Down
12 changes: 2 additions & 10 deletions packages/scripts/src/helpers/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ export function listPackages(
.filter((pkg): pkg is i.PackageInfo => pkg?.name != null);

const sortedNames = getSortedPackages(packages);

_packages = sortedNames.map((name) => (
packages.find((pkg) => pkg.name === name)!
));

return _packages;
}

Expand Down Expand Up @@ -167,15 +169,6 @@ export function isMainPackage(pkgInfo: i.PackageInfo): boolean {
return get(pkgInfo, 'terascope.main', false);
}

export function addPackageConfig(pkgInfo: i.PackageInfo): void {
for (const _key of Object.keys(pkgInfo.terascope)) {
const key = _key as (keyof i.PackageConfig);
if (!i.AvailablePackageConfigKeys.includes(key)) {
throw new Error(`Unknown terascope config "${key}" found in "${pkgInfo.name}" package`);
}
}
}

export function readPackageInfo(folderPath: string): i.PackageInfo {
const dir = path.isAbsolute(folderPath)
? path.join(folderPath)
Expand Down Expand Up @@ -239,7 +232,6 @@ export function updatePkgInfo(pkgInfo: i.PackageInfo): void {

pkgInfo.folderName = path.basename(pkgInfo.dir);
pkgInfo.relativeDir = path.relative(rootInfo.dir, pkgInfo.dir);
addPackageConfig(pkgInfo);

if (!pkgInfo.displayName) {
pkgInfo.displayName = misc.getName(pkgInfo.folderName);
Expand Down
12 changes: 10 additions & 2 deletions packages/scripts/src/helpers/test-runner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ async function _runTests(
await runE2ETest(options, tracker);
return;
}

const filtered = utils.filterBySuite(pkgInfos, options);

if (!filtered.length) {
signale.warn('No tests found.');
return;
Expand Down Expand Up @@ -128,7 +128,15 @@ async function runTestSuite(
}

const args = utils.getArgs(options);
args.projects = pkgs.map((pkgInfo) => pkgInfo.relativeDir);

args.projects = pkgs.map(
(pkgInfo) => {
if (pkgInfo.relativeDir.length) {
return pkgInfo.relativeDir;
}
return '.';
}
);

tracker.started += pkgs.length;
try {
Expand Down

0 comments on commit 6dce410

Please sign in to comment.