Skip to content
Snippets Groups Projects
Commit e83f2e46 authored by Stephan Bosch's avatar Stephan Bosch
Browse files

Testsuite: added circular include tests.

parent a78fd5bb
No related branches found
No related tags found
No related merge requests found
Showing
with 101 additions and 15 deletions
......@@ -60,25 +60,22 @@ const char *ext_include_get_script_directory
if (sieve_dir == NULL)
sieve_dir = getenv("HOME");
if (sieve_dir == NULL) {
sieve_sys_error("include: sieve_dir and home not set "
"(wanted script %s)", str_sanitize(script_name, 80));
return NULL;
}
break;
case EXT_INCLUDE_LOCATION_GLOBAL:
sieve_dir = getenv("SIEVE_GLOBAL_DIR");
if (sieve_dir == NULL) {
sieve_sys_warning("include: sieve_global_dir not set "
"(wanted script %s)", str_sanitize(script_name, 80));
return NULL;
}
break;
default:
return NULL;
}
if (sieve_dir == NULL) {
sieve_sys_error("include: sieve_dir and home not set "
"(wanted script %s)", str_sanitize(script_name, 80));
return NULL;
}
printf("SIEVE DIR: %s\n", sieve_dir);
return sieve_dir;
}
......
......@@ -4,6 +4,7 @@
#include "ostream.h"
#include "hash.h"
#include "mail-storage.h"
#include "env-util.h"
#include "mail-raw.h"
#include "namespaces.h"
......@@ -301,6 +302,8 @@ static void _testsuite_script_verror
msg.location = p_strdup(pool, location);
msg.message = p_strdup_vprintf(pool, fmt, args);
// printf("error: %s: %s.\n", location, t_strdup_vprintf(fmt, args));
array_append(&_testsuite_script_errors, &msg, 1);
}
......@@ -370,9 +373,21 @@ static void testsuite_script_init(void)
bool testsuite_script_compile(const char *script_path)
{
struct sieve_binary *sbin;
const char *sieve_dir;
testsuite_script_clear_messages();
/* Initialize environment */
sieve_dir = strrchr(script_path, '/');
if ( sieve_dir == NULL )
sieve_dir= "./";
else
sieve_dir = t_strdup_until(script_path, sieve_dir+1);
/* Currently needed for include (FIXME) */
env_put(t_strconcat("SIEVE_DIR=", sieve_dir, "included", NULL));
env_put(t_strconcat("SIEVE_GLOBAL_DIR=", sieve_dir, "included-global", NULL));
if ( (sbin = sieve_compile(script_path, test_script_ehandler)) == NULL )
return FALSE;
......
......@@ -61,7 +61,6 @@ static void testsuite_bin_init(void)
testsuite_init();
}
static void testsuite_bin_deinit(void)
{
testsuite_deinit();
......@@ -216,11 +215,13 @@ int main(int argc, char **argv)
/* Initialize environment */
sieve_dir = strrchr(scriptfile, '/');
if ( sieve_dir == NULL )
sieve_dir="./";
sieve_dir= "./";
else
sieve_dir = t_strdup_until(scriptfile, sieve_dir);
sieve_dir = t_strdup_until(scriptfile, sieve_dir+1);
env_put(t_strconcat("SIEVE_DIR=", sieve_dir, NULL));
/* Currently needed for include (FIXME) */
env_put(t_strconcat("SIEVE_DIR=", sieve_dir, "included", NULL));
env_put(t_strconcat("SIEVE_GLOBAL_DIR=", sieve_dir, "included-global", NULL));
/* Compile sieve script */
sbin = _compile_sieve_script(scriptfile);
......
......@@ -17,6 +17,36 @@ test "Generic" {
}
}
test "Circular - direct" {
if test_compile "errors/circular-1.sieve" {
test_fail "compile should have failed";
}
if not test_error :count "eq" :comparator "i;ascii-numeric" "3" {
test_fail "wrong number of errors reported";
}
}
test "Circular - one intermittent" {
if test_compile "errors/circular-2.sieve" {
test_fail "compile should have failed";
}
if not test_error :count "eq" :comparator "i;ascii-numeric" "4" {
test_fail "wrong number of errors reported";
}
}
test "Circular - two intermittent" {
if test_compile "errors/circular-3.sieve" {
test_fail "compile should have failed";
}
if not test_error :count "eq" :comparator "i;ascii-numeric" "5" {
test_fail "wrong number of errors reported";
}
}
/*
* Using import/export without variables required
*/
......
require "include";
discard;
include "circular-one.sieve";
require "include";
discard;
include "circular-two.sieve";
require "include";
discard;
include "circular-three";
require "include";
keep;
include "circular-one.sieve";
require "include";
include "circular-three-3.sieve";
require "include";
include "circular-three.sieve";
require "include";
keep;
include "circular-three-2.sieve";
require "include";
include "circular-two.sieve";
require "include";
keep;
include "circular-two-2.sieve";
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.