Re: Pass Command Line Parameter to getest test case

"Brian Heilig" <Brian.Heilig-tdt4z+Mb/[email protected]>
Newsgroups gmane.comp.lang.eiffel.gobo.general
Message-ID <[email protected]>
Eric Bezault wrote:
> You can use:
> 
> inherit
>     KL_ShARED_OPERATING_SYSTEM
> 
>     if operating_system.is_windows then ...
>     if operating_system.is_unix then ...
> 
> In fact I do something like that in ET_TEST_AST_PRINTER
> (in $GOBO/test/tools). getest can be given the following variable:
> 
>     getest -Dfull_test  ...
> 
> and then in ET_TEST_AST_PRINTER you can find:
> 
>     a_full_test :=  variables.has ("full_test")
> 
> In order for geant to pass the variable "full_test" to getest,
> I had to change $GOBO/misc/test.eant and add:
> 
>     <define name="full_test" value="true" if="${full_test}"/>
> 
> in the <getest> task of the "test" target. You could do the same
> with the variable "device" and values such as "COM1". However,
> having to edit $GOBO/misc/test.eant is not very nice. I don't
> know how we can try to avoid that.

Here's what I did...

In my build.eant file I added the following line:

<redefine target="test"/>

I then copied the "test" target from test.eant and added the 
following line to it:

<define name="device" value="${device}" if="${device}"/>

I think this is better than editing test.eant but still not great. 
Then in my test class I added the following code:

device_name: STRING is
		-- The device name used for testing.
	once
		if variables.has ("device") then
			Result := variables.value ("device")
		elseif operating_system.is_windows then
			Result := "COM1"
		else
			Result := "/dev/ttyS0"
		end
	ensure
		exists: Result /= Void
		set_from_command_line:
			variables.has ("device") implies
			Result.is_equal (variables.value ("device"))
		windows_default:
			not variables.has ("device") and
			operating_system.is_windows implies
			Result.is_equal ("COM1")
		posix_default:
			not variables.has ("device") and
			operating_system.is_unix implies
			Result.is_equal ("/dev/ttyS0")
	end

Thanks for the help,
Brian






To Post a message, send it to:   [email protected]
To Unsubscribe, send a blank message to: [email protected] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/gobo-eiffel/

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.