* [ruby-core:54031] Question about r39944
@ 2013-04-05 16:25 Aaron Patterson
2013-04-05 18:28 ` [ruby-core:54032] " NARUSE, Yui
2013-04-08 2:16 ` [ruby-core:54091] " fujioka
0 siblings, 2 replies; 9+ messages in thread
From: Aaron Patterson @ 2013-04-05 16:25 UTC (permalink / raw
To: ruby-core
[-- Attachment #1: Type: text/plain, Size: 242 bytes --]
Hi,
@xibbar changed test/psych/** to do "require_relative 'helper'". Why?
The "test" directory should be on the load path, so `require_relative`
does not seem necessary.
Thanks!
--
Aaron Patterson
http://tenderlovemaking.com/
[-- Attachment #2: Type: application/pgp-signature, Size: 487 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-core:54032] Re: Question about r39944
2013-04-05 16:25 [ruby-core:54031] Question about r39944 Aaron Patterson
@ 2013-04-05 18:28 ` NARUSE, Yui
2013-04-05 21:39 ` [ruby-core:54035] " Henry Maddocks
2013-04-05 21:51 ` [ruby-core:54036] " Aaron Patterson
2013-04-08 2:16 ` [ruby-core:54091] " fujioka
1 sibling, 2 replies; 9+ messages in thread
From: NARUSE, Yui @ 2013-04-05 18:28 UTC (permalink / raw
To: ruby-core@ruby-lang.org
[-- Attachment #1: Type: text/plain, Size: 530 bytes --]
Even if test directory should be on the load path on test-all, you should
make tests standalone
because we sometimes run tests without test-all to debug it as small set as
it can be.
2013/4/6 Aaron Patterson <tenderlove@ruby-lang.org>
> Hi,
>
> @xibbar changed test/psych/** to do "require_relative 'helper'". Why?
> The "test" directory should be on the load path, so `require_relative`
> does not seem necessary.
>
> Thanks!
>
> --
> Aaron Patterson
> http://tenderlovemaking.com/
>
--
NARUSE, Yui <naruse@airemix.jp>
[-- Attachment #2: Type: text/html, Size: 1147 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-core:54035] Re: Question about r39944
2013-04-05 18:28 ` [ruby-core:54032] " NARUSE, Yui
@ 2013-04-05 21:39 ` Henry Maddocks
2013-04-05 21:51 ` [ruby-core:54036] " Aaron Patterson
1 sibling, 0 replies; 9+ messages in thread
From: Henry Maddocks @ 2013-04-05 21:39 UTC (permalink / raw
To: ruby-core
On 6/04/2013, at 7:28 AM, "NARUSE, Yui" <naruse@airemix.jp> wrote:
> Even if test directory should be on the load path on test-all, you should make tests standalone
> because we sometimes run tests without test-all to debug it as small set as it can be.
Isn't that what the -I command line argument is for?
ruby -Itest test/path/to/test.rb
Henry
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-core:54036] Re: Question about r39944
2013-04-05 18:28 ` [ruby-core:54032] " NARUSE, Yui
2013-04-05 21:39 ` [ruby-core:54035] " Henry Maddocks
@ 2013-04-05 21:51 ` Aaron Patterson
2013-04-05 23:41 ` [ruby-core:54040] " Tanaka Akira
1 sibling, 1 reply; 9+ messages in thread
From: Aaron Patterson @ 2013-04-05 21:51 UTC (permalink / raw
To: ruby-core
Can you give me a specific example of how you're running the tests? It
seems we should make sure the load path is always correct rather than
couple the source file to it's location in the file system.
On Sat, Apr 06, 2013 at 03:28:34AM +0900, NARUSE, Yui wrote:
> Even if test directory should be on the load path on test-all, you should
> make tests standalone
> because we sometimes run tests without test-all to debug it as small set as
> it can be.
>
>
>
> 2013/4/6 Aaron Patterson <tenderlove@ruby-lang.org>
>
> > Hi,
> >
> > @xibbar changed test/psych/** to do "require_relative 'helper'". Why?
> > The "test" directory should be on the load path, so `require_relative`
> > does not seem necessary.
> >
> > Thanks!
> >
> > --
> > Aaron Patterson
> > http://tenderlovemaking.com/
> >
>
>
>
> --
> NARUSE, Yui <naruse@airemix.jp>
--
Aaron Patterson
http://tenderlovemaking.com/
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-core:54040] Re: Question about r39944
2013-04-05 21:51 ` [ruby-core:54036] " Aaron Patterson
@ 2013-04-05 23:41 ` Tanaka Akira
2013-04-06 0:23 ` [ruby-core:54044] " Rodrigo Rosenfeld Rosas
2013-04-06 0:37 ` [ruby-core:54045] " Aaron Patterson
0 siblings, 2 replies; 9+ messages in thread
From: Tanaka Akira @ 2013-04-05 23:41 UTC (permalink / raw
To: ruby-core
2013/4/6 Aaron Patterson <tenderlove@ruby-lang.org>:
> Can you give me a specific example of how you're running the tests? It
> seems we should make sure the load path is always correct rather than
> couple the source file to it's location in the file system.
In general, require_relative is a good tool to require a utility
library for a test.
For example, test/objspace/test_objspace.rb uses test/ruby/envutil.rb.
But I want to invoke the test as follows.
% ./ruby test/objspace/test_objspace.rb
Since test/ruby/ is not a standard library location,
the load path doesn't contain it.
So, if "require" is used instead of "require_relative",
I need to invoke ruby with -Itest/ruby or test_objspace.rb needs to
tweak the load path which is irritative.
--
Tanaka Akira
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-core:54044] Re: Question about r39944
2013-04-05 23:41 ` [ruby-core:54040] " Tanaka Akira
@ 2013-04-06 0:23 ` Rodrigo Rosenfeld Rosas
2013-04-06 0:37 ` [ruby-core:54045] " Aaron Patterson
1 sibling, 0 replies; 9+ messages in thread
From: Rodrigo Rosenfeld Rosas @ 2013-04-06 0:23 UTC (permalink / raw
To: ruby-core
Em 05-04-2013 20:41, Tanaka Akira escreveu:
> 2013/4/6 Aaron Patterson<tenderlove@ruby-lang.org>:
>> Can you give me a specific example of how you're running the tests? It
>> seems we should make sure the load path is always correct rather than
>> couple the source file to it's location in the file system.
> In general, require_relative is a good tool to require a utility
> library for a test.
>
> For example, test/objspace/test_objspace.rb uses test/ruby/envutil.rb.
> But I want to invoke the test as follows.
>
> % ./ruby test/objspace/test_objspace.rb
>
> Since test/ruby/ is not a standard library location,
> the load path doesn't contain it.
>
> So, if "require" is used instead of "require_relative",
> I need to invoke ruby with -Itest/ruby or test_objspace.rb needs to
> tweak the load path which is irritative.
I agree. I tend to often use require_relative in my specs very often and
I do believe it is a good pattern. Actually I also use require_relative
in some libraries as well. I find it easier in lots of cases to be
sure/explicit about what file I'm loading and avoid any search-path
related confusion.
The reason most tests use require is probably because require_relative
didn't exist until recently.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-core:54045] Re: Question about r39944
2013-04-05 23:41 ` [ruby-core:54040] " Tanaka Akira
2013-04-06 0:23 ` [ruby-core:54044] " Rodrigo Rosenfeld Rosas
@ 2013-04-06 0:37 ` Aaron Patterson
2013-04-06 1:20 ` [ruby-core:54048] " Tanaka Akira
1 sibling, 1 reply; 9+ messages in thread
From: Aaron Patterson @ 2013-04-06 0:37 UTC (permalink / raw
To: ruby-core
On Sat, Apr 06, 2013 at 08:41:46AM +0900, Tanaka Akira wrote:
> 2013/4/6 Aaron Patterson <tenderlove@ruby-lang.org>:
> > Can you give me a specific example of how you're running the tests? It
> > seems we should make sure the load path is always correct rather than
> > couple the source file to it's location in the file system.
>
> In general, require_relative is a good tool to require a utility
> library for a test.
>
> For example, test/objspace/test_objspace.rb uses test/ruby/envutil.rb.
Ok. So if you move `test_objspace.rb` to 'test/foo/bar', now you have
to modify the source of `test_objspace.rb`. Why does the source file
depend on the file system location?
> But I want to invoke the test as follows.
>
> % ./ruby test/objspace/test_objspace.rb
>
> Since test/ruby/ is not a standard library location,
> the load path doesn't contain it.
>
> So, if "require" is used instead of "require_relative",
> I need to invoke ruby with -Itest/ruby or test_objspace.rb needs to
> tweak the load path which is irritative.
export RUBYOPT='-Itest/ruby'
;-)
--
Aaron Patterson
http://tenderlovemaking.com/
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-core:54048] Re: Question about r39944
2013-04-06 0:37 ` [ruby-core:54045] " Aaron Patterson
@ 2013-04-06 1:20 ` Tanaka Akira
0 siblings, 0 replies; 9+ messages in thread
From: Tanaka Akira @ 2013-04-06 1:20 UTC (permalink / raw
To: ruby-core
2013/4/6 Aaron Patterson <tenderlove@ruby-lang.org>:
> Ok. So if you move `test_objspace.rb` to 'test/foo/bar', now you have
> to modify the source of `test_objspace.rb`. Why does the source file
> depend on the file system location?
I think it is better than other ways.
> export RUBYOPT='-Itest/ruby'
It is problematic on multi user system.
Consider someone creates /tmp/test/ruby/rubygems.rb as "puts 'hahaha'" or
another dangerous program and you run ruby in /tmp.
--
Tanaka Akira
^ permalink raw reply [flat|nested] 9+ messages in thread
* [ruby-core:54091] Re: Question about r39944
2013-04-05 16:25 [ruby-core:54031] Question about r39944 Aaron Patterson
2013-04-05 18:28 ` [ruby-core:54032] " NARUSE, Yui
@ 2013-04-08 2:16 ` fujioka
1 sibling, 0 replies; 9+ messages in thread
From: fujioka @ 2013-04-08 2:16 UTC (permalink / raw
To: ruby-core
Hi aaron,
When I usually run the standalone test:
% ruby -e 'require "./test/psych/test_array.rb"'
but before my patch:
% ruby -e 'require "./test/psych/test_array.rb"'
/Users/fujioka/local/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in
`require': cannot load such file -- psych/helper (LoadError)
from
/Users/fujioka/local/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in
`require'
from /Users/fujioka/build/ruby/test/psych/test_array.rb:1:in `<top
(required)>'
from
/Users/fujioka/local/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in
`require'
from
/Users/fujioka/local/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in
`require'
from -e:1:in `<main>'
I think the test should pass without special option.
(2013/04/06 1:25), Aaron Patterson wrote:
> Hi,
>
> @xibbar changed test/psych/** to do "require_relative 'helper'". Why?
> The "test" directory should be on the load path, so `require_relative`
> does not seem necessary.
>
> Thanks!
>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-04-08 2:39 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-05 16:25 [ruby-core:54031] Question about r39944 Aaron Patterson
2013-04-05 18:28 ` [ruby-core:54032] " NARUSE, Yui
2013-04-05 21:39 ` [ruby-core:54035] " Henry Maddocks
2013-04-05 21:51 ` [ruby-core:54036] " Aaron Patterson
2013-04-05 23:41 ` [ruby-core:54040] " Tanaka Akira
2013-04-06 0:23 ` [ruby-core:54044] " Rodrigo Rosenfeld Rosas
2013-04-06 0:37 ` [ruby-core:54045] " Aaron Patterson
2013-04-06 1:20 ` [ruby-core:54048] " Tanaka Akira
2013-04-08 2:16 ` [ruby-core:54091] " fujioka
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).