test: fix language service tests in windows (#30113)
This PR parially addresses #29785 and fixes ` //packages/language-service/test:test` PR Close #30113
This commit is contained in:
parent
3efdd39a18
commit
e4b81a6957
|
@ -122,20 +122,21 @@ export function setupBazelTo(tmpDirPath: string) {
|
|||
fs.mkdirSync(nodeModulesPath);
|
||||
fs.mkdirSync(angularDirectory);
|
||||
|
||||
getAngularPackagesFromRunfiles().forEach(
|
||||
({pkgPath, name}) => { fs.symlinkSync(pkgPath, path.join(angularDirectory, name), 'dir'); });
|
||||
getAngularPackagesFromRunfiles().forEach(({pkgPath, name}) => {
|
||||
fs.symlinkSync(pkgPath, path.join(angularDirectory, name), 'junction');
|
||||
});
|
||||
|
||||
// Link typescript
|
||||
const typeScriptSource = resolveNpmTreeArtifact('npm/node_modules/typescript');
|
||||
const typescriptDest = path.join(nodeModulesPath, 'typescript');
|
||||
fs.symlinkSync(typeScriptSource, typescriptDest, 'dir');
|
||||
fs.symlinkSync(typeScriptSource, typescriptDest, 'junction');
|
||||
|
||||
// Link "rxjs" if it has been set up as a runfile. "rxjs" is linked optionally because
|
||||
// not all compiler-cli tests need "rxjs" set up.
|
||||
try {
|
||||
const rxjsSource = resolveNpmTreeArtifact('rxjs', 'index.js');
|
||||
const rxjsDest = path.join(nodeModulesPath, 'rxjs');
|
||||
fs.symlinkSync(rxjsSource, rxjsDest, 'dir');
|
||||
fs.symlinkSync(rxjsSource, rxjsDest, 'junction');
|
||||
} catch (e) {
|
||||
if (e.code !== 'MODULE_NOT_FOUND') throw e;
|
||||
}
|
||||
|
|
|
@ -7,12 +7,8 @@
|
|||
*/
|
||||
|
||||
import * as path from 'path';
|
||||
import * as ts from 'typescript';
|
||||
|
||||
import {createLanguageService} from '../src/language_service';
|
||||
import {ReflectorHost} from '../src/reflector_host';
|
||||
import {Completions, LanguageService} from '../src/types';
|
||||
import {TypeScriptServiceHost} from '../src/typescript_host';
|
||||
|
||||
import {toh} from './test_data';
|
||||
import {MockTypescriptHost} from './test_utils';
|
||||
|
@ -25,12 +21,14 @@ describe('reflector_host_spec', () => {
|
|||
let mockHost = new MockTypescriptHost(
|
||||
['/app/main.ts', '/app/parsing-cases.ts'], toh, 'app/node_modules',
|
||||
{...path, join: (...args: string[]) => originalJoin.apply(path, args)});
|
||||
let service = ts.createLanguageService(mockHost);
|
||||
let ngHost = new TypeScriptServiceHost(mockHost, service);
|
||||
let ngService = createLanguageService(ngHost);
|
||||
const reflectorHost = new ReflectorHost(() => undefined as any, mockHost, {basePath: '\\app'});
|
||||
|
||||
spyOn(path, 'join').and.callFake((...args: string[]) => { return path.win32.join(...args); });
|
||||
if (process.platform !== 'win32') {
|
||||
// If we call this in Windows it will cause a 'Maximum call stack size exceeded error'
|
||||
// Because we are spying on the same function that we are call faking
|
||||
spyOn(path, 'join').and.callFake((...args: string[]) => { return path.win32.join(...args); });
|
||||
}
|
||||
|
||||
const result = reflectorHost.moduleNameToFileName('@angular/core');
|
||||
expect(result).not.toBeNull('could not find @angular/core using path.win32');
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue