Leser: 2
9 Einträge, 1 Seite |
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)
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
%
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";
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl Mytest.t' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use Test::More tests => 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. is(&Mytest::is_even(0), 1); is(&Mytest::is_even(1), 0); is(&Mytest::is_even(2), 1);
renee+2007-10-11 09:24:11--Ändere mal die .t-Datei so wie ich es geschrieben hatte...
Edit: und poste bitte mal die Ausgabe von "make test"
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/Mytest....ok
All tests successful.
Files=1, Tests=4, 0 wallclock secs ( 0.03 cusr + 0.00 csys = 0.03 CPU)
MechaTikal+2007-10-11 10:41:50--EDIT:
Hat sich erledigt. Wie in Mytest.t beschrieben, soll man erst "make install" und dann "perl Mytest.t" ausführen. So klappt das Ganze auch wie im Tutorial beschrieben. Wäre schön, wenn das mal jemand aktualisieren würde.
Danke trotzdem für die Hlfe. Hat sich schon mal jemand intensiver mit XS befasst?
1
2
3
4
5
perl -Mblib t/Mytest.t # benutzt das modul 'blib', welches das verzeichnis blib/lib als pfad benutzt
oder
perl -Iblib/lib t/Mytest.t # f[gt den pfad blib/lib direkt hinzu
oder
prove t/Mytest.t # macht das, was make test macht, nur einzeln
9 Einträge, 1 Seite |