-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSmokeTestRunner.cs
More file actions
47 lines (42 loc) · 1.41 KB
/
Copy pathSmokeTestRunner.cs
File metadata and controls
47 lines (42 loc) · 1.41 KB
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
using UnityEngine;
using Magic.Unity;
// Attach this script to any GameObject in a scene. It renders via IMGUI,
// so no Canvas / EventSystem / Text wiring is needed. On Start it requires
// the smoke.runner Clojure namespace and invokes its `all-pass?` and
// `report-text` vars. The whole report is also written to Player.log.
public class SmokeTestRunner : MonoBehaviour
{
string _report = "(starting...)";
bool _ok;
void Start()
{
try
{
Clojure.Require("smoke.runner");
var okVar = Clojure.GetVar("smoke.runner", "all-pass?");
var textVar = Clojure.GetVar("smoke.runner", "report-text");
_ok = (bool)okVar.invoke();
_report = (string)textVar.invoke();
}
catch (System.Exception e)
{
_ok = false;
_report = "Bootstrap failure (Clojure runtime did not initialise):\n\n" + e;
}
if (_ok) Debug.Log(_report);
else Debug.LogError(_report);
}
void OnGUI()
{
var style = new GUIStyle(GUI.skin.label)
{
fontSize = 18,
wordWrap = true,
richText = false,
};
style.normal.textColor = _ok ? Color.green : new Color(1f, 0.4f, 0.4f);
const int pad = 16;
GUI.Label(new Rect(pad, pad, Screen.width - 2 * pad, Screen.height - 2 * pad),
_report, style);
}
}