Enable clorizer unit tests

This commit is contained in:
Mohamed Hegazy
2014-08-07 22:21:12 -07:00
parent e515ca9697
commit 3fcd33ec32
4 changed files with 110 additions and 102 deletions

View File

@@ -271,6 +271,11 @@ module Harness.LanguageService {
return this.ls;
}
/** Return a new instance of the classifier service shim */
public getClassifier(): ts.ClassifierShim {
return new TypeScript.Services.TypeScriptServicesFactory().createClassifierShim(this);
}
/** Parse file given its source text */
public parseSourceText(fileName: string, sourceText: TypeScript.IScriptSnapshot): TypeScript.SourceUnitSyntax {
return TypeScript.Parser.parse(fileName, TypeScript.SimpleText.fromScriptSnapshot(sourceText), ts.ScriptTarget.ES5, TypeScript.isDTSFile(fileName)).sourceUnit();

View File

@@ -99,6 +99,9 @@ if (runners.length === 0) {
//// language services
runners.push(new FourslashRunner());
//runners.push(new GeneratedFourslashRunner());
// unittests
runners.push(new UnitTestRunner(UnittestTestType.Services));
}
sys.newLine = '\r\n';

View File

@@ -8,7 +8,7 @@ enum UnittestTestType {
}
class UnitTestRunner extends RunnerBase {
constructor(public testType?: UnittestTestType) {
constructor(public testType: UnittestTestType) {
super();
}
@@ -20,6 +20,9 @@ class UnitTestRunner extends RunnerBase {
case UnittestTestType.LanguageService:
this.tests = this.enumerateFiles('tests/cases/unittests/ls');
break;
case UnittestTestType.Services:
this.tests = this.enumerateFiles('tests/cases/unittests/services', /colorization.ts/);
break;
default:
if (this.tests.length === 0) {
throw new Error('Unsupported test cases: ' + this.testType);
@@ -38,7 +41,7 @@ class UnitTestRunner extends RunnerBase {
});
harnessCompiler.addInputFiles(toBeAdded);
harnessCompiler.setCompilerOptions({ noResolve: true });
var stdout = new Harness.Compiler.EmitterIOHost();
var emitDiagnostics = harnessCompiler.emitAll(stdout);
var results = stdout.toArray();
@@ -59,7 +62,8 @@ class UnitTestRunner extends RunnerBase {
before: before,
after: after,
Harness: Harness,
IO: Harness.IO
IO: Harness.IO,
ts:ts
// FourSlash: FourSlash
};
}