Running "rake test" with access to RBA routines.

edited May 2015 in Ruby Scripting

I wish to run "rake test" and have it be able to access RBA routines.
I have found no way to do this. I have tried having tests load .so files
that Klayout uses in order to access them without luck. I have tried running
rake from a ruby script invoked by Klayout at startup, as in:

...

Rake.application.run

...

This does start rake, but under the hood rake seems to do its jobs in shells that do not inherit access to RBA. Can anyone suggest an approach?

Thanks,
Dave

Comments

  • edited May 2015

    Hi Dave,

    KLayout is a not a Ruby extension, but instead Ruby is an extension to KLayout.

    I suspect that Rake starts the normal Ruby interpreter and that one does not know about the extensions that KLayout adds to the interpreter embedded into itself.

    I don't know what is the purpose of your Rake application - if you want to test your code, I can recommend the minitest framework. Here is how I use it:

    # Save this to test.rb and run it with "klayout -r test.rb -b"
    
    require "minitest/unit"
    
    class Test_db < MiniTest::Unit::TestCase
    
      def test_1_DEdge
    
        a = RBA::DEdge::new
        assert_equal("(0,0;0,0)", a.to_s)
    
        # ...
    
      end
    
    end
    
    res = MiniTest::Unit.new.run(["-n", "/^test_/"])
    
    exit 1 unless !res || res == 0
    

    Matthias

  • edited May 2015

    Matthias,

    You guessed correctly. I am trying to use unit testing.

    Yes, I am aware of the way ruby is embedded in KLayout - I compiled my own Ruby installation into KLayout and have written my own apps with embedded Ruby.
    It's a big reason for my attraction to KLayout (the code looks nice too!).
    I was just trying to keep consistent, where operations on the gem I am creating are invoked through rake.

    It looks like rake starts my own Ruby, but not as if it is embedded in KLayout.
    I was hoping a .so lib might be loaded into the rake-started Ruby such that it might see the RBA API.

    Thank you for the suggestion. I am accustomed to MiniTest. I'll see if I can re-write the rake test target to invoke KLayout on each test file.

    Dave

Sign In or Register to comment.