aboutsummaryrefslogtreecommitdiff
path: root/core/testing/events.odin
blob: 1a47e2d6822a07e01ff143fa89127dfec90e0389 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#+private
package testing

/*
	(c) Copyright 2024 Feoramund <rune@swevencraft.org>.
	Made available under Odin's BSD-3 license.

	List of contributors:
		Feoramund:   Total rewrite.
*/

import "base:runtime"
import "core:sync/chan"
import "core:time"

Test_State :: enum {
	Ready,
	Running,
	Successful,
	Failed,
}

Update_Channel :: chan.Chan(Channel_Event)
Update_Channel_Sender :: chan.Chan(Channel_Event, .Send)

Task_Channel :: struct {
	channel: Update_Channel,
	test_index: int,
}

Event_New_Test :: struct {
	test_index: int,
}

Event_State_Change :: struct {
	new_state: Test_State,
}

Event_Set_Fail_Timeout :: struct {
	at_time: time.Time,
	location: runtime.Source_Code_Location,
}

Event_Log_Message :: struct {
	level: runtime.Logger_Level,
	text: string,
	time: time.Time,
	formatted_text: string,
}

Channel_Event :: union {
	Event_New_Test,
	Event_State_Change,
	Event_Set_Fail_Timeout,
	Event_Log_Message,
}