Thread Perl XS - test.pl wird nicht erzeugt (8 answers)
Opened by Gast at 2007-10-10 17:44

MechaTikal
 2007-10-11 10:51
#100653 #100653
User since
2007-10-10
20 Artikel
BenutzerIn
[default_avatar]
Dann stimmt aber das ganze Tutorial nicht. Wenn ich "make test" aufrufe, erhalte ich zwar

Code: (dl )
1
2
3
4
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/New....ok
All tests successful.
Files=1, Tests=1, 0 wallclock secs ( 0.03 cusr + 0.01 csys = 0.04 CPU)

aber ab dem 2. Beispiel kann ich nicht weitermachen. (Oder bin ich einfach zu doof?)
Jedenfalls steht da ja Folgendes:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
In order to test that our extension works, we now need to look at the file test.pl.  This file is set up to imitate the same kind of
testing structure that Perl itself has. Within the test script, you perform a number of tests to confirm the behavior of the exten-
sion, printing "ok" when the test is correct, "not ok" when it is not. Change the print statement in the BEGIN block to print
"1..4", and add the following code to the end of the file:

print &Mytest::is_even(0) == 1 ? "ok 2" : "not ok 2", "\n";
print &Mytest::is_even(1) == 0 ? "ok 3" : "not ok 3", "\n";
print &Mytest::is_even(2) == 1 ? "ok 4" : "not ok 4", "\n";

We will be calling the test script through the command ""make test"". You should see output that looks something like this:

% make test
PERL_DL_NONLAZY=1 /opt/perl5.004/bin/perl (lots of -I arguments) test.pl
1..4
ok 1
ok 2
ok 3
ok 4
%

Habe ich eingetippert (in Mytest.t statt Mytest.test), macht aber beim Ausführen lauter Fehlermeldungen.
Ich probiere das jetzt nochmal, aber es wurmt mich schon, dass die manpage veraltet scheint.

EDIT: So, nochmal das Ganze. Mein Code sieht so aus:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
use Test::More tests => 1..4;
BEGIN { use_ok('Mytest') };

#########################

# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.

print &Mytest::is_even(0) == 1 ? "ok 2" : "not ok 2", "\n";
print &Mytest::is_even(1) == 0 ? "ok 3" : "not ok 3", "\n";
print &Mytest::is_even(2) == 1 ? "ok 4" : "not ok 4", "\n";


Als Ausgabe bei "make test" erhalte ich:
Code: (dl )
1
2
3
4
5
6
7
8
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/Mytest....FAILED tests 2-4
Failed 3/1 tests, -200.00% okay
Failed Test Stat Wstat Total Fail Failed List of Failed
-------------------------------------------------------------------------------
t/Mytest.t 1 3 300.00% 2-4
Failed 1/1 test scripts, 0.00% okay. -3/1 subtests failed, 400.00% okay.
make: *** [test_dynamic] Fehler 255

View full thread Perl XS - test.pl wird nicht erzeugt