extends SceneTree ## 0.6.0, the playtest: Report a bug. The pause menu has a "Report a bug" ## page; its link is a new issue on the Emberwild repo, filled in with ## questions to answer and the details (version, computer, mode, land, time, ## where you are), short enough for a browser; the log's path is shown. ## Run: godot --headless --path . --script res://tests/test_bug_report.gd const BugReport = preload("res://scripts/core/bug_report.gd") var _fails := 0 var _finished := false var S: Node func check(cond: bool, what: String) -> void: print((" ok " if cond else " FAIL ") + what) if not cond: _fails += 1 func _initialize() -> void: _run.call_deferred() func _run() -> void: S = root.get_node("Saves") S.root_dir = "user://test_bug_worlds" for x in S.list_worlds(): S.delete_world(x.id) await _body() check(_finished, "test ran to the end (no script errors)") for x in S.list_worlds(): S.delete_world(x.id) DirAccess.remove_absolute(S.root_dir) print("RESULT: %s (%d failures)" % ["PASS" if _fails == 0 else "FAIL", _fails]) quit(1 if _fails > 0 else 0) func _body() -> void: S.current_id = S.create_world("Cove", 1337, {"worldlet": "cove"}) var w: Node3D = load("res://scenes/world.tscn").instantiate() root.add_child(w) for _i in range(8): await physics_frame w.creatures.enabled = false w.player.set_physics_process(false) print("the link") var url: String = BugReport.issue_url(w) check(url.begins_with("https://git.psbailey.uk/Admin/Emberwild/issues/new?title=Bug%3A%20&body="), "a new issue on the Emberwild repo") check(url.length() < 4000, "short enough for any browser (%d characters)" % url.length()) var body := url.get_slice("&body=", 1).uri_decode() var ver: String = String(ProjectSettings.get_setting("application/config/version")) for want in ["**What happened?**", "**How can we make it happen again?**", "- Version: Emberwild %s" % ver, "- Computer: ", "- Mode: single-player", "- Land: Cove", "- Time: day ", "- Where: ", "- Seed: 1337", "godot.log"]: check(body.contains(want), "it says %s" % want) check(BugReport.log_path().ends_with("logs/godot.log") and BugReport.log_path().begins_with("/"), "the log's full path (%s)" % BugReport.log_path()) check(not BugReport.details_text(w).contains("**"), "Copy gives just the details") check(not body.contains(OS.get_environment("HOME")) and body.contains("~/"), "and not your user name (the home folder is ~)") print("the pause menu") var menu: Control = load("res://scripts/ui/pause_menu.gd").new() # (headless there's no HUD: build the menu as it does) w.add_child(menu) menu.bind(w.player) var btn: Button = null for c in menu._main.get_children(): if c is Button and c.text == "Report a bug": btn = c check(btn != null, "a Report a bug button") if btn != null: menu.open() btn.pressed.emit() check(menu._report.visible and not menu._main.visible, "it opens the Report a bug page") var labels: Array = menu._report.get_children().filter(func(c): return c is Button).map(func(c): return c.text) check("Open the bug report page" in labels and "Copy the details" in labels and "Show the log file" in labels, "with %s" % [labels]) menu.back() check(menu._main.visible and not menu._report.visible, "Esc goes back") menu.close() menu.queue_free() _finished = true