summaryrefslogtreecommitdiff
path: root/src/vala/unit-tests-report.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/vala/unit-tests-report.vala')
-rw-r--r--src/vala/unit-tests-report.vala98
1 files changed, 0 insertions, 98 deletions
diff --git a/src/vala/unit-tests-report.vala b/src/vala/unit-tests-report.vala
deleted file mode 100644
index 6442e48..0000000
--- a/src/vala/unit-tests-report.vala
+++ /dev/null
@@ -1,98 +0,0 @@
-[CCode (cheader_filename = "config.h")]
-extern const string UNIT_TESTS_REPORT_VALA;
-
-namespace Disfluid {
-
- class UnitTestsReport: GLib.Object {
- public string output;
- public size_t n_tests;
- public size_t n_errors;
-
- public UnitTestsReport (string output, size_t n_tests, size_t n_errors) {
- this.output = output;
- this.n_tests = n_tests;
- this.n_errors = n_errors;
- }
- }
-
- async UnitTestsReport do_run_tests_in_bg () throws GLib.ThreadError {
- GLib.SourceFunc callback = do_run_tests_in_bg.callback;
- UnitTestsReport[] output = new UnitTestsReport[1];
- ThreadFunc<bool> run = () => {
- size_t n_tests, n_errors;
- var o = Disfluid.run_tests (out n_tests, out n_errors);
- if (o == null) {
- o = _ ("The tests did not produce any output.");
- }
- output[0] = new UnitTestsReport (o, n_tests, n_errors);
- Idle.add ((owned) callback);
- return true;
- };
- new Thread<bool> ("unit-tests-thread", run);
- yield;
- return output[0];
- }
-
- [GtkTemplate (ui = "/eu/planete_kraus/Disfluid/src/unit_tests_report.ui")]
- public class UnitTestsReportDialog: Adw.ApplicationWindow {
-
- [GtkChild]
- private unowned Gtk.Stack stack;
-
- [GtkChild]
- private unowned Adw.StatusPage page_wait;
-
- [GtkChild]
- private unowned Adw.StatusPage page_success;
-
- [GtkChild]
- private unowned Adw.StatusPage page_failure;
-
- [GtkChild]
- private unowned Gtk.TextView debug_info;
-
- [GtkChild]
- private unowned Gtk.LinkButton report_button;
-
- public signal void new_debug_info (string debug_info);
-
- public void start () {
- this.stack.visible_child = this.page_wait;
- do_run_tests_in_bg.begin ((obj, res) => {
- try {
- var results = do_run_tests_in_bg.end (res);
- if (results.n_errors == 0) {
- this.stack.visible_child = this.page_success;
- }
- else {
- this.stack.visible_child = this.page_failure;
- this.debug_info.buffer.text = results.output;
- // Do not translate the subject
- var subject = "[Disfluid unit tests failure] " + _ ("*** Your subject line here, in English ***") ;
- var body = _ ("*** Please give as much information as possible, in English, as best as you can. Following your message is the debug information, check if there is no sensitive personal information. ***") + "\n\n" + results.output;
- var query = "subject=" + GLib.Uri.escape_string (subject) + "&body=" + GLib.Uri.escape_string (body);
- this.report_button.uri = "mailto:vivien@planete-kraus.eu?" + query;
- this.new_debug_info (results.output);
- }
- }
- catch (ThreadError e) {
- this.stack.visible_child = this.page_failure;
- }
- });
- }
-
- public UnitTestsReportDialog (Gtk.Application app) {
- this.application = app;
- var s = new Gtk.Spinner ();
- s.spinning = true;
- var spinner = new Gtk.WidgetPaintable (s);
- this.page_wait.paintable = spinner;
- this.start ();
- GLib.SimpleAction rerun = new GLib.SimpleAction ("rerun-unit-tests", null);
- rerun.activate.connect (() => {
- this.start ();
- });
- this.add_action (rerun);
- }
- }
-}