summaryrefslogtreecommitdiff
path: root/t/io
Commit message (Collapse)AuthorAgeFilesLines
* Stop truncate(word) from falling back to file nameFather Chrysostomos2012-07-251-2/+10
| | | | | | | | | In commit 5e0adc2d66, which was a bug fix, I made the mistake of checking the truth of the return value of gv_fetchsv, which is called when truncate’s argument is a bareword. This meant that truncate FOO, 0; would truncate the file named FOO if the glob happened to have been deleted.
* ensure shmread() calls get and set magic onceChip Salzenberg2012-07-101-1/+11
|
* Make open(... "<&", $fileno) respect magicFather Chrysostomos2012-06-071-1/+5
| | | | | | | | | | | | | | | | | A magical variable is never SvPOK, but only SvPOKp. The code for checking whether a duplicatee is a numeric file descriptor was only checking SvPOK. So a regular variable containing a fileno-as-a-string would work, such as the $a below, as would a stringified magical vari- able ("$1"), but not $1 itself. $ echo foo | perl -le '$a = "0"; open a, "<&", $a; warn <a>' foo $ echo foo | perl -le '"0" =~ /(.)/; open a, "<&", $1; warn <a>' Can't use an undefined value as filehandle reference at -e line 1. $ echo foo | perl -le '"0" =~ /(.)/; open a, "<&", "$1"; warn <a>' foo SvPOK variables are also SvPOKp, so checking only the latter suffices.
* Assertion failure with $/=*foo; warn;Father Chrysostomos2012-06-071-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | $ ./perl -Ilib -e '$/=*foo; <>; warn' <./perl Assertion failed: (!isGV_with_GP(_svcur)), function Perl_mess_sv, file util.c, line 1467. Abort trap The assertion happens when ‘<...> line 42’ is being appended to the message. The line of code in question is this: const bool line_mode = (RsSIMPLE(PL_rs) && SvCUR(PL_rs) == 1 && *SvPVX_const(PL_rs) == '\n'); It uses this macro in perl.h: #define RsSIMPLE(sv) (SvOK(sv) && (! SvPOK(sv) || SvCUR(sv))) which was last modified by commit af7d13df559: -#define RsSIMPLE(sv) (SvOK(sv) && SvCUR(sv)) -#define RsPARA(sv) (SvOK(sv) && ! SvCUR(sv)) +#define RsSIMPLE(sv) (SvOK(sv) && (! SvPOK(sv) || SvCUR(sv))) +#define RsPARA(sv) (SvPOK(sv) && ! SvCUR(sv)) So it looks as though it has always called SvCUR on something that is not necessarily a PV. As of commit af7d13df559, it has also called SvPVX on a potential non-PV. Fixing this simply involves using SvPV instead of SvPVX. I don’t know that t/io/open.t is the best place for the test, but all the other ‘<...> line 42’ tests are there.
* Deprecate literal unescaped "{" in regexes.Karl Williamson2012-05-241-2/+2
| | | | | | | | | | | | | | | | | We are deprecating literal left braces in regular expressions. The 5.16 delta announced that this is coming. This commit causes a warning to be raised when a literal "{" is encountered. However, it does not do this if the left brace is at the beginning of a construct. Such a brace does not cause problems for us for our future use of it for other purposes, as, for example in things like \b{w}, and there were a large number of core tests that failed without this condition. I didn't mention this exception in the diagnostic. We may choose to forbid it everywhere, and we certainly want to discourage its use everywhere. But this commit gets the essential components in early in 5.17, and we can tighten it up later if we decide to.
* [perl #103492] Give lvalue cx to (s)printf argsFather Chrysostomos2011-12-311-1/+6
| | | | | | | | | Or potential lvalue context, like function calls. The %n format code’s existence renders these two very much like func- tion calls, as they can modify their arguments. This allows sprintf("...%n", substr ...) to work.
* PerlIO::get_layers: Treat numbers as stringsFather Chrysostomos2011-12-251-1/+5
| | | | | | | | | | | | | | PerlIO::get_layers should not be ignoring an argument like 12, but treating "12" (the string) as a filehandle, as those are both the same value. It’s an instance of the string/num bug, which is a bit like the Unicode Bug. This commit takes the conservative approach of expanding it to flat scalars in general, but not references (in case we decide to do something interesting later on, even though I think that would be a bad idea).
* [perl #97956] PerlIO::get_layers: call get-magicFather Chrysostomos2011-12-251-1/+20
|
* Stop seek($glob_copy...) from clearing PL_last_in_gvFather Chrysostomos2011-12-181-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | seek had the same bug as tell. Here is the commit message from 8dc99089, which fixed tell: ---------------------------------------------------------------------- Stop tell($glob_copy) from clearing PL_last_in_gv This bug is a side effect of rv2gv’s starting to return an incoercible mortal copy of a coercible glob in 5.14: $ perl5.12.4 -le 'open FH, "t/test.pl"; $fh=*FH; tell $fh; print tell' 0 $ perl5.14.0 -le 'open FH, "t/test.pl"; $fh=*FH; tell $fh; print tell' -1 In the first case, tell without arguments is returning the position of the filehandle. In the second case, tell with an explicit argument that happens to be a coercible glob (tell has an implicit rv2gv, so tell $fh is actu- ally tell *$fh) sets PL_last_in_gv to a mortal copy thereof, which is freed at the end of the statement, setting PL_last_in_gv to null. So there is no ‘last used’ handle by the time we get to the tell without arguments. This commit adds a new rv2gv flag that tells it not to copy the glob. By doing it unconditionally on the kidop, this allows tell(*$fh) to work the same way. Let’s hope nobody does tell(*{*$fh}), which will unset PL_last_in_gv because the inner * returns a mortal copy. This whole area is really icky. PL_last_in_gv should be refcounted, but that would cause handles to leak out of scope, breaking programs that rely on the auto-closing ‘feature’.
* Stop eof($glob_copy) from clearing PL_last_in_gvFather Chrysostomos2011-12-171-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | eof had the same bug as tell. Here is the commit message from 8dc99089, which fixed tell: ---------------------------------------------------------------------- Stop tell($glob_copy) from clearing PL_last_in_gv This bug is a side effect of rv2gv’s starting to return an incoercible mortal copy of a coercible glob in 5.14: $ perl5.12.4 -le 'open FH, "t/test.pl"; $fh=*FH; tell $fh; print tell' 0 $ perl5.14.0 -le 'open FH, "t/test.pl"; $fh=*FH; tell $fh; print tell' -1 In the first case, tell without arguments is returning the position of the filehandle. In the second case, tell with an explicit argument that happens to be a coercible glob (tell has an implicit rv2gv, so tell $fh is actu- ally tell *$fh) sets PL_last_in_gv to a mortal copy thereof, which is freed at the end of the statement, setting PL_last_in_gv to null. So there is no ‘last used’ handle by the time we get to the tell without arguments. This commit adds a new rv2gv flag that tells it not to copy the glob. By doing it unconditionally on the kidop, this allows tell(*$fh) to work the same way. Let’s hope nobody does tell(*{*$fh}), which will unset PL_last_in_gv because the inner * returns a mortal copy. This whole area is really icky. PL_last_in_gv should be refcounted, but that would cause handles to leak out of scope, breaking programs that rely on the auto-closing ‘feature’.
* Stop tell($glob_copy) from clearing PL_last_in_gvFather Chrysostomos2011-12-171-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This bug is a side effect of rv2gv’s starting to return an incoercible mortal copy of a coercible glob in 5.14: $ perl5.12.4 -le 'open FH, "t/test.pl"; $fh=*FH; tell $fh; print tell' 0 $ perl5.14.0 -le 'open FH, "t/test.pl"; $fh=*FH; tell $fh; print tell' -1 In the first case, tell without arguments is returning the position of the filehandle. In the second case, tell with an explicit argument that happens to be a coercible glob (tell has an implicit rv2gv, so tell $fh is actu- ally tell *$fh) sets PL_last_in_gv to a mortal copy thereof, which is freed at the end of the statement, setting PL_last_in_gv to null. So there is no ‘last used’ handle by the time we get to the tell without arguments. This commit adds a new rv2gv flag that tells it not to copy the glob. By doing it unconditionally on the kidop, this allows tell(*$fh) to work the same way. Let’s hope nobody does tell(*{*$fh}), which will unset PL_last_in_gv because the inner * returns a mortal copy. This whole area is really icky. PL_last_in_gv should be refcounted, but that would cause handles to leak out of scope, breaking programs that rely on the auto-closing ‘feature’.
* sv.c: Make most warnings utf8-cleanBrian Fraser2011-10-061-1/+10
|
* Move the test for recursive call to Perl_load_module to t/io/perlio.tNicholas Clark2011-09-231-1/+15
| | | | | It's a croak(), not a warning, so doesn't really belong in lib/warnings.t [This also implicitly fixes the wrong expected output of 69dc7e4bdb8e397c]
* skip_all is a sub in t/test.pl.Craig A. Berry2011-09-161-2/+2
| | | | | | | plan(skip_all => 'foo') is a Test::More-ism that survived the switch to t/test.pl in 8d646433865d105d3ca0f95dd6593fe343e37aa2 unchanged and caused the test to fail where d_shm is not defined or IPC::SysV is not built.
* Use test.pl miniperl check rather than by-hand in t/io/shm.tGeorge Greer2011-09-141-3/+1
| | | | | Doing the miniperl check by hand didn't exit() so the test script would die as soon as it got down to the "use IPC::SysV" line.
* Tests in "t/io" aren't supposed to use Test::More yet, so use test.pl instead.George Greer2011-09-141-1/+1
|
* shm.t: Skip under miniperlFather Chrysostomos2011-09-141-0/+3
|
* shm.t: Don’t call shmctl in END when undefinedFather Chrysostomos2011-09-141-3/+3
| | | | | The skip was not inside a BEGIN block, so the END block ended up getting compiled and running.
* Fix #98480 math when reading shared memoryLeon Timmermans2011-09-141-1/+7
| | | | | shmread didn't unset SvIOK properly, causing a read into a SVIV to have an incorrect numeric value. This patch fixes that and adds tests.
* Added SysV shared memory testsLeon Timmermans2011-09-141-0/+75
| | | | | Tests are based on IPC-SysV's tests, though I had to remove a lot for it not to rely on IPC::SharedMem.
* close($undef) should not croak_no_modifyFather Chrysostomos2011-08-231-1/+10
| | | | | | | | | | | | Commit ac53db4c3f7e fixed bug #31767 (open $1 not dying), but put the SvREADONLY check in the wrong spot, causing this bug: $ perl -lwe 'no warnings "once"; close $x; close $+' Name "main::x" used only once: possible typo at -e line 1. Use of uninitialized value $x in ref-to-glob cast at -e line 1. Modification of a read-only value attempted at -e line 1. It shouldn’t be dying if I’m not trying to modifying it.
* Skip the hanging eintr.t test on GNU/kFreeBSD tooNiko Tyni2011-08-041-1/+1
| | | | | As we're still using a list of hanging operating systems, include 'gnukfreebsd' by matching for 'freebsd' anywhere in $^O.
* re-indent some tests for readabilityFather Chrysostomos2011-07-161-14/+16
| | | | | This makes it easier to see when the skip count needs to be updated.
* Correct skip count in perlio.tFather Chrysostomos2011-07-161-1/+1
| | | | This makes it pass under miniperl again.
* revert recent changes to eintr.tDavid Mitchell2011-06-161-60/+10
| | | | | | | | | | | Revert "[perl #92828] eintr.t hangs on FreeBSD" This reverts commit 6e59d93aee950461947904b4f24a7f52c6c85f58. Revert "eintr.t: skip based on capability rather than OS" This reverts commit df375c6d048b938ecdeaecc7b264a7f1a190120a. My attempt to skip based on capability hung freebsd, and my attempt to fix that failed. Give up for now.
* [perl #92828] eintr.t hangs on FreeBSDDavid Mitchell2011-06-151-0/+29
| | | | | | | My commit df375c6d048b938ecdeaecc7b264a7f1a190120a attempted to convert t/io/eintr.t from OS-based skipping to capability-based skipping, but it only tested whether reads from pipes are interruptible. Some OSes (like FreeBSD) only hang on write; so probe for that too.
* [perl #90130] Allow CORE::* without feature.pmFather Chrysostomos2011-06-111-1/+6
| | | | | This commit allows feature.pm-enabled keywords to work with CORE::* even outside the scope of ‘use feature’.
* eintr.t: skip based on capability rather than OSDavid Mitchell2011-06-091-10/+31
| | | | | | | | | | | | | The t/io/eintr.t tests require read/write system to calls to be interruptible (to see if anything nasty can be done by the signal handler). Many platforms aren't interruptible, which means the tests would hang. We currently work round this by skipping based on a hard-coded list of OSes (such as win32, VMS etc). Change this so that we instead do an initial test as to whether they are interruptible, and if not, skip the whole test file.
* [perl #92258] <$fh> hangs on a glob copyFather Chrysostomos2011-06-051-1/+7
| | | | | | | | | Opening a file handle to \$glob causes assertion failures (under debugging) or hangs or other erratic behaviour without debugging. This might even crash in some cases. It never really worked properly, but it didn’t start hanging apparently until 5.12.2 and 5.14.0.
* skip t/io/eintr.t on production releasesDavid Mitchell2011-05-031-1/+6
| | | | | | | We already skip this test file on many platforms which don't have interruptible IO system calls. Extend this to unconditionally skip if it's an even (production) release version, so that we don't get false positives for other platforms we didn't know about.
* [perl #88420] BOM support on Windows broken in 5.13.11Jan Dubois2011-04-131-0/+14
| | | | | | | When Perl reads the script in text mode, then the tell() position on the script handle may include stripped carriage return characters. Therefore the file position after reading the first line of the script may be one larger than the length of the input buffer.
* Improve comment for skipped test on Solaris in t/io/eintr.tAndy Dougherty2011-03-221-0/+1
|
* Skip t/io/eintr.t for Solaris 8 as wellAndy Dougherty2011-03-221-1/+2
| | | | (see tickets perl #85842 and #84688).
* Read Perl code on Windows in text mode by default.Jan Dubois2011-03-161-0/+81
| | | | | | | | | | | | | | | | | | | | | | | We used to read Perl code in binary mode to make life easier for ByteLoder to include binary data in a source file. To maintain the illusion of text mode for the DATA handle the filehandle was transformed from binary mode to text mode when the parser reached the __END__ or __DATA__ tokens. This however never worked correctly, as the positions returned by tell(DATA) were still based on reading part of the stream in binary mode. And even worse, flushing all filehandles before calling system(), backticks, or fork() would actually reposition the DATA filehandle incorrectly, so future reads from it returned the wrong data. http://rt.perl.org/rt3/Ticket/Display.html?id=28106 contains several bug reports that are all related to this problem. The new t/io/data.t file contains the failing code samples from those bugs. This patch changes the default build option for Windows to text mode. ByteLoader will have to deal with this internally, e.g. by rewinding DATA and switching to binary mode itself.
* Rename test.pl's skip_all_without_extension to *_dynamic_extension().Nicholas Clark2011-03-122-4/+2
| | | | | | All callers were using it with dynamic extensions, and also had a skip_all_if_miniperl() for the same extension. Merge the two tests into one function to save repetition.
* Skip eintr.t on FreeBSD (see perl #85842 and #84688).Craig A. Berry2011-03-111-1/+3
| | | | | | | | | It appears that a larger PerlIO buffer combined with writing to a pipe triggers an alternate write mechanism in FreeBSD called a direct write, which is not interruptible by signals. That's somewhat speculative and has not been confirmed by someone with knowledge of FreeBSD internals, but we do know the test hangs, so it's best not to run it for now.
* Refactor 4 tests to use skip_if_miniperl().Nicholas Clark2011-03-071-2/+1
|
* Refactor the startup logic in fflush.t to use skip_all()Nicholas Clark2011-03-071-10/+5
| | | | | | | | | The tautological 3 way logic if (...) { print "1..7\n" } elsif (...) { print "1..7\n" } else { ... } had actually been in the test since it was first added in a43cb6b7285a7b60, although it was initially "1..4\n" in each block. Also use plan(), and set test.pl's idea of the current test before exiting.
* Refactor 5 tests to use skip_all(), instead of generating TAP locally.Nicholas Clark2011-03-072-10/+5
|
* Add skip_all_without_perlio() to test.pl, and use it in 8 tests.Nicholas Clark2011-03-076-17/+9
| | | | | It's a common idiom in the tests. This makes it easier to find, read, and remove.
* Ensure that t/io/{print,read,say}.t load Errno at BEGIN time.Nicholas Clark2011-03-063-7/+8
| | | | | | | | | If Errno is loaded after the compiler has parsed the C<exists &Errno::EBADF> later in the script, then the intent of that test is subverted - &Errno::EBADF does not exist, at least as far as the typeglob bound to that op is concerned, and the test for $! is skipped. I suspect that these have been skipping since the implementation of Errno was changed in 42607a60df6df19b in May 2010 to reduce its memory footprint by 55%.
* Tidy perlio_open.t, by using test.pl skip_all* functions where appropriate.Nicholas Clark2011-03-061-13/+3
| | | | This reduces the startup boilerplate code by more than half.
* Add skip_all_without_extension() to test.pl, for the common skip idiom.Nicholas Clark2011-03-061-3/+2
| | | | Use it in t/io/layers.t to skip if Encode is not built.
* Tidy t/io/layers.tNicholas Clark2011-03-061-16/+8
| | | | | | Skip under minitest using skip_all_if_miniperl(). skip_all() once rather than skipping every test if Encode is not built, or PerlIO is not available.
* Tidy t/io/crlf.tNicholas Clark2011-03-061-5/+4
| | | | | Skip a test under minitest using skip_if_miniperl(). Use eq(), like() and unlike() where appropriate, instead of ok().
* Tidy t/io/binmode.tNicholas Clark2011-03-061-15/+13
| | | | | | | Remove redundant C<use Config;> If C<find PerlIO::Layer 'perlio'> fails, use skip() rather than ok() to skip. Make the indenting on 2 inconsistent lines consistent with the rest of the file. Die if Errno can't be loaded, unless it's miniperl.
* Under minitest, tests requiring File::Spec->devnull(), as it may not be built.Nicholas Clark2011-03-061-24/+35
| | | | | Although File::Spec is pure Perl, it is part of the Cwd distribution, and that isn't built for minitest. So we can't rely on it.
* In t/ avoid using File::Spec for paths only used by Perl.Nicholas Clark2011-03-061-2/+1
| | | | | | All platforms Perl builds on can already support Unix-style paths (given that make_ext.pl is using them). This makes 7 more tests pass under minitest, which doesn't build File::Spec, because it's part of an XS module.
* Skip the test for #77684 under minitest, as it requires PerlIO::scalarNicholas Clark2011-02-231-1/+2
|
* In t/io/open.t, skip the tests for loading IO::File when running under miniperlNicholas Clark2011-02-211-1/+2
| | | | This is analogous to skipping all of t/op/iofile.t under miniperl.