[Commits] [SCM] clawsker branch, master, updated. 1.3.8-14-gdbdbfec
mones at claws-mail.org
mones at claws-mail.org
Wed Aug 28 16:19:59 UTC 2024
The branch, master has been updated
via dbdbfecedbb6ad14548208e5b9a1d4c344bba800 (commit)
from 73cc06b3925b49d1de3dc18e1e81428977ce757a (commit)
Summary of changes:
clawsker | 4 ++--
t/set_rc_filename.t | 30 ++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 2 deletions(-)
create mode 100644 t/set_rc_filename.t
- Log -----------------------------------------------------------------
commit dbdbfecedbb6ad14548208e5b9a1d4c344bba800
Author: Ricardo Mones <ricardo at mones.org>
Date: Wed Aug 28 18:19:50 2024 +0200
Use negative indices and add test
diff --git a/clawsker b/clawsker
index e6e6170..108bde5 100755
--- a/clawsker
+++ b/clawsker
@@ -429,8 +429,8 @@ sub get_menurc_filename {
sub set_rc_filename {
my ($fullname) = @_;
my @parts = splitpath ($fullname);
- $CONFIGRC = $parts[$#parts];
- $parts[$#parts] = '';
+ $CONFIGRC = $parts[-1];
+ $parts[-1] = '';
$CONFIGDIR = catpath (@parts);
}
diff --git a/t/set_rc_filename.t b/t/set_rc_filename.t
new file mode 100644
index 0000000..c7d122b
--- /dev/null
+++ b/t/set_rc_filename.t
@@ -0,0 +1,30 @@
+use 5.010_000;
+use strict;
+use utf8;
+use Test::More tests => 12;
+use Test::Exception;
+
+require_ok ('Clawsker');
+
+use Clawsker;
+
+ok ( defined &Clawsker::set_rc_filename, 'has function' );
+
+is ( $Clawsker::CONFIGRC, 'clawsrc', 'init: rc' );
+like ( $Clawsker::CONFIGDIR, qr{^.*\.claws-mail$}, 'init: dir' );
+
+Clawsker::set_rc_filename();
+is ( $Clawsker::CONFIGRC, '', 'empty: rc' );
+is ( $Clawsker::CONFIGDIR, '', 'empty: dir' );
+
+Clawsker::set_rc_filename('filename');
+is ( $Clawsker::CONFIGRC, 'filename', 'fn: rc' );
+is ( $Clawsker::CONFIGDIR, '', 'fn: dir' );
+
+Clawsker::set_rc_filename('path/to/filename');
+is ( $Clawsker::CONFIGRC, 'filename', 'rp: rc' );
+is ( $Clawsker::CONFIGDIR, 'path/to/', 'rp: dir' );
+
+Clawsker::set_rc_filename('/path/to/filename');
+is ( $Clawsker::CONFIGRC, 'filename', 'ap: rc' );
+is ( $Clawsker::CONFIGDIR, '/path/to/', 'ap: dir' );
-----------------------------------------------------------------------
hooks/post-receive
--
Hidden preferences editor for Claws Mail
More information about the Commits
mailing list