Skip to content

Update rwc and test262 runner #1894

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

Merged
merged 8 commits into from
Feb 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions Jakefile
Original file line number Diff line number Diff line change
Expand Up @@ -457,14 +457,16 @@ directory(builtLocalDirectory);
var run = path.join(builtLocalDirectory, "run.js");
compileFile(run, harnessSources, [builtLocalDirectory, tscFile].concat(libraryTargets).concat(harnessSources), [], /*useBuiltCompiler:*/ true);

var internalTests = "internal/"

var localBaseline = "tests/baselines/local/";
var refBaseline = "tests/baselines/reference/";

var localRwcBaseline = "tests/baselines/rwc/local/";
var refRwcBaseline = "tests/baselines/rwc/reference/";
var localRwcBaseline = path.join(internalTests, "baselines/rwc/local");
var refRwcBaseline = path.join(internalTests, "baselines/rwc/reference");

var localTest262Baseline = "tests/baselines/test262/local/";
var refTest262Baseline = "tests/baselines/test262/reference/";
var localTest262Baseline = path.join(internalTests, "baselines/test262/local");
var refTest262Baseline = path.join(internalTests, "baselines/test262/reference");

desc("Builds the test infrastructure using the built compiler");
task("tests", ["local", run].concat(libraryTargets));
Expand Down Expand Up @@ -497,11 +499,13 @@ function cleanTestDirs() {
jake.rmRf(localBaseline);
}

// Clean the local Rwc baselines directory
// Clean the local Rwc baselines directory
if (fs.existsSync(localRwcBaseline)) {
jake.rmRf(localRwcBaseline);
}

jake.mkdirP(localRwcBaseline);
jake.mkdirP(localTest262Baseline);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent

jake.mkdirP(localBaseline);
}

Expand All @@ -513,8 +517,8 @@ function writeTestConfigFile(tests, testConfigFile) {
}

function deleteTemporaryProjectOutput() {
if (fs.existsSync(localBaseline + "projectOutput/")) {
jake.rmRf(localBaseline + "projectOutput/");
if (fs.existsSync(path.join(localBaseline, "projectOutput/"))) {
jake.rmRf(path.join(localBaseline, "projectOutput/"));
}
}

Expand Down
29 changes: 20 additions & 9 deletions src/harness/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1569,21 +1569,32 @@ module Harness {
export interface BaselineOptions {
LineEndingSensitive?: boolean;
Subfolder?: string;
Baselinefolder?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these capitalized?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just try to keep with the style

}

export function localPath(fileName: string, subfolder?: string) {
return baselinePath(fileName, 'local', subfolder);
export function localPath(fileName: string, baselineFolder?: string, subfolder?: string) {
if (baselineFolder === undefined) {
return baselinePath(fileName, 'local', 'tests/baselines', subfolder);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just always take the baselineFolder and just have each runner pass in the right thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compiler Runner/project runner/ fourslash runner don't need that.

}
else {
return baselinePath(fileName, 'local', baselineFolder, subfolder);
}
}

function referencePath(fileName: string, subfolder?: string) {
return baselinePath(fileName, 'reference', subfolder);
function referencePath(fileName: string, baselineFolder?: string, subfolder?: string) {
if (baselineFolder === undefined) {
return baselinePath(fileName, 'reference', 'tests/baselines', subfolder);
}
else {
return baselinePath(fileName, 'reference', baselineFolder, subfolder);
}
}

function baselinePath(fileName: string, type: string, subfolder?: string) {
function baselinePath(fileName: string, type: string, baselineFolder: string, subfolder?: string) {
if (subfolder !== undefined) {
return Harness.userSpecifiedroot + 'tests/baselines/' + subfolder + '/' + type + '/' + fileName;
return Harness.userSpecifiedroot + baselineFolder + '/' + subfolder + '/' + type + '/' + fileName;
} else {
return Harness.userSpecifiedroot + 'tests/baselines/' + type + '/' + fileName;
return Harness.userSpecifiedroot + baselineFolder + '/' + type + '/' + fileName;
}
}

Expand Down Expand Up @@ -1637,7 +1648,7 @@ module Harness {
return;
}

var refFilename = referencePath(relativeFilename, opts && opts.Subfolder);
var refFilename = referencePath(relativeFilename, opts && opts.Baselinefolder, opts && opts.Subfolder);

if (actual === null) {
actual = '<no content>';
Expand Down Expand Up @@ -1675,7 +1686,7 @@ module Harness {
opts?: BaselineOptions): void {

var actual = <string>undefined;
var actualFilename = localPath(relativeFilename, opts && opts.Subfolder);
var actualFilename = localPath(relativeFilename, opts && opts.Baselinefolder, opts && opts.Subfolder);

if (runImmediately) {
actual = generateActual(actualFilename, generateContent);
Expand Down
7 changes: 5 additions & 2 deletions src/harness/rwcRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ module RWC {
var otherFiles: { unitName: string; content: string; }[] = [];
var compilerResult: Harness.Compiler.CompilerResult;
var compilerOptions: ts.CompilerOptions;
var baselineOpts: Harness.Baseline.BaselineOptions = { Subfolder: 'rwc' };
var baselineOpts: Harness.Baseline.BaselineOptions = {
Subfolder: 'rwc',
Baselinefolder: 'internal/baselines'
};
var baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2];
var currentDirectory: string;

Expand Down Expand Up @@ -170,7 +173,7 @@ module RWC {
}

class RWCRunner extends RunnerBase {
private static sourcePath = "tests/cases/rwc/";
private static sourcePath = "internal/cases/rwc/";

/** Setup the runner's tests so that they are ready to be executed by the harness
* The first test should be a describe/it block that sets up the harness's compiler instance appropriately
Expand Down
7 changes: 5 additions & 2 deletions src/harness/test262Runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <reference path='syntacticCleaner.ts' />

class Test262BaselineRunner extends RunnerBase {
private static basePath = 'tests/cases/test262';
private static basePath = 'internal/cases/test262';
private static helpersFilePath = 'tests/cases/test262-harness/helpers.d.ts';
private static helperFile = {
unitName: Test262BaselineRunner.helpersFilePath,
Expand All @@ -15,7 +15,10 @@ class Test262BaselineRunner extends RunnerBase {
target: ts.ScriptTarget.Latest,
module: ts.ModuleKind.CommonJS
};
private static baselineOptions: Harness.Baseline.BaselineOptions = { Subfolder: 'test262' };
private static baselineOptions: Harness.Baseline.BaselineOptions = {
Subfolder: 'test262',
Baselinefolder: 'internal/baselines'
};

private static getTestFilePath(filename: string): string {
return Test262BaselineRunner.basePath + "/" + filename;
Expand Down