Skip to content

Commit

Permalink
Version in exported module
Browse files Browse the repository at this point in the history
* Python: export `dna_jellyfish.__version__`

* Perl: export `$jellyfish::VERSION`

* Ruby: export `Jellyfish::VERSION`
  • Loading branch information
gmarcais committed Mar 19, 2024
1 parent 54602dd commit e128ca3
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 3 deletions.
10 changes: 10 additions & 0 deletions swig/jellyfish.i
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ else:
#undef die
%}

#ifdef SWIGPYTHON
%constant const char* __version__ = PACKAGE_VERSION;
#else
%constant const char* VERSION = PACKAGE_VERSION;
#endif

#ifdef SWIGRUBY
#endif


%include "mer_dna.i"
%include "mer_file.i"
%include "hash_counter.i"
Expand Down
24 changes: 24 additions & 0 deletions swig/perl5/t/test_jellyfish.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This file is part of Jellyfish.
#
# This work is dual-licensed under 3-Clause BSD License or GPL 3.0.
# You can choose between one of them if you use this work.
#
# `SPDX-License-Identifier: BSD-3-Clause OR GPL-3.0`

use strict;
use warnings;
use Test::More;

require_ok('jellyfish');

# Test version
{
my $version = $jellyfish::VERSION;
my $m = $version =~ m/^(\d+)\.(\d+)\.(\d+)$/;
ok($m, , "Version match regexp");
ok($1 > 0, "Major positive");
ok($2 >= 0, "Minor");
ok($3 >= 0, "Revision");
}

done_testing;
25 changes: 25 additions & 0 deletions swig/python/test_jellyfish.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This file is part of Jellyfish.
#
# This work is dual-licensed under 3-Clause BSD License or GPL 3.0.
# You can choose between one of them if you use this work.
#
# `SPDX-License-Identifier: BSD-3-Clause OR GPL-3.0`

import unittest
import sys
import re

import dna_jellyfish as jf

class TestMerFile(unittest.TestCase):
def test_version(self):
version = jf.__version__
m = re.match('^(\d+)\.(\d+).(\d+)$', version)
self.assertIsNotNone(m)
self.assertGreater(int(m[1]), 0)
self.assertGreaterEqual(int(m[2]), 0)
self.assertGreaterEqual(int(m[3]), 0)

if __name__ == '__main__':
data = sys.argv.pop(1)
unittest.main()
20 changes: 20 additions & 0 deletions swig/ruby/test_jellyfish.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file is part of Jellyfish.
#
# This work is dual-licensed under 3-Clause BSD License or GPL 3.0.
# You can choose between one of them if you use this work.
#
# `SPDX-License-Identifier: BSD-3-Clause OR GPL-3.0`

require 'test/unit'
require 'jellyfish'


class TestMerFile < Test::Unit::TestCase
def test_version
m = /^(\d+)\.(\d+)\.(\d+)$/ =~ Jellyfish::VERSION
assert_not_nil m
assert_true($1.to_i > 0)
assert_true($2.to_i >= 0)
assert_true($3.to_i >= 0)
end
end
2 changes: 1 addition & 1 deletion tests/swig_perl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $JF count -m $K -s 10M -t $nCPUs -C -o ${pref}.jf seq1m_$I.fa
$JF dump -c ${pref}.jf > ${pref}.dump
$JF histo ${pref}.jf > ${pref}.histo

for i in test_mer_file.t test_hash_counter.t test_string_mers.t; do
for i in test_jellyfish.t test_mer_file.t test_hash_counter.t test_string_mers.t; do
echo Test $i
$PERL "-I$LOADPATH/.libs" "-I$LOADPATH" "-I$SRCDIR/swig/perl5" "$SRCDIR/swig/perl5/t/$i" .
done
2 changes: 1 addition & 1 deletion tests/swig_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $JF count -m $K -s 10M -t $nCPUs -C -o ${pref}.jf seq1m_$I.fa
$JF dump -c ${pref}.jf > ${pref}.dump
$JF histo ${pref}.jf > ${pref}.histo

for i in test_mer_file.py test_hash_counter.py test_string_mers.py; do
for i in test_jellyfish.py test_mer_file.py test_hash_counter.py test_string_mers.py; do
echo Test $i
$PYTHON "$SRCDIR/swig/python/$i" .
done
3 changes: 2 additions & 1 deletion tests/swig_ruby.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ $JF histo ${pref}.jf > ${pref}.histo



for i in test_mer_file.rb test_hash_counter.rb test_string_mers.rb; do
#for i in test_jellyfish.rb test_mer_file.rb test_hash_counter.rb test_string_mers.rb; do
for i in test_jellyfish.rb; do
echo Test $i
$RUBY "-I$LOADPATH" "$SRCDIR/swig/ruby/$i" .
done

0 comments on commit e128ca3

Please sign in to comment.