Skip to content

Commit

Permalink
Merge pull request #275 from danger/windows-ci
Browse files Browse the repository at this point in the history
Check windows support on CI
  • Loading branch information
orta committed Jun 9, 2017
2 parents 26d9501 + ef285c7 commit ede5a12
Showing 1 changed file with 86 additions and 88 deletions.
174 changes: 86 additions & 88 deletions source/runner/_tests/_danger_runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,113 +37,111 @@ async function setupDangerfileContext() {
return contextForDanger(dsl)
}

if (process.platform !== "win32") {
describe("with fixtures", () => {
it("handles a blank Dangerfile", async () => {
const context = await setupDangerfileContext()
const runtime = await createDangerfileRuntimeEnvironment(context)
const results = await runDangerfileEnvironment(resolve(fixtures, "__DangerfileEmpty.js"), runtime)

expect(results).toEqual({
fails: [],
markdowns: [],
messages: [],
warnings: []
})
describe("with fixtures", () => {
it("handles a blank Dangerfile", async () => {
const context = await setupDangerfileContext()
const runtime = await createDangerfileRuntimeEnvironment(context)
const results = await runDangerfileEnvironment(resolve(fixtures, "__DangerfileEmpty.js"), runtime)

expect(results).toEqual({
fails: [],
markdowns: [],
messages: [],
warnings: []
})
})

it("handles a full set of messages", async () => {
const context = await setupDangerfileContext()
const runtime = await createDangerfileRuntimeEnvironment(context)
const results = await runDangerfileEnvironment(resolve(fixtures, "__DangerfileFullMessages.js"), runtime)

expect(results).toEqual({
fails: [{"message": "this is a failure"}],
markdowns: ["this is a *markdown*"],
messages: [{"message": "this is a message"}],
warnings: [{"message": "this is a warning"}]
})
it("handles a full set of messages", async () => {
const context = await setupDangerfileContext()
const runtime = await createDangerfileRuntimeEnvironment(context)
const results = await runDangerfileEnvironment(resolve(fixtures, "__DangerfileFullMessages.js"), runtime)

expect(results).toEqual({
fails: [{"message": "this is a failure"}],
markdowns: ["this is a *markdown*"],
messages: [{"message": "this is a message"}],
warnings: [{"message": "this is a warning"}]
})
})

it("handles a failing dangerfile", async () => {
const context = await setupDangerfileContext()
const runtime = await createDangerfileRuntimeEnvironment(context)
it("handles a failing dangerfile", async () => {
const context = await setupDangerfileContext()
const runtime = await createDangerfileRuntimeEnvironment(context)

try {
await runDangerfileEnvironment(resolve(fixtures, "__DangerfileBadSyntax.js"), runtime)
throw new Error("Do not get to this")
}
catch (e) {
// expect(e.message === ("Do not get to this")).toBeFalsy()
expect(e.message).toEqual("hello is not defined")
}
})
try {
await runDangerfileEnvironment(resolve(fixtures, "__DangerfileBadSyntax.js"), runtime)
throw new Error("Do not get to this")
}
catch (e) {
// expect(e.message === ("Do not get to this")).toBeFalsy()
expect(e.message).toEqual("hello is not defined")
}
})

it("handles relative imports correctly", async () => {
const context = await setupDangerfileContext()
const runtime = await createDangerfileRuntimeEnvironment(context)
await runDangerfileEnvironment(resolve(fixtures, "__DangerfileImportRelative.js"), runtime)
})
it("handles relative imports correctly", async () => {
const context = await setupDangerfileContext()
const runtime = await createDangerfileRuntimeEnvironment(context)
await runDangerfileEnvironment(resolve(fixtures, "__DangerfileImportRelative.js"), runtime)
})

it("handles scheduled (async) code", async () => {
const context = await setupDangerfileContext()
const runtime = await createDangerfileRuntimeEnvironment(context)
const results = await runDangerfileEnvironment(resolve(fixtures, "__DangerfileScheduled.js"), runtime)
expect(results).toEqual({
fails: [],
messages: [],
markdowns: [],
warnings: [{ message: "Asynchronous Warning" }],
})
it("handles scheduled (async) code", async () => {
const context = await setupDangerfileContext()
const runtime = await createDangerfileRuntimeEnvironment(context)
const results = await runDangerfileEnvironment(resolve(fixtures, "__DangerfileScheduled.js"), runtime)
expect(results).toEqual({
fails: [],
messages: [],
markdowns: [],
warnings: [{ message: "Asynchronous Warning" }],
})
})

it("handles multiple scheduled statements and all message types", async () => {
const context = await setupDangerfileContext()
const runtime = await createDangerfileRuntimeEnvironment(context)
const results = await runDangerfileEnvironment(resolve(fixtures, "__DangerfileMultiScheduled.js"), runtime)
expect(results).toEqual({
fails: [{ message: "Asynchronous Failure" }],
messages: [{ message: "Asynchronous Message" }],
markdowns: ["Asynchronous Markdown"],
warnings: [{ message: "Asynchronous Warning" }],
})
it("handles multiple scheduled statements and all message types", async () => {
const context = await setupDangerfileContext()
const runtime = await createDangerfileRuntimeEnvironment(context)
const results = await runDangerfileEnvironment(resolve(fixtures, "__DangerfileMultiScheduled.js"), runtime)
expect(results).toEqual({
fails: [{ message: "Asynchronous Failure" }],
messages: [{ message: "Asynchronous Message" }],
markdowns: ["Asynchronous Markdown"],
warnings: [{ message: "Asynchronous Warning" }],
})
})

// This adds > 6 seconds to the tests! Only orta should be forced into that.
if (process.env["USER"] === "orta") {
it("can execute async/await scheduled functions", async () => {
// this test takes *forever* because of babel-polyfill being required
const context = await setupDangerfileContext()
const runtime = await createDangerfileRuntimeEnvironment(context)
const results = await runDangerfileEnvironment(resolve(fixtures, "__DangerfileAsync.js"), runtime)
expect(results.warnings).toEqual([{
message: "Async Function"
}, {
message: "After Async Function"
}])
})
}

it("can schedule callback-based promised", async () => {
// This adds > 6 seconds to the tests! Only orta should be forced into that.
if (process.env["USER"] === "orta") {
it("can execute async/await scheduled functions", async () => {
// this test takes *forever* because of babel-polyfill being required
const context = await setupDangerfileContext()
const runtime = await createDangerfileRuntimeEnvironment(context)
const results = await runDangerfileEnvironment(resolve(fixtures, "__DangerfileCallback.js"), runtime)
const results = await runDangerfileEnvironment(resolve(fixtures, "__DangerfileAsync.js"), runtime)
expect(results.warnings).toEqual([{
message: "Scheduled a callback",
message: "Async Function"
}, {
message: "After Async Function"
}])
})
}

it("can handle TypeScript based Dangerfiles", async () => {
const context = await setupDangerfileContext()
const runtime = await createDangerfileRuntimeEnvironment(context)
const results = await runDangerfileEnvironment(resolve(fixtures, "__DangerfileTypeScript.ts"), runtime)
expect(results.messages).toEqual([{
message: "Honey, we got Types",
}])
})
it("can schedule callback-based promised", async () => {
const context = await setupDangerfileContext()
const runtime = await createDangerfileRuntimeEnvironment(context)
const results = await runDangerfileEnvironment(resolve(fixtures, "__DangerfileCallback.js"), runtime)
expect(results.warnings).toEqual([{
message: "Scheduled a callback",
}])
})

it("can handle TypeScript based Dangerfiles", async () => {
const context = await setupDangerfileContext()
const runtime = await createDangerfileRuntimeEnvironment(context)
const results = await runDangerfileEnvironment(resolve(fixtures, "__DangerfileTypeScript.ts"), runtime)
expect(results.messages).toEqual([{
message: "Honey, we got Types",
}])
})
}

})

describe("cleaning Dangerfiles", () => {
it("Supports removing the danger import", () => {
Expand Down

0 comments on commit ede5a12

Please sign in to comment.