Skip to content

Commit aa8fede

Browse files
committed
Merge branch 'master' into source-maps
# Conflicts: # package-lock.json # src/LuaPrinter.ts # test/compiler/watchmode.spec.ts
2 parents 7c09bf2 + a200793 commit aa8fede

216 files changed

Lines changed: 14419 additions & 11006 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ charset = utf-8
88
trim_trailing_whitespace = true
99
insert_final_newline = true
1010

11-
[*.yml]
11+
[*.{yml,md}]
1212
indent_size = 2

.gitignore

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
1-
*.js
2-
node_modules/
3-
yarn.lock
4-
5-
.vscode/
1+
/node_modules
2+
/dist
3+
/coverage
64

7-
coverage/
8-
.nyc*
9-
*.js.map
5+
yarn.lock
6+
.vscode
7+
.idea
108

119
# Release
1210
*.tgz
1311

1412
# OSX
1513
.DS_Store
1614
*.lcov
17-
18-
# IDEA IDEs
19-
.idea/
20-
21-
typescript_lualib.lua
22-
lualib_bundle.lua
23-
24-
dist/*

.prettierignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/dist
2+
/coverage
3+
/test/compiler/testfiles/invalid_syntax.ts
4+
/test/translation/transformation/characterEscapeSequence.ts
5+
6+
/src
7+
*.md

.travis.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
language: node_js
22
node_js:
3-
- stable
4-
install:
5-
- npm install
3+
- stable
4+
65
script:
7-
- npm run build
8-
- npm run coverage
9-
after_success:
10-
- codecov
6+
- npm run lint
7+
- npm run build
8+
- npm test -- --coverage
9+
after_success: npx codecov
10+
1111
deploy:
1212
provider: npm
1313
email: lorenz.junglas@student.kit.edu

CONTRIBUTING.md

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,67 +14,46 @@ To get familiar with the project structure, here is a short overview of each dir
1414
* `src/targets/`
1515
- Version-specific transpiler overrides for the different Lua targets. The main transpiler transpiles Lua 5.0, each target-specific transpiler extends the transpiler of the version before it, so the 5.3 inherits 5.2 which inherits 5.1 which inherits 5.0. LuaJIT is based on 5.2 so inherits from the 5.2 transpiler.
1616
* *Compiler.ts* - Main entry point of the transpiler, this is what interfaces with the TypeScript compiler API.
17-
* *Transpiler.ts* - Main transpiler code, transforms a TypeScript AST to a Lua string.
17+
* *LuaTransformer.ts* - Main transpiler code, transforms a TypeScript AST to a Lua AST.
18+
* *LuaPrinter.ts* - Transforms a Lua AST to a string.
1819
* *TSHelper.ts* - Helper methods used during the transpilation process.
1920
- `test/`
2021
* This directory contains all testing code for the transpiler.
21-
* `test/src/`
22-
- Contains all extra source and utility used to run tests.
2322
* `test/unit/`
2423
- Unit/Functional tests for the transpiler. Tests in here are grouped by functionality they are testing. Generally each of these tests uses the transpiler to transpile some TypeScript to Lua, then executes it using the Fengari Lua VM. Assertion is done on the result of the lua code.
2524
* `test/translation/`
2625
- **[Obsolete]** Contains tests that only check the transpiled Lua String. We prefer adding unit/functional tests over translation tests. This directory will probably be removed at some point.
2726

2827
## Running Tests
29-
The tests for this project can be executed using the standard `npm test`. This runs all tests (can take a while!).
28+
The tests for this project can be executed using the standard `npm test`. This runs all tests.
3029

31-
### Testing while developing
32-
Due to the time required to run all tests, it is impractical to run every test while developing part of the transpiler. To speed up the test run you can import `FocusTest` or `FocusTests` from Alsatian. If a class is decorated with `@FocusTests`, all other test classes will be ignored. Similarly, if any test method is decorated with `@FocusTest`, only `@FocusTest` methods will be run during `npm test`.
30+
Due to the time required to run all tests, it is impractical to run every test while developing part of the transpiler. To speed up the test run you can:
3331

34-
For example:
35-
```ts
36-
import { Expect, FocusTests, Test, TestCase } from "alsatian";
32+
- Use `npm test name` to run tests that match a file name pattern
3733

38-
@FocusTests
39-
export class FunctionTests {
40-
// All tests in here will be executed.
41-
}
34+
- Use `npm test -- --watch [name]` to start tests and rerun them on change
4235

43-
// All other tests will be ignored.
44-
```
36+
- Check out `Watch Usage` in the watching interface to get information about filtering tests without restarting CLI
4537

46-
Or
38+
- Use `.only` and `.skip` to filter executed tests in the file
4739

48-
```ts
49-
import { Expect, FocusTest, Test, TestCase } from "alsatian";
50-
51-
export class FunctionTests {
52-
@FocusTest
53-
@Test("Example test 1")
54-
public test1(): void { // Will be executed
55-
}
56-
57-
@FocusTest
58-
@Test("Example test 2")
59-
public test2(): void { // Will also be executed
60-
}
61-
62-
@Test("Example test 3")
63-
public test3(): void { // Will be ignored
64-
}
65-
}
66-
67-
// All other tests will be ignored.
68-
```
40+
```ts
41+
// Skipped
42+
test("test", () => {});
6943

44+
// Executed
45+
test.only("test", () => {});
46+
```
7047

7148
## Testing Guidelines
7249
When submitting a pull request with new functionality, we require some functional (transpile and execute Lua) to be added, to ensure the new functionality works as expected, and will continue to work that way.
7350

7451
Translation tests are discouraged as in most cases as we do not really care about the exact Lua output, as long as executing it results in the correct result (which is tested by functional tests).
7552

7653
## Coding Conventions
77-
Most coding conventions are enforced by the ts-lint configuration. The test process will fail if code does not pass the linter. Some extra conventions worth mentioning:
54+
Most coding conventions are enforced by the TSLint and Prettier. You can check your code locally by running `npm run lint`. The CI build will fail if your code does not pass the linter. For better experience, you can install extensions for your code editor for [TSLint](https://palantir.github.io/tslint/usage/third-party-tools/) and [Prettier](https://prettier.io/docs/en/editors.html).
55+
56+
Some extra conventions worth mentioning:
7857
* Do not abbreviate variable names. The exception here are inline lambda arguments, if it is obvious what the argument is you can abbreviate to the first letter, e.g: `statements.filter(s => ts.VariableStatement(s))`
7958
* Readability of code is more important than the amount of space it takes. If extra line breaks make your code more readable, add them.
8059
* Functional style is encouraged!

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ install:
1111
# Get the latest stable version of Node.js or io.js
1212
- ps: Install-Product node $env:nodejs_version
1313
# install modules
14-
- npm install
14+
- npm ci
1515

1616
# Post-install test scripts.
1717
test_script:

build_lualib.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import * as fs from "fs";
22
import * as glob from "glob";
3-
import {compile} from "./src/Compiler";
4-
import {LuaLib as luaLib, LuaLibFeature} from "./src/LuaLib";
3+
import { compile } from "./src/Compiler";
4+
import { LuaLib as luaLib, LuaLibFeature } from "./src/LuaLib";
55

66
const bundlePath = "./dist/lualib/lualib_bundle.lua";
77

88
compile([
9+
"--skipLibCheck",
10+
"--types",
11+
"node",
912
"--luaLibImport",
1013
"none",
1114
"--luaTarget",

jest.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const isCI = require("is-ci");
2+
3+
/** @type {Partial<import('@jest/types').Config.DefaultOptions>} */
4+
module.exports = {
5+
testMatch: ["**/test/**/*.spec.ts"],
6+
collectCoverageFrom: ["<rootDir>/src/**/*", "!<rootDir>/src/lualib/**/*"],
7+
watchPathIgnorePatterns: ["/watch\\.ts$"],
8+
9+
testEnvironment: "node",
10+
testRunner: "jest-circus/runner",
11+
preset: "ts-jest",
12+
globals: {
13+
"ts-jest": {
14+
tsConfig: "<rootDir>/test/tsconfig.json",
15+
diagnostics: { warnOnly: !isCI },
16+
},
17+
},
18+
};

0 commit comments

Comments
 (0)