Skip to content

Commit dab5b14

Browse files
committed
Handles new lines in the test. Updated README
1 parent 5bc263e commit dab5b14

File tree

7 files changed

+13
-45
lines changed

7 files changed

+13
-45
lines changed

README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@
22
This tool is used to generate `dom.generated.d.ts` and `webworker.generated.d.ts` for TypeScript, and `domWeb.js` and `domWindows.js` for Visual Studio JavaScript language service. The input file is the XML spec file generated by the Microsoft Edge browser.
33

44
## Build Instruction
5-
**Required Software**: Visual Studio 2015 Community Version (with Visual F# installed)
6-
7-
To build the tool, simply open the `Generator.sln` in Visual Studio and build the solution. A nuget restore should be done automatically before the build.
8-
9-
Press `F5` in Visual Studio to run the tool. If it runs successfully, the output files will be generated under the `generated` folder.
5+
To build the tool, simply clone the repo, and run `build.cmd` in command line or powershell. If it runs successfully, the output files will be generated under the `generated` folder.
106

117
## Code Structure
128
- `Shared.fs`: handles the parsing from XML spec file, and stores the common data structures for later use;
139
- `TS.fs`: handles the emitting of the `lib.d.ts` file;
1410
- `JS.fs`: handles the emitting of the `domWeb.js` and `domWindows.js`
15-
files used for Visual Studio JavaScript language service;
16-
- `Program.fs`: entry point of the tool;
11+
12+
## Contribution Guide
13+
The `dom.generated.d.ts` and `webworker.generated.d.ts` files that are used in TypeScript repo `master` branch are used as baselines. For each pull request, we will try run the script and compare the generated files with the baseline files. So to make the tests passed, please update the baseline and the code at the same pull request.
1714

1815
## Input Files:
1916
- `browser.webidl.xml`: the XML spec file generated by Microsoft Edge (due to the different updating schedules between Edge and TypeScript, this may **not** be the most up-to-date version of the spec.);

Shared.fsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ module GlobalVars =
1717

1818
let inputFolder = __SOURCE_DIRECTORY__ + @"\inputfiles"
1919
let makeTextWriter fileName = File.CreateText(__SOURCE_DIRECTORY__ + @"\generated\" + fileName) :> TextWriter
20-
let jsWebOutput = makeTextWriter "domWeb.js"
21-
let jsWinOutput = makeTextWriter "domWindows.js"
22-
let jsWorkerOutput = makeTextWriter "dedicatedworker.js"
20+
// let jsWebOutput = makeTextWriter "domWeb.js"
21+
// let jsWinOutput = makeTextWriter "domWindows.js"
22+
// let jsWorkerOutput = makeTextWriter "dedicatedworker.js"
2323
let tsWebOutput = makeTextWriter "dom.generated.d.ts"
2424
let tsWorkerOutput = makeTextWriter "webworker.generated.d.ts"
2525
let defaultEventType = "Event"

appveyor.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

baselines/dom.generated.d.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7014,14 +7014,12 @@ interface ImageData {
70147014
width: number;
70157015
}
70167016

7017-
interface ImageDataConstructor {
7017+
declare var ImageData: {
70187018
prototype: ImageData;
70197019
new(width: number, height: number): ImageData;
70207020
new(array: Uint8ClampedArray, width: number, height: number): ImageData;
70217021
}
70227022

7023-
declare var ImageData: ImageDataConstructor;
7024-
70257023
interface KeyboardEvent extends UIEvent {
70267024
altKey: boolean;
70277025
char: string;

baselines/webworker.generated.d.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,14 +465,12 @@ interface ImageData {
465465
width: number;
466466
}
467467

468-
interface ImageDataConstructor {
468+
declare var ImageData: {
469469
prototype: ImageData;
470470
new(width: number, height: number): ImageData;
471471
new(array: Uint8ClampedArray, width: number, height: number): ImageData;
472472
}
473473

474-
declare var ImageData: ImageDataConstructor;
475-
476474
interface MSApp {
477475
clearTemporaryWebDataAsync(): MSAppAsyncOperation;
478476
createBlobFromRandomAccessStream(type: string, seeker: any): Blob;

build.fsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ Target "Run" (fun _ ->
1414
)
1515

1616
let testFile file =
17-
let baseline = "./baselines/" + file
18-
let newFile = "./generated/" + file
19-
if FilesAreEqual (FileInfo baseline) (FileInfo newFile) then
17+
let baseline = File.ReadAllText("./baselines/" + file)
18+
let newFileWithLFEndings = File.ReadAllText("./generated/" + file).Replace(Environment.NewLine, "\n")
19+
if String.Equals(baseline, newFileWithLFEndings) then
2020
String.Empty
2121
else
22-
sprintf "Test failed: %s is different from baseline file.\n" newFile
22+
sprintf "\nTest failed: %s is different from baseline file." file
2323

2424
Target "Test" (fun _ ->
2525
Directory.GetFiles("./baselines")

build.sh

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)