|
| 1 | +import * as glob from 'glob'; |
| 2 | +import * as fs from 'fs'; |
| 3 | +import * as path from 'path'; |
| 4 | + |
| 5 | +describe('@sentry/angular-ivy', () => { |
| 6 | + /* |
| 7 | + * This test ensures that the source files in @sentry/angular-ivy are in sync with @sentry/angular. |
| 8 | + * If this test fails, run `yarn build` in `packages/angular-ivy` to update the sym-linked files. |
| 9 | + */ |
| 10 | + test('ivy source files should be sym-linked and in sync with @sentry/angular', () => { |
| 11 | + const angularBaseDir = path.resolve(__dirname, '..'); |
| 12 | + const angularIvyBaseDir = path.resolve(__dirname, '..', '..', 'angular-ivy'); |
| 13 | + |
| 14 | + const angularSourceFilePaths = glob.sync(path.join(angularBaseDir, 'src', '**', '*')); |
| 15 | + const angularIvySourceFilePaths = glob.sync(path.join(angularIvyBaseDir, 'src', '**', '*')); |
| 16 | + |
| 17 | + const angularSourceFiles = angularSourceFilePaths.map(filePath => path.relative(angularBaseDir, filePath)); |
| 18 | + const angularIvySourceFiles = angularIvySourceFilePaths.map(filePath => path.relative(angularIvyBaseDir, filePath)); |
| 19 | + |
| 20 | + // shallow equality check |
| 21 | + expect(angularSourceFiles).toStrictEqual(angularIvySourceFiles); |
| 22 | + |
| 23 | + // all files in angular-ivy should be sym-linked except for sdk.ts |
| 24 | + angularIvySourceFilePaths |
| 25 | + .filter(filePath => path.relative(angularIvyBaseDir, filePath) !== path.join('src', 'sdk.ts')) |
| 26 | + .forEach(ivyFilePath => { |
| 27 | + expect(fs.lstatSync(ivyFilePath).isSymbolicLink()).toBe(true); |
| 28 | + expect(angularSourceFilePaths).toContain(fs.realpathSync(ivyFilePath)); |
| 29 | + }); |
| 30 | + }); |
| 31 | +}); |
0 commit comments