diff --git a/src/Makefile.am b/src/Makefile.am
index 16766d3..73c78e7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,6 +6,8 @@ bin_PROGRAMS = gnome-terminal
 libexec_PROGRAMS = gnome-terminal-server
 noinst_PROGRAMS =
 
+check_PROGRAMS = terminal-screen
+
 if WITH_NAUTILUS_EXTENSION
 nautilusextension_LTLIBRARIES = libterminal-nautilus.la
 endif # WITH_NAUTILUS_EXTENSION
@@ -149,6 +151,77 @@ terminal-gdbus-generated.c terminal-gdbus-generated.h: org.gnome.Terminal.xml Ma
 terminal-resources.h terminal-resources.c: terminal.gresource.xml Makefile $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir $(srcdir) $(srcdir)/terminal.gresource.xml)
 	$(AM_V_GEN) XMLLINT=$(XMLLINT) $(GLIB_COMPILE_RESOURCES) --target $@ --sourcedir $(srcdir) --generate --c-name terminal $<
 
+terminal_screen_CPPFLAGS = \
+	-DTERMINAL_COMPILATION \
+	-DTERM_LOCALEDIR="\"$(datadir)/locale\"" \
+	-DTERM_HELPDIR="\"$(HELP_DIR)\"" \
+	-DTERM_LIBEXECDIR="\"$(libexecdir)\"" \
+	$(AM_CPPFLAGS)
+terminal_screen_SOURCES = \
+	eggshell.c \
+	eggshell.h \
+	profile-editor.c \
+	profile-editor.h \
+	terminal-accels.c \
+	terminal-accels.h \
+	terminal-app.c \
+	terminal-app.h \
+	terminal-debug.c \
+	terminal-debug.h \
+	terminal-encoding.c \
+	terminal-encoding.h \
+	terminal-gdbus.c \
+	terminal-gdbus.h \
+	terminal-gdbus-generated.c \
+	terminal-gdbus-generated.h \
+	terminal-icon-button.h \
+	terminal-icon-button.c \
+	terminal-info-bar.c \
+	terminal-info-bar.h \
+	terminal-marshal.c \
+	terminal-marshal.h \
+	terminal-mdi-container.c \
+	terminal-mdi-container.h \
+	terminal-notebook.c \
+	terminal-notebook.h \
+	terminal-prefs.c \
+	terminal-prefs.h \
+	terminal-profiles-list.c \
+	terminal-profiles-list.h \
+	terminal-schemas.h \
+	terminal-settings-list.c \
+	terminal-settings-list.h \
+	terminal-screen.c \
+	terminal-screen.h \
+	terminal-screen-container.c \
+	terminal-screen-container.h \
+	terminal-search-popover.c \
+	terminal-search-popover.h \
+	terminal-search-provider.c \
+	terminal-search-provider.h \
+	terminal-search-provider-gdbus-generated.c \
+	terminal-search-provider-gdbus-generated.h \
+	terminal-tab-label.c \
+	terminal-tab-label.h \
+	terminal-tabs-menu.c \
+	terminal-tabs-menu.h \
+	terminal-type-builtins.c \
+	terminal-type-builtins.h \
+	terminal-util.c \
+	terminal-util.h \
+	terminal-window.c \
+	terminal-window.h \
+	$(NULL)
+terminal_screen_CFLAGS = \
+	-DTERMINAL_SCREEN_MAIN \
+	$(TERM_CFLAGS) \
+	$(WARN_CFLAGS) \
+	$(AM_CFLAGS)
+terminal_screen_LDFLAGS = \
+	$(AM_LDFLAGS)
+terminal_screen_LDADD = \
+	$(TERM_LIBS)
+
 # Terminal client
 
 if ENABLE_GTERMINAL
diff --git a/src/terminal-screen.c b/src/terminal-screen.c
index 84b4a87..7ed2677 100644
--- a/src/terminal-screen.c
+++ b/src/terminal-screen.c
@@ -2079,3 +2079,86 @@ terminal_screen_get_uuid (TerminalScreen *screen)
 
   return screen->priv->uuid;
 }
+
+/******************************************************************************/
+
+#ifdef TERMINAL_SCREEN_MAIN
+
+static const char* regex_checks[] = {
+  "There's no URL here http:/foo",          NULL,
+  "Visit http://example.com for details",   "http://example.com",
+  "Trailing dot http://foo/bar.",           "http://foo/bar",
+  "See <http://foo/bar>",                   "http://foo/bar",
+
+  "Write to foo@bar.com.",                  "foo@bar.com",
+  "Write to <foo@bar.com>",                 "foo@bar.com",
+  "Write to mailto:foo@bar.com.",           "mailto:foo@bar.com",
+};
+
+#ifdef WITH_PCRE2
+  XXX
+#else
+static char *
+check_regex_one (GRegex *regex,
+                 const gchar *input)
+{
+  GMatchInfo *match_info;
+  char *ret = NULL;
+
+  if (g_regex_match (regex, input, 0, &match_info))
+    {
+      ret = g_strdup (g_match_info_fetch (match_info, 0));
+    }
+  g_match_info_free (match_info);
+  return ret;
+}
+#endif
+
+static char *
+check_regex_all (
+#ifdef WITH_PCRE2
+                 VteRegex **regexes,
+#else
+                 GRegex **regexes,
+#endif
+                 int len,
+                 const gchar *input)
+{
+  int i;
+  char *ret;
+
+  for (i = 0; i < len; i++)
+    {
+      ret = check_regex_one (regexes[i], input);
+      if (ret != NULL)
+        return ret;
+    }
+  return NULL;
+}
+
+int
+main (int argc, char **argv)
+{
+  guint i;
+  const char *input, *expected_match;
+  char *match;
+
+  n_url_regexes = G_N_ELEMENTS (url_regex_patterns);
+  precompile_regexes (url_regex_patterns, n_url_regexes, &url_regexes, &url_regex_flavors);
+
+  for (i = 0; i < G_N_ELEMENTS (regex_checks); i += 2)
+    {
+      input = regex_checks[i];
+      expected_match = regex_checks[i + 1];
+      match = check_regex_all (url_regexes, n_url_regexes, input);
+
+      g_assert_cmpstr (match, ==, expected_match);
+
+      g_free (match);
+    }
+
+  printf("terminal-screen regex tests passed :)\n");
+  return 0;
+}
+
+#endif /* TERMINAL_SCREEN_MAIN */
