Skip to content

Commit 3103c0d

Browse files
committed
Gulp Tests & InstanceOf
1 parent 0a9b905 commit 3103c0d

File tree

8 files changed

+746
-42
lines changed

8 files changed

+746
-42
lines changed

gulpfile.ts

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,78 @@
1-
import * as concat from "gulp-concat";
1+
import { TestRunner, TestSet } from "alsatian";
2+
import * as del from "del";
23
import * as glob from "glob";
34
import * as gulp from "gulp";
5+
import * as concat from "gulp-concat";
6+
import * as istanbul from "gulp-istanbul";
7+
import tslint from "gulp-tslint";
48
import * as ts from "gulp-typescript";
9+
import { TapBark } from "tap-bark";
510

611
import {parseCommandLine} from "./src/CommandLineParser";
712
import {compile, compileFilesWithOptions} from "./src/Compiler";
813

9-
gulp.task("default", () => {
10-
const tsProject = ts.createProject("tsconfig.json");
11-
return tsProject.src().pipe(tsProject()).js.pipe(gulp.dest("dist"));
14+
// BUILD
15+
16+
gulp.task("build", () => {
17+
const tsProject = ts.createProject("tsconfig.json");
18+
return tsProject.src().pipe(tsProject()).js.pipe(gulp.dest("dist"));
19+
});
20+
21+
gulp.task("lualib", () => {
22+
compile([
23+
"-ah",
24+
"--dontRequireLuaLib",
25+
"-lt",
26+
"5.1",
27+
"--outDir",
28+
"./dist/lualib",
29+
"--rootDir",
30+
"./src/lualib",
31+
...glob.sync("./src/lualib/*.ts"),
32+
]);
33+
34+
return gulp.src("./dist/lualib/*.lua")
35+
.pipe(concat("typescript_lualib_bundle.lua"))
36+
.pipe(gulp.dest("./dist/lualib"));
37+
});
38+
39+
gulp.task("default", gulp.series("build", "lualib"));
40+
41+
// TESTS
42+
43+
gulp.task(
44+
"tslint",
45+
() => gulp.src("src/**/*.ts").pipe(tslint()).pipe(tslint.report()));
46+
47+
gulp.task("clean-test", () => del("./test/**/*.spec.js"));
48+
49+
gulp.task("build-test", () => {
50+
const tsProject = ts.createProject("./test/tsconfig.json");
51+
return tsProject.src().pipe(tsProject()).js.pipe(gulp.dest("./test"));
1252
});
1353

14-
gulp.task("lualib", done => {
15-
compile(["-ah", "--dontRequireLuaLib", "-lt", "5.1", "--outDir", "./dist/lualib", "--rootDir", "./src/lualib", ...glob.sync("./src/lualib/*.ts")]);
54+
gulp.task("pre-test", () =>
55+
gulp.src(["src/**/*.js"])
56+
.pipe(istanbul())
57+
.pipe(istanbul.hookRequire())
58+
);
59+
60+
gulp.task("unit-tests", (done: () => any) => {
61+
const testSet = TestSet.create();
62+
63+
testSet.addTestsFromFiles("./test/**/*.spec.js");
64+
65+
const testRunner = new TestRunner();
66+
67+
testRunner.outputStream
68+
.pipe(TapBark.create().getPipeable())
69+
.pipe(process.stdout);
70+
71+
testRunner.run(testSet)
72+
.then(() => {
73+
istanbul.writeReports();
74+
done();
75+
});
76+
});
1677

17-
return gulp.src("./dist/lualib/*.lua").pipe(concat("typescript_lualib_bundle.lua")).pipe(gulp.dest("./dist/lualib"));
18-
});
78+
gulp.task("test", gulp.series("tslint", "clean-test", "build-test", "lualib", "pre-test", "unit-tests", "clean-test"));

0 commit comments

Comments
 (0)