206 Commits
Author SHA1 Message Date
Hiroshi SHIBATAandClaude Opus 5.5 20f85b847f Remove unsupported platforms from the fileutils test platform checks
Ruby 1.9.1 dropped Windows CE, and Ruby 2.3 dropped OS/2 (emx) and Borland C.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 07:29:08 +09:00
Nobuyoshi Nakada cec5c97bf2 [ruby/fileutils] Add tests for FileUtils.options_of
Fix https://github.com/ruby/fileutils/pull/195

https://github.com/ruby/fileutils/commit/b2d9b72739
2026-09-22 14:58:36 +00:00
Nobuyoshi Nakada 6a2c832374 [ruby/fileutils] Add tests for FileUtils.options
Fix https://github.com/ruby/fileutils/pull/194

https://github.com/ruby/fileutils/commit/8b1efe473e
2026-09-22 14:58:36 +00:00
Nobuyoshi Nakada 7a34d74cf7 [ruby/fileutils] Add tests for FileUtils.have_option?
Fix https://github.com/ruby/fileutils/pull/193

https://github.com/ruby/fileutils/commit/6fd04f3cea
2026-09-22 14:58:36 +00:00
Nobuyoshi Nakada ca50175581 [ruby/fileutils] Add tests for FileUtils.commands
Fix https://github.com/ruby/fileutils/pull/192

https://github.com/ruby/fileutils/commit/df83e4bb04
2026-09-22 14:58:36 +00:00
Nobuyoshi Nakada ca76cabbb5 [ruby/fileutils] Add tests for FileUtils.collect_method
Fix https://github.com/ruby/fileutils/pull/191

https://github.com/ruby/fileutils/commit/ff78cfd3a4
2026-09-22 14:58:36 +00:00
Nobuyoshi Nakada a809b598b6 [ruby/fileutils] Use a missing target in the dangling symlink test
Windows reports self-referential links as existing, so use a missing
target to test a dangling link rather than a symbolic-link loop.

https://github.com/ruby/fileutils/commit/803fe3be07
2026-09-22 14:58:35 +00:00
Nobuyoshi Nakada c433f97790 [ruby/fileutils] Test symbolic links and verify the symlink alias
Cover single, multiple, and dangling links through `ln_s`, keeping
valid-link tests available where dangling links are unsupported.

Fix https://github.com/ruby/fileutils/pull/190

https://github.com/ruby/fileutils/commit/189aefb679
2026-09-22 14:58:35 +00:00
Nobuyoshi Nakada 52c1a16c89 [ruby/fileutils] Test file removal and verify the safe_unlink alias
Cover removal of existing and missing files through `rm_f` and
verify the `safe_unlink` alias.

Fix https://github.com/ruby/fileutils/pull/189

https://github.com/ruby/fileutils/commit/902bcce36b
2026-09-22 14:58:35 +00:00
Nobuyoshi Nakada 316b514d84 [ruby/fileutils] Test tree removal and verify the rmtree alias
Cover removal of existing and missing trees through `rm_rf` and
verify the `rmtree` alias.

Fix https://github.com/ruby/fileutils/pull/188

https://github.com/ruby/fileutils/commit/07cc858f16
2026-09-22 14:58:35 +00:00
Nobuyoshi Nakada 8e05d47401 [ruby/fileutils] Test file moves and verify the move alias
Check the result and effects of `mv` and verify the `move` alias.

Fix https://github.com/ruby/fileutils/pull/187

https://github.com/ruby/fileutils/commit/3bed6e74a1
2026-09-22 14:58:35 +00:00
Nobuyoshi Nakada 142a7c45c6 [ruby/fileutils] Test directory creation results and verify aliases
Check `mkdir_p` return values and verify the `makedirs` and `mkpath`
aliases without duplicating directory creation tests.

Fix https://github.com/ruby/fileutils/pull/186

https://github.com/ruby/fileutils/commit/72ff748e26
2026-09-22 14:58:35 +00:00
Nobuyoshi Nakada e657f57fd3 [ruby/fileutils] Test hard-link identity and verify the link alias
Verify that `ln` creates hard links and that `link` remains an alias.

Fix https://github.com/ruby/fileutils/pull/185

https://github.com/ruby/fileutils/commit/46db9d557b
2026-09-22 14:58:35 +00:00
Nobuyoshi Nakada b4188315ef [ruby/fileutils] Verify getwd as an alias of pwd
Avoid duplicating working-directory coverage already in `test_pwd`.

Fix https://github.com/ruby/fileutils/pull/183

https://github.com/ruby/fileutils/commit/d937a3d5ba
2026-09-22 14:58:35 +00:00
Nobuyoshi Nakada cd35f4b6a3 [ruby/fileutils] Test directory changes and verify the chdir alias
Cover directory changes, block behavior, and verbose output through
`cd`, and verify that `chdir` remains an alias.

Fix https://github.com/ruby/fileutils/pull/182

https://github.com/ruby/fileutils/commit/8476509760
2026-09-22 14:58:35 +00:00
Nobuyoshi Nakada 54f5107fa7 [ruby/fileutils] Add tests for FileUtils.compare_stream
Fix https://github.com/ruby/fileutils/pull/181

https://github.com/ruby/fileutils/commit/4b041318e9
2026-09-22 14:58:35 +00:00
Nobuyoshi Nakada 9ab645992d [ruby/fileutils] Add file comparison tests and verify aliases
Cover equal and different file contents in `test_cmp` and verify
that `compare_file` and `identical?` remain aliases.

Fix https://github.com/ruby/fileutils/pull/180
Fix https://github.com/ruby/fileutils/pull/184

https://github.com/ruby/fileutils/commit/01ac124ce4
2026-09-22 14:58:35 +00:00
Nobuyoshi Nakada 09a5f2ef36 [ruby/fileutils] Add tests for FileUtils.touch
Fix https://github.com/ruby/fileutils/pull/177

https://github.com/ruby/fileutils/commit/86278df2f7
2026-09-21 09:10:36 +00:00
Nobuyoshi Nakada cf2b80c06a [ruby/fileutils] Workaround for symlink bug on Windows
Fixed by ruby/ruby#17545.

https://github.com/ruby/fileutils/commit/9e957c2330
2026-09-21 08:58:29 +00:00
Nobuyoshi Nakada 647e6e61c1 [ruby/fileutils] Remove redundant condition
Since `Process.uid` returns `0` always on mingw or mswin, `root_in_posix?` returns `true` too.

https://github.com/ruby/fileutils/commit/d18fbf0c56
2026-09-21 03:07:33 +00:00
Jiaying Song be820c30cb [ruby/fileutils] Skip test_rm_r_no_permissions test under root
Skip the test_rm_r_no_permissions test under the root user, as deletion always succeeds.

Signed-off-by: Jiaying Song <jiaying.song.cn@windriver.com>

https://github.com/ruby/fileutils/commit/3c831389c5
2026-09-21 03:07:33 +00:00
TAKANO MitsuhiroandClaude Opus 4.8 508ee64264 [ruby/fileutils] Skip chown tests when the target group is not assignable
In user-namespace environments (e.g. ChromeOS Crostini) getgroups(2) can report supplementary groups such as the overflow GID 65534 (nobody) that a non-root process cannot actually chgrp a file to. TestFileUtils#setup built @groups straight from `[Process.gid] | Process.groups`, so the chown tests tried to chgrp to such a group and failed with EPERM instead of being skipped.

Filter @groups with a one-time capability probe down to the groups the process can actually assign, so the affected tests skip via their existing `return unless @groups[1]` guard when there is no usable second group.

https://github.com/ruby/fileutils/commit/8dc0266054

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-21 03:05:09 +00:00
Guilherme Carreiro 26f43967c8 [ruby/fileutils] Fix relative symlink target generation
https://github.com/ruby/fileutils/commit/7de921e801
2026-09-21 02:57:34 +00:00
Nobuyoshi Nakada 5a8e87cb2e [ruby/fileutils] Just the parent path of the destination symlink should exist
https://github.com/ruby/fileutils/commit/71225b1b46
2025-07-19 14:09:50 +00:00
Erik Berlin 4431ca5363 [ruby/fileutils] FileUtils.remove_dir checks directory
https://github.com/ruby/fileutils/commit/f0d7fc817b
2025-07-19 13:54:45 +00:00
Nobuyoshi Nakada 3dced7955c [ruby/fileutils] Use shorter symlink by real paths
https://github.com/ruby/fileutils/commit/277f7f2ff8
2025-07-19 13:47:48 +00:00
Nobuyoshi Nakada de68f22042 [ruby/fileutils] Fix up FileUtils#ln_sr
https://github.com/ruby/fileutils/commit/2836a164ed
2025-07-19 13:47:47 +00:00
Nobuyoshi Nakada cfe8263f41 [ruby/fileutils] Fix ln_sf with multiple sources and target_directory: false
In this case, an ArgumentError is now raised rather than ignoring the
option, just as GNU coreutils' `ln` would error on the command line.
Fixes https://github.com/ruby/fileutils/pull/128 as well.

https://github.com/ruby/fileutils/commit/4fc578a75f
2025-07-18 09:22:34 +00:00
Hiroshi SHIBATA 6bd5a51ab5 Removed Solaris conditions from test files
We no longer execute those files with Solaris platforms.
2025-04-02 16:24:47 +09:00
KJ Tsanaktsidis 8800127d80 Skip some tests which don't work under permissionless containers
When running as UID 0 but without CAP_DAC_OVERRIDE (for example, in a
docker container running with --uid 0 but --cap-drop=all), these tests
won't work because of hard-coded assumptions about what uid 0 can and
can't do.
2024-08-23 09:34:41 +10:00
Satadru Pramanik, DO, MPH, MEng 94aed6ece5 [ruby/fileutils] Add mkdir_p to FileUtils.install
(https://github.com/ruby/fileutils/pull/104)

* Add mkdir_p to FileUtils.install

* Adjust raise message.

* adjust raise language

* handle trailing slash in dest

* simplify

* Add tests
2023-02-10 03:37:39 +00:00
Nobuyoshi Nakada c6330cd32b [ruby/fileutils] [Feature #18925] Add ln_sr method and relative: option to ln_s
https://github.com/ruby/fileutils/commit/5116088d5c
2022-11-25 01:03:57 +00:00
Samuel WilliamsandLars Kanis ea8a7287e2 Add support for sockaddr_un on Windows. (#6513)
* Windows: Fix warning about undefined if_indextoname()

* Windows: Fix UNIXSocket on MINGW and make .pair more reliable

* Windows: Use nonblock=true for read tests with scheduler

* Windows: Move socket detection from File.socket? to File.stat

Add S_IFSOCK to Windows and interpret reparse points accordingly.
Enable tests that work now.

* Windows: Use wide-char functions to UNIXSocket

This fixes behaviour with non-ASCII characters.
It also fixes deletion of temporary UNIXSocket.pair files.

* Windows: Add UNIXSocket tests for specifics of Windows impl.

* Windows: fix VC build due to missing _snwprintf

Avoid usage of _snwprintf, since it fails linking ruby.dll like so:

  linking shared-library x64-vcruntime140-ruby320.dll
  x64-vcruntime140-ruby320.def : error LNK2001: unresolved external symbol snwprintf
  x64-vcruntime140-ruby320.def : error LNK2001: unresolved external symbol vsnwprintf_l

whereas linking miniruby.exe succeeds.

This patch uses snprintf on the UTF-8 string instead.

Also remove branch GetWindowsDirectoryW, since it doesn't work.

* Windows: Fix dangling symlink test failures

Co-authored-by: Lars Kanis <kanis@comcard.de>
2022-11-17 14:50:25 -08:00
Yusuke Endoh 72c7dba436 [ruby/fileutils] Revert "FileUtils.rm* methods swallows only Errno::ENOENT when force is true"
This reverts commit https://github.com/ruby/fileutils/commit/fa65d676ece9.

This caused some incompatibility problems in real-world cases.
https://bugs.ruby-lang.org/issues/18784#change-98927
https://bugs.ruby-lang.org/issues/18784#change-98967

https://github.com/ruby/fileutils/commit/42983c2553
2022-11-07 11:25:25 +00:00
Yusuke EndohandDavid Rodríguez 983115cf3c [ruby/fileutils] FileUtils.rm* methods swallows only Errno::ENOENT when force is true
... instead of any StandardError.

To behave like the standard `rm` command, it should only ignore
exceptions about not existing files, not every exception. This should
make debugging some errors easier, because the expectation is that `rm
-rf` will succeed if and only if, all given files (previously existent
or not) are removed. However, due to this exception swallowing, this is
not always the case.

From the `rm` man page

> COMPATIBILITY
>
> The rm utility differs from historical implementations in that the -f
> option only masks attempts to remove non-existent files instead of
> masking a large variety of errors.

https://github.com/ruby/fileutils/commit/fa65d676ec

Co-Authored-By: David Rodríguez <deivid.rodriguez@riseup.net>
2022-08-23 16:52:41 +09:00
Yusuke Endoh 96562a517d [ruby/fileutils] Narrow the scope of ensure
The ensure in postorder_traverse was added for [Bug #6756].
The intention was to try to delete the parent directory if it failed to
get the children. (It may be possible to delete the directory if it is
empty.)

However, the ensure region rescue'ed not only "failure to get children"
but also "failure to delete each child". Thus, the following raised
Errno::ENOTEMPTY, but we expect it to raise Errno::EACCES.

```
$ mkdir foo
$ touch foo/bar
$ chmod 555 foo
$ ruby -rfileutils -e 'FileUtils.rm_rf("foo")'
```

This changeset narrows the ensure region so that it rescues only
"failure to get children".

https://github.com/ruby/fileutils/commit/ec5d3b84ea
2022-08-23 16:52:40 +09:00
Yusuke Endoh 073f3b7e0a [ruby/fileutils] Fix the test permission of "test_rm_rf"
The test was added for [Bug #6756]. The ticket insisted
`FileUtils.rm_rf` should delete an empty directory even if its
permission is 000. However, the test tried to delete a directory with
permission 700.

https://github.com/ruby/fileutils/commit/d6c2ab2c01
2022-08-23 16:52:39 +09:00
David Rodríguez 70f69f8539 [ruby/fileutils] Fix mkdir_p hanging on Windows when trying to create a file on a offline drive
https://github.com/ruby/fileutils/commit/9cc6a082d7
2022-08-22 10:12:25 +09:00
Nobuyoshi NakadaandDavid Rodríguez ee1d2b276a [ruby/fileutils] Add an octal prefix to clarify to be octal
https://github.com/ruby/fileutils/commit/332025bc02

Co-Authored-By: David Rodríguez <deivid.rodriguez@riseup.net>
2022-07-19 17:33:44 +09:00
Jeremy Evans ab3cb29bd9 Avoid defining the same test class in multiple files
Should fix issues with parallel testing sometimes not running all
tests.

This should be viewed skipping whitespace changes.

Fixes [Bug #18731]
2022-04-22 15:00:16 -07:00
Hiroshi SHIBATA 940a19e4b3 Use Test::Unit::AssertionFailedError instead of MiniTest::Assertion for test-unit migration 2021-09-06 18:34:15 +09:00
Hiroshi SHIBATA 349e79bae0 Try to test with rake-13.0.2 again.
[ruby/fileutils] Make verbose output go to stdout instead of stderr

  This reverts commit 510df47f5f.
2020-12-19 16:53:18 +09:00
Yusuke Endoh 2fd71112fb Make the test suite pass on real Android/Termux environment
Attempting to create a hard link raises EACCES
2020-10-12 21:26:05 +09:00
Kazuhiro NISHIYAMA 6adbdb56ed Fix Encoding::CompatibilityError in FileUtils::Entry_#join 2020-06-22 18:34:24 +09:00
Kazuhiro NISHIYAMA 3a1e63e540 Fix typos 2020-06-22 18:23:58 +09:00
Kazuhiro NISHIYAMA 7ac6c967e4 Revert d231b8f95b and add debug print 2020-06-22 18:18:16 +09:00
Kazuhiro NISHIYAMA d231b8f95b Fix remove_entry error when path encoding is not compatible UTF-8 2020-06-22 17:11:24 +09:00
Kazuhiro NISHIYAMA 48d7ebe6fc Check symlink in tmpdir and do not use empty path 2020-06-22 17:11:23 +09:00
Nobuyoshi Nakada 510df47f5f Revert "[ruby/fileutils] Make verbose output go to stdout instead of stderr"
This reverts commit 7cddb844e6,
because the test of rake 13.0.1 is depending on the previous
behavior.
2020-06-12 19:02:50 +09:00
Nobuyoshi Nakada cc9ca468fe [ruby/fileutils] Fix #install with "X" mode option
`FileUtils#install` methed raises an unexpected `TypeError`, when
called with `mode:` option which has `"X"`.

```
$ ruby -rfileutils -e 'FileUtils.install("tmp/a", "tmp/b", mode: "o+X")'
/opt/local/lib/ruby/2.7.0/fileutils.rb:942:in `directory?': no implicit conversion of File::Stat into String (TypeError)
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:942:in `block (3 levels) in symbolic_modes_to_i'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:933:in `each_char'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:933:in `each'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:933:in `inject'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:933:in `block (2 levels) in symbolic_modes_to_i'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:931:in `each'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:931:in `each_slice'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:931:in `block in symbolic_modes_to_i'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:926:in `each'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:926:in `inject'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:926:in `symbolic_modes_to_i'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:973:in `fu_mode'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:883:in `block in install'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:1588:in `block in fu_each_src_dest'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:1604:in `fu_each_src_dest0'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:1586:in `fu_each_src_dest'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:877:in `install'
	from -e:1:in `<main>'
```

In spite of that `symbolic_modes_to_i` considers the `File::Stat`
`path` case at the beginning, in `"X"` case, `path` is passed to
`FileTest.directory?` method which requires a `String`.  In such
case, the mode in `path` should be examined instead.

https://github.com/ruby/fileutils/commit/af675af6b2
2020-06-12 18:38:49 +09:00