ruby-dev (Japanese) list archive (unofficial mirror)
 help / color / mirror / Atom feed
From: watson1978@gmail•com
To: ruby-dev@ruby-lang.org
Subject: [ruby-dev:50096] [Ruby trunk Bug#13489] "make test-all" fails on macOS with case-sensitive filesystem
Date: Sun, 23 Apr 2017 06:37:00 +0000	[thread overview]
Message-ID: <redmine.journal-64438.20170423063700.a82753eaf8bf5065@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-13489.20170420135310@ruby-lang.org

Issue #13489 has been updated by watson1978 (Shizuo Fujita).


`Kernel.open` で使用している POSIX `open` が case-sensitive と非 case-sensitive で振る舞いが違うようです。`Kernel.open` の処理を抜き出したもので試してみました。

```c
#include <stdio.h>
#include <string.h>
#include <fcntl.h>

int main()
{
    const char *file = "file.test";
    char pathname[128] = {0};
    unsigned char sufix[] = { 0xef, 0xbb, 0xbf };
    int flags = O_CLOEXEC;
    mode_t mode = O_NOFOLLOW | O_FSYNC | O_EXLOCK | O_SHLOCK | O_NONBLOCK | O_RDWR;
    int ret;

    strcpy(pathname, file);
    memcpy(&pathname[strlen(file)], sufix, sizeof(sufix));

    ret = open(pathname, flags, mode);
    printf("ret = %d\n", ret);
    return 0;
}
```

非 case-sensitive では以下のような結果になります。

```
$ touch file.test
$ clang file.c
$ ./a.out
ret = 3
```

case-sensitive では以下のような結果になり、ファイルのオープンに失敗します。

```
$ touch file.test
$ clang file.c
$ ./a.out
ret = -1
```

該当のテストが、非 case-sensitive での振る舞いに依存しているように見受けられるので、
以下のように 非 case-sensitive のときだけ実行するようにしてはいかがでしょう?

```diff
diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb
index a3c2a4018a..07b58878e5 100644
--- a/test/ruby/test_file_exhaustive.rb
+++ b/test/ruby/test_file_exhaustive.rb
@@ -742,16 +742,26 @@ def test_expand_path
     end
     case RUBY_PLATFORM
     when /darwin/
-      ["\u{feff}", *"\u{2000}"..."\u{2100}"].each do |c|
-        file = regular_file + c
-        full_path = File.expand_path(file)
-        mesg = proc {File.basename(full_path).dump}
-        begin
-          open(file) {}
-        rescue
-          assert_equal(file, full_path, mesg)
-        else
-          assert_equal(regular_file, full_path, mesg)
+      case_sensitive_filesystem = false
+      begin
+        open(regular_file.upcase) {}
+      rescue
+        # if Kernel.open cannot open upcased file path, the test is running under case-sensitive filesystem
+        case_sensitive_filesystem = true
+      end
+
+      unless case_sensitive_filesystem
+        ["\u{feff}", *"\u{2000}"..."\u{2100}"].each do |c|
+          file = regular_file + c
+          full_path = File.expand_path(file)
+          mesg = proc {File.basename(full_path).dump}
+          begin
+            open(file) {}
+          rescue
+            assert_equal(file, full_path, mesg)
+          else
+            assert_equal(regular_file, full_path, mesg)
+          end
         end
       end
     end
```

----------------------------------------
Bug #13489: "make test-all" fails on macOS with case-sensitive filesystem
https://bugs.ruby-lang.org/issues/13489#change-64438

* Author: watson1978 (Shizuo Fujita)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
普段使用している macOS は HFS+ case-sensitive でフォーマットしています。
"make test-all" をそのマシン上で実行すると以下のようなエラーが発生し、
どうやら conftest.c でのコンパイルエラーが原因のようです。

conftest.c には

~~~
#include <Ruby/Ruby.h>
~~~

 という行が生成されるらしいのですが、
case-sensitive なファイルシステムではそのファイルパスを見つけることができません。

~~~
#include <ruby/ruby.h>
~~~
と生成されるべきかと思います。

https://github.com/ruby/ruby/blob/3e92b635fb5422207b7bbdc924e292e51e21f040/test/mkmf/test_framework.rb#L24-L33
の have_framework("Ruby") でinclude文が生成されているのかと思われます。


### エラーログ

~~~
$ make test-all -j 8

... snip ...

# Running tests:


Retrying...
[  3/121] TestMkmf::TestHaveFramework#test_multi_frameworks = 0.10 s
  1) Failure:
TestMkmf::TestHaveFramework#test_multi_frameworks [/Users/watson/src/ruby/test/mkmf/test_framework.rb:29]:
have_framework: checking for Ruby... -------------------- no

"clang -o conftest -I. -I/Users/watson/src/ruby/.ext/include/x86_64-darwin16 -I/Users/watson/src/ruby/include -I./test  -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -pipe conftest.c  -L. -L/Users/watson/src/ruby -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/openssl/lib     -lruby.2.5.0-static -framework CoreFoundation  -framework Ruby -lpthread -lgmp -ldl -lobjc "
conftest.c:3:10: fatal error: 'Ruby/Ruby.h' file not found
#include <Ruby/Ruby.h>
         ^
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <Ruby/Ruby.h>
4:
5: int main(void){return 0;}
/* end */

"clang -o conftest -I. -I/Users/watson/src/ruby/.ext/include/x86_64-darwin16 -I/Users/watson/src/ruby/include -I./test  -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -pipe conftest.c  -L. -L/Users/watson/src/ruby -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/openssl/lib     -lruby.2.5.0-static -framework CoreFoundation -ObjC -framework Ruby -lpthread -lgmp -ldl -lobjc "
conftest.c:3:10: fatal error: 'Ruby/Ruby.h' file not found
#include <Ruby/Ruby.h>
         ^
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <Ruby/Ruby.h>
4:
5: int main(void){return 0;}
/* end */

--------------------

try as Objective-C

[  4/121] TestMkmf::TestHaveFramework#test_single_framework = 0.10 s
  2) Failure:
TestMkmf::TestHaveFramework#test_single_framework [/Users/watson/src/ruby/test/mkmf/test_framework.rb:25]:
have_framework: checking for Ruby... -------------------- no

"clang -o conftest -I. -I/Users/watson/src/ruby/.ext/include/x86_64-darwin16 -I/Users/watson/src/ruby/include -I./test  -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -pipe conftest.c  -L. -L/Users/watson/src/ruby -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/openssl/lib     -lruby.2.5.0-static -framework CoreFoundation  -framework Ruby -lpthread -lgmp -ldl -lobjc "
conftest.c:3:10: fatal error: 'Ruby/Ruby.h' file not found
#include <Ruby/Ruby.h>
         ^
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <Ruby/Ruby.h>
4:
5: int main(void){return 0;}
/* end */

"clang -o conftest -I. -I/Users/watson/src/ruby/.ext/include/x86_64-darwin16 -I/Users/watson/src/ruby/include -I./test  -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -pipe conftest.c  -L. -L/Users/watson/src/ruby -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/openssl/lib     -lruby.2.5.0-static -framework CoreFoundation -ObjC -framework Ruby -lpthread -lgmp -ldl -lobjc "
conftest.c:3:10: fatal error: 'Ruby/Ruby.h' file not found
#include <Ruby/Ruby.h>
         ^
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <Ruby/Ruby.h>
4:
5: int main(void){return 0;}
/* end */

--------------------

try as Objective-C

[ 20/121] TestFileExhaustive#test_expand_path = 0.00 s
  3) Failure:
TestFileExhaustive#test_expand_path [/Users/watson/src/ruby/test/ruby/test_file_exhaustive.rb:750]:
"\uFEFF".
<"/var/folders/fs/gltv6wcd3m70hcgqcp2njt_80000gn/T/rubytest-file20170420-79876-gvlo69/file.test"> expected but was
<"/var/folders/fs/gltv6wcd3m70hcgqcp2njt_80000gn/T/rubytest-file20170420-79876-gvlo69/file.test">.

Finished tests in 223.305106s, 75.8290 tests/s, 9835.1132 assertions/s.
16933 tests, 2196231 assertions, 3 failures, 0 errors, 80 skips

ruby -v: ruby 2.5.0dev (2017-04-20 trunk 58401) [x86_64-darwin16]
make: *** [yes-test-all] Error 3
[trunk][~/src/ruby]$                                                                                                           rbenv:2.4.1
~~~




-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2017-04-23  5:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-13489.20170420135310@ruby-lang.org>
2017-04-20 13:53 ` [ruby-dev:50088] [Ruby trunk Bug#13489] "make test-all" fails on macOS with case-sensitive filesystem watson1978
2017-04-20 16:42 ` [ruby-dev:50089] [Ruby trunk Bug#13489][Feedback] " nobu
2017-04-20 17:13 ` [ruby-dev:50090] [Ruby trunk Bug#13489] " watson1978
2017-04-20 18:03 ` [ruby-dev:50091] " watson1978
2017-04-20 18:44 ` [ruby-dev:50092] " watson1978
2017-04-21  3:20 ` [ruby-dev:50093] " watson1978
2017-04-21  5:36 ` [ruby-dev:50094] " nobu
2017-04-22 11:05 ` [ruby-dev:50095] [Ruby trunk Bug#13489][Open] " watson1978
2017-04-23  6:37 ` watson1978 [this message]
2017-04-24 14:26 ` [ruby-dev:50098] [Ruby trunk Bug#13489] " nobu
2017-04-24 15:46 ` [ruby-dev:50099] " watson1978
2018-03-03 22:04 ` [ruby-dev:50489] " nagachika00
2018-03-18 14:34 ` [ruby-dev:50504] " usa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-64438.20170423063700.a82753eaf8bf5065@ruby-lang.org \
    --to=ruby-dev@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).