Introduce unit tests for automated testing

The first one is a test for sokoke_magic_uri and
it already helped improving the function.
This commit is contained in:
Christian Dywan 2008-11-14 02:46:23 +01:00
parent 0b16997f1a
commit 7863d0f7fd
2 changed files with 24 additions and 3 deletions

View file

@ -88,9 +88,9 @@ sokoke_magic_uri (const gchar* uri,
{
gchar* current_dir;
gchar* result;
gchar** parts;
gchar* search;
const gchar* search_uri;
gchar** parts;
KatzeItem* item;
g_return_val_if_fail (uri, NULL);
@ -114,8 +114,17 @@ sokoke_magic_uri (const gchar* uri,
if (!strstr (uri, "://"))
{
/* Do we have a domain, ip address or localhost? */
if (strchr (uri, '.') != NULL || strchr (uri, ':')
|| !strcmp (uri, "localhost"))
parts = g_strsplit (uri, ".", 0);
if (parts[0] && parts[1])
{
search = NULL;
if (!(parts[1][1] == '\0' && !g_ascii_isalpha (parts[1][0])))
search = g_strconcat ("http://", uri, NULL);
g_free (parts);
if (search)
return search;
}
if (strchr (uri, ':') || !strcmp (uri, "localhost"))
return g_strconcat ("http://", uri, NULL);
/* We don't want to search? So return early. */
if (!search_engines)

12
wscript
View file

@ -7,6 +7,7 @@ import pproc as subprocess
import Common
import sys
import os
import UnitTest
APPNAME = 'midori'
VERSION = '0.1.0'
@ -224,6 +225,9 @@ def build (bld):
else:
Params.pprint ('BLUE', "logo-shade could not be rasterized.")
if Params.g_commands['check']:
bld.add_subdirs ('tests')
def shutdown ():
if Params.g_commands['install'] or Params.g_commands['uninstall']:
dir = Common.path_install ('DATADIR', 'icons/hicolor')
@ -242,6 +246,14 @@ def shutdown ():
Params.pprint ('YELLOW', "Icon cache not updated. After install, run this:")
Params.pprint ('YELLOW', "gtk-update-icon-cache -q -f -t %s" % dir)
elif Params.g_commands['check']:
test = UnitTest.unit_test ()
test.change_to_testfile_dir = True
test.want_to_see_test_output = True
test.want_to_see_test_error = True
test.run ()
test.print_results ()
elif Params.g_options.update_po:
os.chdir('./po')
try: