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(task): consider config sys in task runner #3518

Merged
merged 1 commit into from
Aug 15, 2022
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
2 changes: 1 addition & 1 deletion src/cli/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export const runTask = async (
flags: createConfigFlags(config.flags ?? { task }),
logger,
outputTargets: config.outputTargets ?? [],
sys: sys ?? coreCompiler.createSystem({ logger }),
sys: sys ?? config.sys ?? coreCompiler.createSystem({ logger }),
testing: config.testing ?? {},
};

Expand Down
32 changes: 32 additions & 0 deletions src/cli/test/run.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,38 @@ describe('run', () => {
taskTestSpy.mockRestore();
});

describe('default configuration', () => {
describe('sys property', () => {
it('uses the sys argument if one is provided', async () => {
// remove the `CompilerSystem` on the config, just to be sure we don't accidentally use it
unvalidatedConfig.sys = undefined;

validatedConfig = mockValidatedConfig({ sys });

await runTask(coreCompiler, unvalidatedConfig, 'build', sys);

// first validate there was one call, and that call had two arguments
expect(taskBuildSpy).toHaveBeenCalledTimes(1);
expect(taskBuildSpy).toHaveBeenCalledWith(coreCompiler, validatedConfig);

const compilerSystemUsed: d.CompilerSystem = taskBuildSpy.mock.calls[0][1].sys;
expect(compilerSystemUsed).toBe(sys);
});

it('uses the sys field on the config if no sys argument is provided', async () => {
// if the optional `sys` argument isn't provided, attempt to default to the one on the config
await runTask(coreCompiler, unvalidatedConfig, 'build');

// first validate there was one call, and that call had two arguments
expect(taskBuildSpy).toHaveBeenCalledTimes(1);
expect(taskBuildSpy).toHaveBeenCalledWith(coreCompiler, validatedConfig);

const compilerSystemUsed: d.CompilerSystem = taskBuildSpy.mock.calls[0][1].sys;
expect(compilerSystemUsed).toBe(unvalidatedConfig.sys);
});
});
});

it('calls the build task', async () => {
await runTask(coreCompiler, unvalidatedConfig, 'build', sys);

Expand Down