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 language service tests in windows #30113

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codefresh/codefresh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ steps:
# Add Bazel CI config
- copy .codefresh\bazel.rc %ProgramData%\bazel.bazelrc
# Run tests
- yarn bazel test //tools/ts-api-guardian:all
- yarn bazel test //tools/ts-api-guardian:all //packages/language-service/test
- yarn test-ivy-aot //packages/animations/test //packages/common/test //packages/forms/test //packages/http/test //packages/platform-browser/test //packages/platform-browser-dynamic/test //packages/router/test
9 changes: 5 additions & 4 deletions packages/compiler-cli/test/test_support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
14 changes: 6 additions & 8 deletions packages/language-service/test/reflector_host_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
*/

import * as path from 'path';
import * as ts from 'typescript';
alan-agius4 marked this conversation as resolved.
Show resolved Hide resolved

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';
Expand All @@ -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); });
alan-agius4 marked this conversation as resolved.
Show resolved Hide resolved
}

const result = reflectorHost.moduleNameToFileName('@angular/core');
expect(result).not.toBeNull('could not find @angular/core using path.win32');
});
Expand Down