Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not picking up the library paths defined in the rake task? #86

Open
thomthom opened this issue Nov 26, 2021 · 2 comments
Open

Not picking up the library paths defined in the rake task? #86

thomthom opened this issue Nov 26, 2021 · 2 comments

Comments

@thomthom
Copy link

thomthom commented Nov 26, 2021

I got a Rake task for my tests that looks like this:

Rake::TestTask.new(:test) do |task|
  task.libs << 'tools/lib'
  task.libs << 'tools/tests'
  task.test_files = FileList['tools/tests/test_*.rb']
end

I originally configured the test runner as:

{
  "rubyTestExplorer.debugCommand": "bundle exec rdebug-ide",
  "rubyTestExplorer.minitestCommand": "bundle exec rake",
  "rubyTestExplorer.minitestDirectory": "./tools/tests/",
}

But that would not discover, run or debug any tests because the lib paths from the Rake task where not recognized.

I was however able to make it work by adding the lib paths again to each command:

{
  "rubyTestExplorer.debugCommand": "bundle exec rdebug-ide -I tools/lib -I tools/tests",
  "rubyTestExplorer.minitestCommand": "bundle exec rake -I tools/lib -I tools/tests",
  "rubyTestExplorer.minitestDirectory": "./tools/tests/",
}

Is this expected? Is there a different way I can set this up that avoids duplicating the paths in multiple places?

@thomthom
Copy link
Author

thomthom commented May 7, 2022

I ran into this again with another project. I have test helpers that via Rake I'm adding the paths to (task.libs <<). This works fine via bundle exec rake from the console, but not via this extension - even though it executes bundle exec rake.

Am I going against the grain here?

@kdiogenes
Copy link

Hey @thomthom!

In my test file I used required_relative "../lib/file.rb" and it works. From what I dig the problem is that the extension call one rake task defined by it that uses this code that requires the test files from our lib: https://github.com/connorshea/vscode-ruby-test-adapter/blob/main/ruby/vscode/minitest/tests.rb. From my understanding, it's not using/knowing your Rakefile.

If you want to use only require you need to make sure that something like the following $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) runs during the load of your test files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants