Skip to content

Add compiler tests#67

Merged
lolleko merged 3 commits intoTypeScriptToLua:masterfrom
zapp-brannigan-dota:compiler-tests
Mar 13, 2018
Merged

Add compiler tests#67
lolleko merged 3 commits intoTypeScriptToLua:masterfrom
zapp-brannigan-dota:compiler-tests

Conversation

@zapp-brannigan-dota
Copy link
Copy Markdown
Contributor

Please also enable AppVeyor for Windows testing.

Copy link
Copy Markdown
Member

@Perryvw Perryvw left a comment

Choose a reason for hiding this comment

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

Nice changes.

"noImplicitAny" : true,
"noImplicitThis" : true,
"alwaysStrict" : true,
"strictNullChecks": true,
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.

Strict flags (and others) are tsc flags and should not be tested by our compiler.

"noImplicitThis" : true,
"alwaysStrict" : true,
"strictNullChecks": true,
"luaTarget": "JIT"
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.

luatarget ist not a compilerOption and needs to be declared in the root of the config.json.

// Delete outDir folder
removeSync('test/integration/project/outDir');
}

Copy link
Copy Markdown
Member

@lolleko lolleko Mar 13, 2018

Choose a reason for hiding this comment

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

Not sure that checking if a file exist is the best way to test the compiler.

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.

These tests are about outDir and rootDir and I think those are appropriately tested with that. But I'd be happy to implement something else if you tell me what you think it should be 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.

Right makes sense. Might want to rename the test.
I was thinking about checking if paths are resolved correctly directly, but this is hard to test since all the resolve stuff is packed into parseCommandLine() and compile() which makes it hard to test directly. So checking if a file exists is probably the best way right now. I might revisit this when I rewrite the CLI interface.

});

// Delete outDir folder
removeSync('test/integration/project/outDir');
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.

please use a function with @teardown for cleanup https://github.com/alsatian-test/alsatian/wiki/pre-and-post-test.

@@ -0,0 +1,36 @@
import { Expect, Test, TestCase } from "alsatian";
import { execSync } from "child_process"
import { existsSync, removeSync, unlink } from "fs-extra"
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.

Why do you need fs-extra all those functions exist in default fs.

Copy link
Copy Markdown
Contributor Author

@zapp-brannigan-dota zapp-brannigan-dota Mar 13, 2018

Choose a reason for hiding this comment

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

fs-extra can delete non empty directories.

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.

RIP thought default node could do that by now.

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

@lolleko lolleko merged commit 715cdb7 into TypeScriptToLua:master Mar 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants