Mercurial > irccd
diff tests/test-jsapi-directory.c @ 1037:8f8ce47aba8a
make: switch to GNU make
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 27 Apr 2021 09:22:16 +0200 |
parents | 6da542806ed3 |
children | f06e9761cc90 |
line wrap: on
line diff
--- a/tests/test-jsapi-directory.c Mon Apr 12 11:16:18 2021 +0200 +++ b/tests/test-jsapi-directory.c Tue Apr 27 09:22:16 2021 +0200 @@ -32,14 +32,11 @@ { (void)udata; - plugin = js_plugin_open("example", SOURCE "/data/example-plugin.js"); + plugin = js_plugin_open("example", TOP "/tests/data/example-plugin.js"); ctx = js_plugin_get_context(plugin); - duk_push_string(ctx, SOURCE); - duk_put_global_string(ctx, "SOURCE"); - - duk_push_string(ctx, BINARY); - duk_put_global_string(ctx, "BINARY"); + duk_push_string(ctx, TOP); + duk_put_global_string(ctx, "TOP"); } static void @@ -47,6 +44,9 @@ { (void)udata; + remove(TOP "/tests/1/2"); + remove(TOP "/tests/1"); + irc_plugin_finish(plugin); plugin = NULL; @@ -57,7 +57,7 @@ object_constructor(void) { const char *script = - "d = new Irccd.Directory(SOURCE + '/data/root');" + "d = new Irccd.Directory(TOP + '/tests/data/root');" "p = d.path;" "l = d.entries.length;"; @@ -75,7 +75,7 @@ GREATEST_TEST object_find(void) { - const char *script = "d = new Irccd.Directory(SOURCE + '/data/root');"; + const char *script = "d = new Irccd.Directory(TOP + '/tests/data/root');"; if (duk_peval_string(ctx, script) != 0) GREATEST_FAIL(); @@ -85,7 +85,7 @@ GREATEST_FAIL(); duk_get_global_string(ctx, "p"); - GREATEST_ASSERT_STR_EQ(SOURCE "/data/root/lines.txt", duk_get_string(ctx, -1)); + GREATEST_ASSERT_STR_EQ(TOP "/tests/data/root/lines.txt", duk_get_string(ctx, -1)); /* Find "unknown.txt" not recursively (not found). */ if (duk_peval_string(ctx, "p = d.find('unknown.txt');") != 0) @@ -106,7 +106,7 @@ GREATEST_FAIL(); duk_get_global_string(ctx, "p"); - GREATEST_ASSERT_STR_EQ(SOURCE "/data/root/level-1/level-2/file-2.txt", duk_get_string(ctx, -1)); + GREATEST_ASSERT_STR_EQ(TOP "/tests/data/root/level-1/level-2/file-2.txt", duk_get_string(ctx, -1)); GREATEST_PASS(); } @@ -117,28 +117,28 @@ struct stat st; /* First create an empty directory. */ - mkdir(BINARY "/empty", 0700); + mkdir(TOP "/tests/empty", 0700); - if (duk_peval_string(ctx, "d = new Irccd.Directory(BINARY + '/empty')") != 0) + if (duk_peval_string(ctx, "d = new Irccd.Directory(TOP + '/tests/empty')") != 0) GREATEST_FAIL(); /* Not recursive. */ if (duk_peval_string(ctx, "d.remove()") != 0) GREATEST_FAIL(); - GREATEST_ASSERT_EQ(-1, stat(BINARY "/empty", &st)); + GREATEST_ASSERT_EQ(-1, stat(TOP "/tests/empty", &st)); - mkdir(BINARY "/notempty", 0700); - mkdir(BINARY "/notempty/empty", 0700); + mkdir(TOP "/tests/notempty", 0700); + mkdir(TOP "/tests/notempty/empty", 0700); - if (duk_peval_string(ctx, "d = new Irccd.Directory(BINARY + '/notempty')") != 0) + if (duk_peval_string(ctx, "d = new Irccd.Directory(TOP + '/tests/notempty')") != 0) GREATEST_FAIL(); /* Not recursive. */ if (duk_peval_string(ctx, "d.remove(true)") != 0) GREATEST_FAIL(); - GREATEST_ASSERT_EQ(-1, stat(BINARY "/notempty", &st)); + GREATEST_ASSERT_EQ(-1, stat(TOP "/tests/notempty", &st)); GREATEST_PASS(); } @@ -156,34 +156,34 @@ free_find(void) { /* Find "lines.txt" not recursively. */ - if (duk_peval_string(ctx, "p = Irccd.Directory.find(SOURCE + '/data/root', 'lines.txt');") != 0) { + if (duk_peval_string(ctx, "p = Irccd.Directory.find(TOP + '/tests/data/root', 'lines.txt');") != 0) { puts(duk_to_string(ctx, -1)); GREATEST_FAIL(); } duk_get_global_string(ctx, "p"); - GREATEST_ASSERT_STR_EQ(SOURCE "/data/root/lines.txt", duk_get_string(ctx, -1)); + GREATEST_ASSERT_STR_EQ(TOP "/tests/data/root/lines.txt", duk_get_string(ctx, -1)); /* Find "unknown.txt" not recursively (not found). */ - if (duk_peval_string(ctx, "p = Irccd.Directory.find(SOURCE + '/data/root', 'unknown.txt');") != 0) + if (duk_peval_string(ctx, "p = Irccd.Directory.find(TOP + '/tests/data/root', 'unknown.txt');") != 0) GREATEST_FAIL(); duk_get_global_string(ctx, "p"); GREATEST_ASSERT(duk_is_null(ctx, -1)); /* Find "file-2.txt" not recursively (exists but in sub directory). */ - if (duk_peval_string(ctx, "p = Irccd.Directory.find(SOURCE + '/data/root', 'file-2.txt');") != 0) + if (duk_peval_string(ctx, "p = Irccd.Directory.find(TOP + '/tests/data/root', 'file-2.txt');") != 0) GREATEST_FAIL(); duk_get_global_string(ctx, "p"); GREATEST_ASSERT(duk_is_null(ctx, -1)); /* Find "file-2.txt" recursively. */ - if (duk_peval_string(ctx, "p = Irccd.Directory.find(SOURCE + '/data/root', 'file-2.txt', true);") != 0) + if (duk_peval_string(ctx, "p = Irccd.Directory.find(TOP + '/tests/data/root', 'file-2.txt', true);") != 0) GREATEST_FAIL(); duk_get_global_string(ctx, "p"); - GREATEST_ASSERT_STR_EQ(SOURCE "/data/root/level-1/level-2/file-2.txt", duk_get_string(ctx, -1)); + GREATEST_ASSERT_STR_EQ(TOP "/tests/data/root/level-1/level-2/file-2.txt", duk_get_string(ctx, -1)); GREATEST_PASS(); } @@ -194,24 +194,24 @@ struct stat st; /* First create an empty directory. */ - mkdir(BINARY "/empty", 0700); + mkdir(TOP "/tests/empty", 0700); /* Not recursive. */ - if (duk_peval_string(ctx, "Irccd.Directory.remove(BINARY + '/empty')") != 0) { + if (duk_peval_string(ctx, "Irccd.Directory.remove(TOP + '/tests/empty')") != 0) { puts(duk_to_string(ctx, -1)); GREATEST_FAIL(); } - GREATEST_ASSERT_EQ(-1, stat(BINARY "/empty", &st)); + GREATEST_ASSERT_EQ(-1, stat(TOP "/tests/empty", &st)); - mkdir(BINARY "/notempty", 0700); - mkdir(BINARY "/notempty/empty", 0700); + mkdir(TOP "/tests/notempty", 0700); + mkdir(TOP "/tests/notempty/empty", 0700); /* Not recursive. */ - if (duk_peval_string(ctx, "Irccd.Directory.remove(BINARY + '/notempty', true)") != 0) + if (duk_peval_string(ctx, "Irccd.Directory.remove(TOP + '/tests/notempty', true)") != 0) GREATEST_FAIL(); - GREATEST_ASSERT_EQ(-1, stat(BINARY "/notempty", &st)); + GREATEST_ASSERT_EQ(-1, stat(TOP "/tests/notempty", &st)); GREATEST_PASS(); } @@ -221,15 +221,15 @@ { struct stat st; - remove(BINARY "/1/2"); - remove(BINARY "/1"); + remove(TOP "/tests/1/2"); + remove(TOP "/tests/1"); - if (duk_peval_string(ctx, "Irccd.Directory.mkdir(BINARY + '/1/2')") != 0) { + if (duk_peval_string(ctx, "Irccd.Directory.mkdir(TOP + '/tests/1/2')") != 0) { puts(duk_to_string(ctx, -1)); GREATEST_FAIL(); } - GREATEST_ASSERT_EQ(0, stat(BINARY "/1/2", &st)); + GREATEST_ASSERT_EQ(0, stat(TOP "/tests/1/2", &st)); GREATEST_PASS(); }