summaryrefslogtreecommitdiff
path: root/test/pathname/test_pathname.rb
AgeCommit message (Collapse)Author
2022-04-21[ruby/pathname] Implement Pathname#lutimeAkinori MUSHA
https://github.com/ruby/pathname/commit/268cb5acff
2022-01-07[ruby/pathname] Make Pathname#each_entry return enumerator if called without ↵Jeremy Evans
block Fixes [Bug #18158] https://github.com/ruby/pathname/commit/914c726aa2
2021-09-07[ruby/pathname] Prefer omit over skipNobuyoshi Nakada
https://github.com/ruby/pathname/commit/abd0b91044
2021-08-31[Feature #16972] Add mode: option to Pathname#mkpathNobuyoshi Nakada
2021-03-28[ruby/pathname] Fix segfault of Pathname#splitKenichi Kamiya
Fix segmentation fault of Pathname#split when File.split returns non array value [Bug #17755] https://github.com/ruby/pathname/commit/e29b49e3b1 https://github.com/ruby/pathname/commit/1db7479a74
2021-03-28[ruby/pathname] Support Ruby 3.0Hiroshi SHIBATA
Update test/pathname/test_pathname.rb https://github.com/ruby/pathname/commit/29645187e0 https://github.com/ruby/pathname/commit/78584864de Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2021-01-29Forward keyword arguments for Pathname#each_line [Bug #17589]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4128
2021-01-12Remove "." and ".." from Dir.glob with FNM_DOTMATCH [Bug #17280]Nobuyoshi Nakada
Co-authored-by: Jeremy Evans <code@jeremyevans.net> Notes: Merged: https://github.com/ruby/ruby/pull/4052
2020-10-12Make the test suite pass on real Android/Termux environmentYusuke Endoh
Attempting to create a hard link raises EACCES
2020-09-14Optimize Pathname#relative? / absolute?Marc-Andre Lafortune
Notes: Merged: https://github.com/ruby/ruby/pull/2107
2020-06-21Prefer more descriptive assertion methodsNobuyoshi Nakada
2020-01-24brace the fact that lchmod(2) can EOPNOTSUPP卜部昌平
Musl libc has this function as a tiny wrapper of fchmodat(3posix). On the other hand Linux kernel does not support changing modes of a symlink. The operation always fails with EOPNOTSUPP. This fchmodat behaviour is defined in POSIX. We have to take care of such exceptions.
2019-11-18Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans
This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby. Notes: Merged: https://github.com/ruby/ruby/pull/2476
2019-11-18Warn on access/modify of $SAFE, and remove effects of modifying $SAFEJeremy Evans
This removes the security features added by $SAFE = 1, and warns for access or modification of $SAFE from Ruby-level, as well as warning when calling all public C functions related to $SAFE. This modifies some internal functions that took a safe level argument to no longer take the argument. rb_require_safe now warns, rb_require_string has been added as a version that takes a VALUE and does not warn. One public C function that still takes a safe level argument and that this doesn't warn for is rb_eval_cmd. We may want to consider adding an alternative method that does not take a safe level argument, and warn for rb_eval_cmd. Notes: Merged: https://github.com/ruby/ruby/pull/2476
2019-09-26Fix more keyword argument separation issues in PathnameJeremy Evans
Notes: Merged: https://github.com/ruby/ruby/pull/2484
2019-09-25Make rb_scan_args handle keywords more similar to Ruby methods (#2460)Jeremy Evans
Cfuncs that use rb_scan_args with the : entry suffer similar keyword argument separation issues that Ruby methods suffer if the cfuncs accept optional or variable arguments. This makes the following changes to : handling. * Treats as **kw, prompting keyword argument separation warnings if called with a positional hash. * Do not look for an option hash if empty keywords are provided. For backwards compatibility, treat an empty keyword splat as a empty mandatory positional hash argument, but emit a a warning, as this behavior will be removed in Ruby 3. The argument number check needs to be moved lower so it can correctly handle an empty positional argument being added. * If the last argument is nil and it is necessary to treat it as an option hash in order to make sure all arguments are processed, continue to treat the last argument as the option hash. Emit a warning in this case, as this behavior will be removed in Ruby 3. * If splitting the keyword hash into two hashes, issue a warning, as we will not be splitting hashes in Ruby 3. * If the keyword argument is required to fill a mandatory positional argument, continue to do so, but emit a warning as this behavior will be going away in Ruby 3. * If keyword arguments are provided and the last argument is not a hash, that indicates something wrong. This can happen if a cfunc is calling rb_scan_args multiple times, and providing arguments that were not passed to it from Ruby. Callers need to switch to the new rb_scan_args_kw function, which allows passing of whether keywords were provided. This commit fixes all warnings caused by the changes above. It switches some function calls to *_kw versions with appropriate kw_splat flags. If delegating arguments, RB_PASS_CALLED_KEYWORDS is used. If creating new arguments, RB_PASS_KEYWORDS is used if the last argument is a hash to be treated as keywords. In open_key_args in io.c, use rb_scan_args_kw. In this case, the arguments provided come from another C function, not Ruby. The last argument may or may not be a hash, so we can't set keyword argument mode. However, if it is a hash, we don't want to warn when treating it as keywords. In Ruby files, make sure to appropriately use keyword splats or literal keywords when calling Cfuncs that now issue keyword argument separation warnings through rb_scan_args. Also, make sure not to pass nil in place of an option hash. Work around Kernel#warn warnings due to problems in the Rubygems override of the method. There is an open pull request to fix these issues in Rubygems, but part of the Rubygems tests for their override fail on ruby-head due to rb_scan_args not recognizing empty keyword splats, which this commit fixes. Implementation wise, adding rb_scan_args_kw is kind of a pain, because rb_scan_args takes a variable number of arguments. In order to not duplicate all the code, the function internals need to be split into two functions taking a va_list, and to avoid passing in a ton of arguments, a single struct argument is used to handle the variables previously local to the function. Notes: Merged-By: jeremyevans <code@jeremyevans.net>
2019-09-21Make Kernel#{Pathname,BigDecimal,Complex} return argument if given correct typeJeremy Evans
This is how Kernel#{Array,String,Float,Integer,Hash,Rational} work. BigDecimal and Complex instances are always frozen, so this should not cause backwards compatibility issues for those. Pathname instances are not frozen, so potentially this could cause backwards compatibility issues by not returning a new object. Based on a patch from Joshua Ballanco, some minor changes by me. Fixes [Bug #7522] Notes: Merged: https://github.com/ruby/ruby/pull/2473
2019-09-09Make test-all and test-spec runnable on AndroidYusuke Endoh
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.
2019-07-14Delegates 3 arguments for Pathname.glob.Tanaka Akira
Thanks for the patch by pocke (Masataka Kuwabara) [Feature #14405].
2019-02-22STATX_BTIME depends on filesystemsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-20Do not test File class methodnobu
It fails by EPERM for unknown reason. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-20Skip EPERMnobu
Docker's default seccomp whitelist does not include statx syscall by the default. Skipt this error for now. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-20Try statx syscallnobu
* file.c (rb_file_s_birthtime): export for pathname to check if birthtime is supported. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-18Pathname#relative_path_from uses is_a?akr
I reconsidered because simpler code would have better maintainablity. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-16Pathname#relative_path_from compatible with mock.akr
[Fix GH-2049] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-13Pathname: Have #relative_path_from accept String argument.marcandre
[Fix GH-1975] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-10skip some tests so that no failure occurs in root privilegemame
Some tests had failed on `sudo make test-all`, mainly because root can access any files regardless of permission. This change adds `skip` guards into such tests. Note that almost all tests in which `skip` guards is added, already have "windows" guard. This is because there is no support to avoid read access by owner on Windows. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-28`$SAFE` as a process global state. [Feature #14250]ko1
* vm_core.h (rb_vm_t): move `rb_execution_context_t::safe_level` to `rb_vm_t::safe_level_` because `$SAFE` is a process (VM) global state. * vm_core.h (rb_proc_t): remove `rb_proc_t::safe_level` because `Proc` objects don't need to keep `$SAFE` at the creation. Also make `is_from_method` and `is_lambda` as 1 bit fields. * cont.c (cont_restore_thread): no need to keep `$SAFE` for Continuation. * eval.c (ruby_cleanup): use `rb_set_safe_level_force()` instead of access `vm->safe_level_` directly. * eval_jump.c: End procs `END{}` doesn't keep `$SAFE`. * proc.c (proc_dup): removed and introduce `rb_proc_dup` in vm.c. * safe.c (rb_set_safe_level): don't check `$SAFE` 1 -> 0 changes. * safe.c (safe_setter): use `rb_set_safe_level()`. * thread.c (rb_thread_safe_level): `Thread#safe_level` returns `$SAFE`. It should be obsolete. * transcode.c (load_transcoder_entry): `rb_safe_level()` only returns 0 or 1 so that this check is not needed. * vm.c (vm_proc_create_from_captured): don't need to keep `$SAFE` for Proc. * vm.c (rb_proc_create): renamed to `proc_create`. * vm.c (rb_proc_dup): moved from proc.c. * vm.c (vm_invoke_proc): do not need to set and restore `$SAFE` for `Proc#call`. * vm_eval.c (rb_eval_cmd): rename a local variable to represent clearer meaning. * lib/drb/drb.rb: restore `$SAFE`. * lib/erb.rb: restore `$SAFE`, too. * test/lib/leakchecker.rb: check `$SAFE == 0` at the end of tests. * test/rubygems/test_gem.rb: do not set `$SAFE = 1`. * bootstraptest/test_proc.rb: catch up this change. * spec/ruby/optional/capi/string_spec.rb: ditto. * test/bigdecimal/test_bigdecimal.rb: ditto. * test/fiddle/test_func.rb: ditto. * test/fiddle/test_handle.rb: ditto. * test/net/imap/test_imap_response_parser.rb: ditto. * test/pathname/test_pathname.rb: ditto. * test/readline/test_readline.rb: ditto. * test/ruby/test_file.rb: ditto. * test/ruby/test_optimization.rb: ditto. * test/ruby/test_proc.rb: ditto. * test/ruby/test_require.rb: ditto. * test/ruby/test_thread.rb: ditto. * test/rubygems/test_gem_specification.rb: ditto. * test/test_tempfile.rb: ditto. * test/test_tmpdir.rb: ditto. * test/win32ole/test_win32ole.rb: ditto. * test/win32ole/test_win32ole_event.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12Add FrozenError as a subclass of RuntimeErrorshyouhei
FrozenError will be used instead of RuntimeError for exceptions raised when there is an attempt to modify a frozen object. The reason for this change is to differentiate exceptions related to frozen objects from generic exceptions such as those generated by Kernel#raise without an exception class. From: Jeremy Evans <code@jeremyevans.net> Signed-off-by: Urabe Shyouhei <shyouhei@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22Fixed misspelling words.hsbt
These are detected by https://github.com/client9/misspell git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21test_pathname.rb#test_open should care about umaskkosaki
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21Pathname#glob method implemented.akr
[ruby-core:49373] [Feature #7360] proposed by Alexander E. Fischer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-16pathname.rb: UNC root pathname needs a separatornobu
* ext/pathname/lib/pathname.rb (Pathname#plus): UNC root pathname needs a separator. File.basename returns "/" on UNC root, as well as sole drive letter, even if it does not end with a separator. [ruby-core:80900] [Bug #13515] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-05Pathname#empty? implemented.akr
* ext/pathname/pathname.c (Pathname#empty?): New method. [ruby-core:76404] [Feature#12596] Proposed by John Backus. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-10* lib/open-uri.rb: Remove indicator for "frozen_string_literal: true".akr
* lib/pp.rb: Ditto. * lib/prettyprint.rb: Ditto. * lib/resolv.rb: Ditto. * lib/securerandom.rb: Ditto. * lib/tmpdir.rb: Ditto. * lib/unicode_normalize/tables.rb: Ditto. * test/net/ftp/test_buffered_socket.rb: Ditto. * test/net/ftp/test_mlsx_entry.rb: Ditto. * test/open-uri/test_open-uri.rb: Ditto. * test/open-uri/test_ssl.rb: Ditto. * test/pathname/test_pathname.rb: Ditto. * test/test_pp.rb: Ditto. * test/test_prettyprint.rb: Ditto. * tool/transcode-tblgen.rb: Ditto. * ext/pathname/lib/pathname.rb: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-05Put an line before "frozen_string_literal: true" for emacs.akr
https://bugs.ruby-lang.org/issues/8976#note-49 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52052 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-05specify frozen_string_literal: true.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-29test_pathname.rb: fix exceptionnobu
* test/pathname/test_pathname.rb (has_symlink): now raises ENOENT instead of TypeError when symlink is available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-29test: try File.symlink with invalid pathsnobu
* test (have_symlink?): try File.symlink with invalid paths to test the administrator privilege, nil just raises an ArgumentError before trying the actual API. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-28test: File.symlink needs administrator privilegenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-26test_pathname.rb: skip EACCESnobu
* test/pathname/test_pathname.rb (test_realpath): skip EACCES if changing mode of a directory may have no effect. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-17remove unnecessary enumerator requiresnormal
* lib/rinda/tuplespace.rb: remove enumerator require * test/pathname/test_pathname.rb: ditto Related to https://bugs.ruby-lang.org/issues/10902 but not a complete fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-14* ext/pathname/lib/pathname.rb (descend): Blockless form supported.akr
(ascend): Ditto. [ruby-core:68820] [Feature #11052] Patch by Piotr Szotkowski. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-13* test/lib/envutil.rb: Moved from test/ruby/.akr
* test/lib/find_executable.rb: Ditto. * test/lib/memory_status.rb: Ditto. * test/lib/test/unit.rb: require envutil. * test/: Don't require envutil in test files. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-15pathname.rb: fix a Pathname#relative_path_from crash onnobu
* ext/pathname/lib/pathname.rb (SAME_PATHS): Pathname#relative_path_from uses String#casecmp to compare strings on case-insensitive filesystem platforms (e.g., Windows). This can return nil for strings with different encodings, and the code previously assumed that it always returned a Fixnum. [Fix GH-713] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-04* test/pathname/test_pathname.rb: added testcase for Pathname#mountpoint.hsbt
[fix GH-709] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-28* ext/pathname/pathname.c (path_birthtime): New method,akr
Pathname#birthtime. Proposed by Kazuhiro NISHIYAMA. [ruby-dev:48232] [Feature #9857] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-05* ext/pathname/lib/pathname.rb (cleanpath_aggressive): make allakr
separators File::SEPARATOR from File::ALT_SEPARATOR. Reported by Daniel Rikowski. Fixed by Nobuyoshi Nakada. [Bug #9618] * ext/pathname/lib/pathname.rb (cleanpath_conservative): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-05* ext/pathname/lib/pathname.rb (Pathname#/): Aliased to Pathname#+.akr
Suggested by Alexey Muranov. [ruby-core:61432] [Feature #9625] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-02Fix error with empty args.kazu
* ext/pathname/lib/pathname.rb (Pathname#join): Fix error with empty args. Reported by ko1 via IRC. * test/pathname/test_pathname.rb (TestPathname#test_join): Add the test for above case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e