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(legacy-tools): fix tooling to build and test in windows #3800

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
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
40 changes: 33 additions & 7 deletions packages/legacy/tools/src/models/package/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class Package {

const inputPath = path.join(this.data.packageRoot, source);

console.log('sreenara package.build', inputPath);

const javascriptFileCollector = javascript
? Package.getFiles({ location: inputPath, pattern: CONSTANTS.PATTERNS.JAVASCRIPT, targets: undefined })
: Promise.resolve([]);
Expand All @@ -73,6 +75,8 @@ class Package {
.then(([javascriptFiles, typescriptFiles]) => {
const sourceFiles = [...javascriptFiles, ...typescriptFiles];

console.log('sreenara package.build', sourceFiles);

const files = sourceFiles.map((file) => new PackageFile({
directory: source,
location: file.replace(inputPath, ''),
Expand All @@ -97,25 +101,44 @@ class Package {
* @param config - Test configuration Object.
* @returns - Promise resolving to this Package instance.
*/
public test(config: TestConfig): Promise<this> {
public async test(config: TestConfig): Promise<this> {
const testDirectory = path.join(this.data.packageRoot, CONSTANTS.TEST_DIRECTORIES.ROOT);

const unitTestFileCollector = config.unit
? Package.getFiles({
console.log(
'sreenara test config, pattern, location',
config,
CONSTANTS.PATTERNS.TEST,
path.join(testDirectory, CONSTANTS.TEST_DIRECTORIES.UNIT),
);
let unitTestFileCollector = config.unit
? await Package.getFiles({
location: path.join(testDirectory, CONSTANTS.TEST_DIRECTORIES.UNIT),
pattern: CONSTANTS.PATTERNS.TEST,
targets: config.targets,
})
: Promise.resolve([]);

const integrationTestFileCollector = config.integration
? Package.getFiles({
console.log('sreenara unitTestFileCollector before changes', unitTestFileCollector);
unitTestFileCollector = (unitTestFileCollector as unknown as string[]).map((filename) => {
const newFile = filename.replace(/\\/g, '/');
console.log('new filename', newFile);
return newFile;
});
console.log('sreenara unitTestFileCollector after changes', unitTestFileCollector);
let integrationTestFileCollector = config.integration
? await Package.getFiles({
location: path.join(testDirectory, CONSTANTS.TEST_DIRECTORIES.INTEGRATION),
pattern: CONSTANTS.PATTERNS.TEST,
targets: config.targets,
})
: Promise.resolve([]);

integrationTestFileCollector = (integrationTestFileCollector as unknown as string[]).map((filename) => {
const newFile = filename.replace(/\\/g, '/');
console.log('new filename', newFile);
return newFile;
});

return Promise.all([unitTestFileCollector, integrationTestFileCollector])
.then(async ([unitFiles, integrationFiles]) => {
if (config.runner === 'jest') {
Expand Down Expand Up @@ -159,13 +182,16 @@ class Package {
*/
protected static getFiles({ location, pattern, targets }:
{ location: string, pattern: string, targets: string | undefined }): Promise<Array<string>> {
console.log('sreenara package.getFiles()', location, pattern, targets);
let target;
if (!targets) {
target = path.join(location, pattern);
// target = path.posix.join(location, pattern);
target = path.join(location, pattern).replace(/\\/g, '/');
} else {
target = path.join(location, targets);
target = path.join(location, targets).replace(/\\/g, '/');
}

console.log('sreenara package.getFiles() target', target);
return glob.glob(target);
}

Expand Down
1 change: 1 addition & 0 deletions packages/legacy/tools/src/utils/jest/jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Jest {
* @returns - Empty Promise.
*/
public static test({ files }: { files: Array<string> }): Promise<void> {
console.log('sreenara running jest.test files', files);
return Jest.wrapper.run(files);
}

Expand Down
Loading