summaryrefslogtreecommitdiff
path: root/test/exec.t
diff options
context:
space:
mode:
Diffstat (limited to 'test/exec.t')
-rwxr-xr-xtest/exec.t58
1 files changed, 29 insertions, 29 deletions
diff --git a/test/exec.t b/test/exec.t
index 6757fc7..c113c87 100755
--- a/test/exec.t
+++ b/test/exec.t
@@ -3,67 +3,67 @@
# Tests for getopt in it.class
-is(it::exec("echo gna"), "gna\n", "basic exec");
-is(it::exec("echo {arg}", ['arg' => 'gnu'], ['arg' => "gna"]), "gna\n", "exec with argument");
-is(it::exec("echo {0}", 'gna'), "gna\n", "exec with positional argument");
-is(it::shell_command("egrep a{10}"), 'egrep a{10}', "exec with too large positional argument");
-is(it::shell_command("echo {arg}", ['arg' => 'gna07,-:blah']), "echo gna07,-:blah", "don't quote arguments with only whitelistes characters");
-is(it::shell_command("echo {arg}", ['arg' => '2>&1']), "echo '2>&1'", "quote arguments with dangerous characters");
-is(it::shell_command("echo {arg}", ['arg' => '']), "echo ''", "quote empty arguments");
-is(it::shell_command("echo {arg}", ['arg' => null]), "echo ", "remove null values");
-is(it::shell_command("echo {arg}", ['arg' => false]), "echo ", "remove false values");
-is(it::shell_command("echo {arg}", ['arg' => []]), "echo ", "remove empty arrays");
-is(it::shell_command("echo {arg}", (object)['arg' => "foo"]) , "echo foo", "allow objects");
-is(it::shell_command("echo {arg}", ['arg' => 1], ['arg' => 2]), "echo 2", "support varargs");
+is_(it::exec("echo gna"), "gna\n", "basic exec");
+is_(it::exec("echo {arg}", ['arg' => 'gnu'], ['arg' => "gna"]), "gna\n", "exec with argument");
+is_(it::exec("echo {0}", 'gna'), "gna\n", "exec with positional argument");
+is_(it::shell_command("egrep a{10}"), 'egrep a{10}', "exec with too large positional argument");
+is_(it::shell_command("echo {arg}", ['arg' => 'gna07,-:blah']), "echo gna07,-:blah", "don't quote arguments with only whitelistes characters");
+is_(it::shell_command("echo {arg}", ['arg' => '2>&1']), "echo '2>&1'", "quote arguments with dangerous characters");
+is_(it::shell_command("echo {arg}", ['arg' => '']), "echo ''", "quote empty arguments");
+is_(it::shell_command("echo {arg}", ['arg' => null]), "echo ", "remove null values");
+is_(it::shell_command("echo {arg}", ['arg' => false]), "echo ", "remove false values");
+is_(it::shell_command("echo {arg}", ['arg' => []]), "echo ", "remove empty arrays");
+is_(it::shell_command("echo {arg}", (object)['arg' => "foo"]) , "echo foo", "allow objects");
+is_(it::shell_command("echo {arg}", ['arg' => 1], ['arg' => 2]), "echo 2", "support varargs");
errlike(fn() => it::shell_command('echo -- $(echo {arg})', ['arg' => "-1"]), "leading - in value", "disallow leading dash in non-option args");
-is(
+is_(
it::shell_command("echo {-opts}", ['-opts' => ['--longopt' => true]]),
"echo --longopt",
"options argument with long option"
);
-is(
+is_(
it::shell_command("echo {-opts}", ['-opts' => ['-onedash' => true]]),
"echo -onedash",
"... with long option but only one dash"
);
-is(
+is_(
it::shell_command("echo {-opts}", ['-opts' => ['-s' => true]]),
"echo -s",
"... with short option"
);
-is(
+is_(
it::shell_command("echo {-opts}", ['-opts' => ['--longopt' => 'val']]),
"echo --longopt val",
"... with long option with value"
);
-is(
+is_(
it::shell_command("echo {-opts}", ['-opts' => ['-onedash' => 'val']]),
"echo -onedash val",
"... with long option but only one dash and with value"
);
-is(
+is_(
it::shell_command("echo {-opts}", ['-opts' => ['-s' => 'val']]),
"echo -s val",
"... with short option with value"
);
-is(
+is_(
it::shell_command("echo {-opts}", ['-opts' => ['--longopt' => false]]),
"echo ",
"... with disabled long option"
);
-is(
+is_(
it::shell_command("echo {-opts}", ['-opts' => ['-s' => false]]),
"echo ",
"... with disabled short option"
);
-is(
+is_(
it::shell_command("echo {-opts}", ['-opts' => ['longopt' => true]]),
"echo --longopt",
"... long option without dashes"
);
-is(
+is_(
it::shell_command("echo {-opts}", ['-opts' => ['s' => true]]),
"echo -s",
"... short option without dashes"
@@ -75,16 +75,16 @@ foreach (["", "C", "de_CH", "de_CH.utf8"] as $locale)
$arg = "preüpost";
if (it::match('utf8', $locale))
$arg = it::any2utf8($arg);
- is(it::exec("echo {arg}", ['arg' => $arg]), $arg . "\n", "exec with argument and umlaut (locale '$locale')");
+ is_(it::exec("echo {arg}", ['arg' => $arg]), $arg . "\n", "exec with argument and umlaut (locale '$locale')");
}
-is(it::_exec_quotevalue(""), "''", "empty arg needs quotes");
-is(it::_exec_quotevalue("*"), "'*'", "special chars need quotes");
-is(it::_exec_quotevalue("Aabcdef0123456789"), "Aabcdef0123456789", "simple case. tel:debug_getdata needs unquoted vals");
+is_(it::_exec_quotevalue(""), "''", "empty arg needs quotes");
+is_(it::_exec_quotevalue("*"), "'*'", "special chars need quotes");
+is_(it::_exec_quotevalue("Aabcdef0123456789"), "Aabcdef0123456789", "simple case. tel:debug_getdata needs unquoted vals");
-is(it::system('exit 0'), 0, 'return exit code 0');
-is(it::system('exit 1'), 1, 'return exit code 1');
-is(it::system('exit -1'), 255, 'return exit code unsigned');
+is_(it::system('exit 0'), 0, 'return exit code 0');
+is_(it::system('exit 1'), 1, 'return exit code 1');
+is_(it::system('exit -1'), 255, 'return exit code unsigned');
@unlink('/tmp/it_system_test');
it::system('touch /tmp/it_system_test');