Robert Klemme
11/2/2007 11:21:00 PM
On 02.11.2007 19:45, transfire@gmail.com wrote:
>
> On Nov 2, 1:30 pm, Robert Klemme <shortcut...@googlemail.com> wrote:
>> On 02.11.2007 15:21, transf...@gmail.com wrote:
>>
>>
>>
>>
>>
>>> On Nov 2, 5:40 am, "Robert Klemme" <shortcut...@googlemail.com> wrote:
>>>> 2007/11/2, Trans <transf...@gmail.com>:
>>>>> On Nov 1, 10:38 pm, "ara.t.howard" <ara.t.how...@gmail.com> wrote:
>>>>>> On Nov 1, 2007, at 6:18 PM, Trans wrote:
>>>>>>> Is there any way to ask a file what other file require/load 'd it? I
>>>>>>> imagine this has been asked before but I couldnt seem to find good
>>>>>>> terms to search for it.
>>>>>> cfp:~ > cat a.rb
>>>>>> p Kernel.requiree('main')
>>>>>> require 'b'
>>>>>> p Kernel.requiree('main')
>>>>>> BEGIN {
>>>>>> module Kernel
>>>>>> h = Hash.new
>>>>>> define_method(:requiree) do |of|
>>>>>> h[of]
>>>>>> end
>>>>>> r = method :require
>>>>>> define_method(:require) do |*a|
>>>>>> r.call *a
>>>>>> h[a.first] = caller
>>>>>> end
>>>>>> end
>>>>>> }
>>>>> Doh! Of course!
>>>>> Thanks Ara, that allowed me to figure it out.
>>>>> Turns out using 'load' to load the test rather then passing it
>>>>> straight to the ruby command, for some reason, gives test/unit the
>>>>> idea that it should go out and hunt for every file it can find with a
>>>>> test in it, including the copies in pkg/. That seems nuts me, but now
>>>>> I recall having to specify some parameter to reign test/unit in before
>>>>> --don't recall off hand what it was though. I'll have to track that
>>>>> down. In any case
>>>>> test_files.each do |file|
>>>>> sh %{ruby -e #{file} >> #{output}}
>>>>> end
>>>>> works, and that's good enough.
>>>> Just out of curiosity: why don't you use the test packages mechanisms
>>>> to run multiple tests (TestSuite)?
>>> I need to keep them isolated to make sure they all work on their own.
>>> How would you use the test/unit mechanisms to do that?
>> I am not sure what you mean by "on their own". Do you expect side
>> effects from test executions? From what I understand a TestCase should
>> ideally be independent and probably also side effect free. Then you
>> could easily lump them into a single TestSuite. The only issue I can
>> think of off the top of my head would be class instance variables and
>> required files which might yield different results - but then again,
>> relying on a specific require order is probably not a good idea in its own.
>
> There are a couple of aspects to isolating the tests. The main one is
> just making sure that a lib requires all the libs it needs to operate.
> Sometimes one lib gets loaded that requires something that another
> will use, so if they are both loaded you can't tell if they can act
> independently. Also, it is possible that some libs are meant as
> options, ie you use one or the other, but not both. I imagine there
> may well be other reasons. To be thorough, I run tests in isolation,
> in pairs, and as a whole. Really this has more to do with the nature
> of Facets. Facets isn't just a single library, it's a (lightly
> integrated) collection of them.
Makes perfectly sense to me. Thanks for the explanation. This would
make it interesting to have something like transactions built into the
interpreter - that way you could undefine stuff without having to
execute a new interpreter. I should go to bed now before I come up with
more silly ideas.
Kind regards
robert