aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_dir.rb
Commit message (Collapse)AuthorAgeFilesLines
* Add error checking to readdir, telldir, and closedir calls in dir.cJeremy Evans2024-09-121-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Raise SystemCallError exception when these functions return an error. This changes behavior for the following case (found by the tests): ```ruby dir1 = Dir.new('..') dir2 = Dir.for_fd(dir1.fileno) dir1.close dir2.close ``` The above code is basically broken, as `dir1.close` closed the file descriptor. The subsequent `dir2.close` call is undefined behavior. When run in isolation, it raises Errno::EBADF after the change, but if another thread opens a file descriptor between the `dir1.close` and `dir2.close` calls, the `dir2.close` call could close the file descriptor opened by the other thread. Raising an exception is much better in this case as it makes it obvious there is a bug in the code. For the readdir check, since the GVL has already been released, reacquire it rb_thread_call_with_gvl if an exception needs to be raised. Due to the number of closedir calls, this adds static close_dir_data and check_closedir functions. The close_dir_data takes a struct dir_data * and handles setting the dir entry to NULL regardless of failure. Fixes [Bug #20586] Co-authored-by: Nobuyoshi Nakada <nobu.nakada@gmail.com>
* Make Range#step to consistently use + for iteration (#7444)Victor Shepelev2024-08-181-1/+1
| | | | | | | | Make Range#step to consistently use + for iteration [Feature #18368] Previously, non-numerics expected step to be integer, and iterated with begin#succ, skipping over step value steps. Since this commit, numeric and non-numeric iteration behaves the same way, by using + operator.
* [Feature #20244] Issue a single `Warning.warn` callNobuyoshi Nakada2024-03-141-0/+20
| | | | | Make the entire series of message lines a multiline string so that the `Warning.warn` hook can receive them in a single call.
* [Feature #20244] Show the conflicting another chdir blockNobuyoshi Nakada2024-03-141-11/+14
|
* Make Dir#chdir never yield args, and return block return valueJeremy Evans2023-12-111-2/+8
| | | | | If no block is given, return 0 instead of nil for consistency with Dir.chdir and Dir.fchdir.
* [Feature #19244] Windows: Prefer USERPROFILE over HOMEPATH on startup as wellLars Kanis2023-10-271-0/+34
|
* Add Dir.for_fdJeremy Evans2023-03-241-0/+15
| | | | | | | This returns a Dir instance for the given directory file descriptor. If fdopendir is not supported, this raises NotImplementedError. Implements [Feature #19347]
* Add Dir#chdirJeremy Evans2023-03-241-1/+40
| | | | | | This uses Dir.fchdir if supported, or Dir.chdir otherwise. Implements [Feature #19347]
* Test of environment variables order for HOME on WindowsNobuyoshi Nakada2022-12-241-0/+18
|
* Add Dir.home test with encodingNobuyoshi Nakada2022-12-241-0/+10
|
* Extract setup of environment variablesNobuyoshi Nakada2022-12-241-13/+12
|
* [Bug #19042] Fix Dir.glob brace with '/'Hiroshi Shirosaki2022-10-181-0/+14
| | | | | | | | Dir.glob brace pattern with '/' after '**' does not match paths in recursive expansion process. We expand braces with '/' before expanding a recursive. Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
* Use omit instead of skip: test/ruby/**/*.rbHiroshi SHIBATA2022-01-041-3/+3
|
* Expect bool as `sort:` option at glob [Feature #18287]Nobuyoshi Nakada2021-11-181-0/+6
|
* Add the test of `Dir.glob` when `sort: true` is given explicitlyNobuyoshi Nakada2021-11-051-0/+2
|
* Prefer qualified names under ThreadNobuyoshi Nakada2021-06-291-1/+1
|
* Actually ignore FNM_CASEFOLD flag in Dir.globJeremy Evans2021-06-241-0/+11
| | | | | | | | | This was already documented as being ignored, but it wasn't being ignored, causing an issue in a particular case where a UTF-8 pattern was provided and a filename was tested that wasn't valid UTF-8. Fixes [Bug #14456]
* Remove "." and ".." from Dir.glob with FNM_DOTMATCH [Bug #17280]Nobuyoshi Nakada2021-01-121-1/+4
| | | | Co-authored-by: Jeremy Evans <code@jeremyevans.net>
* dir.c: chdir conflict should raise only when called in different threadYusuke Endoh2020-12-241-3/+16
| | | | | ... and keep it as a warning (like 2.7) when it is called in the same thread. [Bug #15661]
* test/ruby: Check warning messages at a finer granularityNobuyoshi Nakada2020-12-171-1/+0
| | | | | Instead of suppressing all warnings wholly in each test scripts by setting `$VERBOSE` to `nil` in `setup` methods.
* Made method-local instance variables local variablesNobuyoshi Nakada2020-12-081-24/+16
|
* Switch conflicting chdir warning to RuntimeErrorJeremy Evans2020-09-281-2/+28
| | | | | | | | The documentation already stated this was an error in one case (when it was previously a warning). Describe the other case, where chdir without block is called inside block passed to chdir. Fixes [Bug #15661]
* Assertions for basic use of `encoding:` optionNobuyoshi Nakada2020-04-111-0/+14
|
* Assertions for enumerators of DirNobuyoshi Nakada2020-04-111-0/+12
|
* Removed unnecessary `to_a` callNobuyoshi Nakada2020-04-111-1/+1
| | | | `Dir.entries` returns an array.
* Fixed crash when argument array is modifiedNobuyoshi Nakada2020-03-251-0/+12
|
* Sort globbed results by default [Feature #8709]Nobuyoshi Nakada2020-01-191-30/+71
| | | | | | Sort the results which matched single wildcard or character set in binary ascending order, unless `sort: false` is given. The order of an Array of pattern strings and braces are not affected.
* Removed useless sorts of lists generated from literalsNobuyoshi Nakada2020-01-181-4/+4
|
* Make test-all and test-spec runnable on AndroidYusuke Endoh2019-09-091-0/+1
| | | | | | Calling some syscall functions such as Dir.chroot causes SIGSYS instead of EPERM on Android. This change skips all tests that stops the test-suite run.
* Prohibit nul-separated glob pattern [Feature #14643] (#2419)Nobuyoshi Nakada2019-09-021-3/+2
|
* dir.c: fix Dir.glob starts with braceshirosaki2019-03-211-0/+8
| | | | | | | | * dir.c (ruby_glob0): expand braces if a glob pattern starts with brace. [ruby-core:91728] [Bug #15649] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* do not close FSs explicitly.ko12019-03-031-2/+2
| | | | | | | | | | * test/ruby/test_dir.rb: r67159 closes all files explicitly but this change breaks attempt of this test introduced at r56467. Try another solution which removes all references from an Array with `#clear`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* close opened files explicitlyko12019-03-031-1/+4
| | | | | | | | to fix a test failure like http://ci.rvm.jp/results/trunk-theap-asserts@silicon-docker/1804207 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: fix Dir.glob with braces and matching dirshirosaki2019-01-161-0/+14
| | | | | | | | | | | * dir.c (join_path_from_pattern): add the last slash for directory matching. * test/ruby/test_dir.rb (test_glob_recursive_directory): add a test for above. [ruby-core:91110] [Bug #15540] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix r65926 test_dir.rb for windows (tilde)k0kubun2018-11-241-1/+2
| | | | | | | | [Fix GH-2022] From: MSP-Greg <greg.mpls@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* split each assert_nothing_raisednobu2018-11-231-3/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Use File.expand_path("~username") instead of ENV["HOME"]naruse2018-11-221-2/+1
| | | | | | | | | File.expand_path("~username") uses getpwnam() independently from Dir.home. [Bug #15324] From: Chris Seaton <chris@chrisseaton.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: fix directory globnobu2018-07-091-1/+23
| | | | | | | | | * dir.c (glob_helper): fix directory glob which resulted in lacking the first byte. adjust the length of basename to be appended as well as removing the heading path, not the length of the joined path. [ruby-dev:50588] [Bug #14899] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: warning for NULnobu2018-04-191-2/+4
| | | | | | | * dir.c (rb_push_glob): warn NUL-separated glob patterns. [Feature #14643] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: check NUL bytesnobu2018-03-281-0/+8
| | | | | | | | | | * dir.c (GlobPathValue): should be used in rb_push_glob only. other methods should use FilePathValue. https://hackerone.com/reports/302338 * dir.c (rb_push_glob): expand GlobPathValue git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: Dir#each_childnobu2018-01-241-0/+3
| | | | | | | * dir.c (dir_each_child_m): new instance methods Dir#each_child and Dir#children. [Feature #13969] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "Dir.glob with FNM_EXTGLOB is optimized [Feature #13873]"naruse2017-10-271-4/+4
| | | | | | | | This reverts commit r60341,r60342,r60344,r60345. Breaking compabitility of the order of result breaks many tests. To avoid such effort to fix tests, the order should be kept. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sort test resultnaruse2017-10-221-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sort the test resultnaruse2017-10-221-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Dir.glob with FNM_EXTGLOB is optimized [Feature #13873]naruse2017-10-221-1/+1
| | | | | | The order of resulted array is changed in some cases. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "ignore server side error"naruse2017-10-211-1/+1
| | | | | | This reverts commit r60314. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60315 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ignore server side errornaruse2017-10-211-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "Dir.glob with FNM_EXTGLOB is optimized [Feature #13873]"naruse2017-10-211-1/+1
| | | | | | This reverts commit r60253 because it causes on error on Linux. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Dir.glob with FNM_EXTGLOB is optimized [Feature #13873]naruse2017-10-211-1/+1
| | | | | | The order of resulted array is changed in some cases. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Use the same variable name as in dir.ckazu2017-08-031-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e