run coroutine tests only in Debug mode

LLVM 5.0.1, 6.0.0, and trunk crash when attempting to optimize coroutine code.
So, Zig does not support ReleaseFast or ReleaseSafe for coroutines yet.
Luckily, Clang users are running into the same crashes, so folks from the LLVM
community are working on fixes. If we're really lucky they'll be fixed in 6.0.1.
Otherwise we can hope for 7.0.0.
This commit is contained in:
Andrew Kelley 2018-02-28 18:56:26 -05:00
parent 58dc2b719c
commit 36eadb569a
2 changed files with 15 additions and 3 deletions

View File

@ -1,3 +1,5 @@
const builtin = @import("builtin");
comptime {
_ = @import("cases/align.zig");
_ = @import("cases/alignof.zig");
@ -11,7 +13,6 @@ comptime {
_ = @import("cases/bugs/656.zig");
_ = @import("cases/cast.zig");
_ = @import("cases/const_slice_child.zig");
_ = @import("cases/coroutines.zig");
_ = @import("cases/defer.zig");
_ = @import("cases/enum.zig");
_ = @import("cases/enum_with_members.zig");
@ -48,4 +49,15 @@ comptime {
_ = @import("cases/var_args.zig");
_ = @import("cases/void.zig");
_ = @import("cases/while.zig");
// LLVM 5.0.1, 6.0.0, and trunk crash when attempting to optimize coroutine code.
// So, Zig does not support ReleaseFast or ReleaseSafe for coroutines yet.
// Luckily, Clang users are running into the same crashes, so folks from the LLVM
// community are working on fixes. If we're really lucky they'll be fixed in 6.0.1.
// Otherwise we can hope for 7.0.0.
if (builtin.mode == builtin.Mode.Debug) {
_ = @import("cases/coroutines.zig");
}
}

View File

@ -4,12 +4,12 @@ const assert = std.debug.assert;
var x: i32 = 1;
test "create a coroutine and cancel it" {
const p = try (async(std.debug.global_allocator) emptyAsyncFn());
const p = try (async(std.debug.global_allocator) simpleAsyncFn());
cancel p;
assert(x == 2);
}
async fn emptyAsyncFn() void {
async fn simpleAsyncFn() void {
x += 1;
suspend;
x += 1;