Skip to content
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
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ Options:
--version Show version number [boolean]
--lt, --luaTarget Specify Lua target version.
[string] [choices: "JIT", "5.1", "5.2", "5.3"] [default: "JIT"]
--lld, --luaLibDir Specify typescript_lualib.lua location relative to outDir.
[string] [default: "./"]
--ah, --addHeader Specify if a header will be added to compiled files.
[boolean] [default: true]

Expand All @@ -53,9 +51,9 @@ Examples:
"noImplicitAny" : true,
"noImplicitThis" : true,
"alwaysStrict" : true,
"strictNullChecks": true,
"luaTarget": "JIT"
}
"strictNullChecks": true
},
"luaTarget": "JIT"
}
```

Expand Down
47 changes: 42 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
},
"dependencies": {
"dedent": "^0.7.0",
"fs-extra": "^5.0.0",
"typescript": "^2.7.2",
"yargs": "^11.0.0"
},
"devDependencies": {
"@types/fs-extra": "^5.0.1",
"@types/node": "^9.4.7",
"@types/yargs": "^11.0.0",
"alsatian": "^2.2.1",
"codecov": "^3.0.0",
Expand Down
39 changes: 39 additions & 0 deletions test/integration/compiler.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Expect, Teardown, Test, TestCase } from "alsatian";
import { execSync } from "child_process"
import { existsSync, removeSync, unlink } from "fs-extra"
import { resolve } from "path"

export class CompilerTests {

@TestCase('tsconfig.default.json', ['typescript_lualib.lua', 'nested/folder/file.lua'])
@TestCase('tsconfig.outDir.json', ['outDir/typescript_lualib.lua', 'outDir/nested/folder/file.lua'])
@TestCase('tsconfig.rootDir.json', ['nested/typescript_lualib.lua', 'nested/folder/file.lua'])
@TestCase('tsconfig.bothDirOptions.json', ['outDir/typescript_lualib.lua', 'outDir/folder/file.lua'])
@Test("Compile project")
public compileProject(tsconfig: string, expectedFiles: string[]) {
const compilerPath = resolve('dist/Compiler.js');
const tsconfigPath = resolve('test/integration/project', tsconfig);

// Compile project
execSync(`node ${compilerPath} -p ${tsconfigPath}`);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't use exec to test. Errors won't be reported correctly also coverage reports probably won't work either.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What should I use instead?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

function executeCommandLine(args: ReadonlyArray)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can't figure this out, I tried passing a callback but it never gets called.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

to be fixed later #68


expectedFiles.forEach(relativePath => {
const absolutePath = resolve('test/integration/project', relativePath);

// Assert
Expect(existsSync(absolutePath)).toBe(true);

// Delete file
unlink(absolutePath, (error) => {
throw error;
});
});
}

@Teardown
public teardown() {
// Delete outDir folder
removeSync('test/integration/project/outDir');
}

}
1 change: 1 addition & 0 deletions test/integration/project/nested/folder/file.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const test = true;
7 changes: 7 additions & 0 deletions test/integration/project/tsconfig.bothDirOptions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.default.json",
"compilerOptions": {
"outDir": "../project/outDir",
"rootDir": "../project/nested"
}
}
3 changes: 3 additions & 0 deletions test/integration/project/tsconfig.default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"luaTarget": "JIT"
}
6 changes: 6 additions & 0 deletions test/integration/project/tsconfig.outDir.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.default.json",
"compilerOptions": {
"outDir": "../project/outDir"
}
}
6 changes: 6 additions & 0 deletions test/integration/project/tsconfig.rootDir.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.default.json",
"compilerOptions": {
"rootDir": "../project/nested"
}
}