Skip to content

Commit 211ac96

Browse files
committed
add test to ensure source files are in sync
1 parent 0f8b396 commit 211ac96

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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

Comments
 (0)