简体   繁体   English

Guard-rspec 和 ember 不能很好地协同工作

[英]Guard-rspec and ember does not works well together

Rails 4.2.7 guard-rspec 4.7.3 Rails 4.2.7 防护规范 4.7.3

Since I installed ember-cli-rails, the ember app prevent guard-spec to run and triggers hundreds of errors.由于我安装了 ember-cli-rails,ember 应用程序阻止了 guard-spec 的运行并触发了数百个错误。 Here is one error :这是一个错误:

Directory: /home/sylvain/dev/placedemarche/marketadmin/tmp/broccoli_merge_trees-output_path-rlX3b4rm.tmp/marketadmin/tests/unit

    is already being watched through: /home/sylvain/dev/placedemarche/marketadmin/tmp/broccoli_persistent_filterbabel__babel_marketadmin-output_path-Nv8C3Z67.tmp/marketadmin/tests/unit

    MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
    ** ERROR: directory is already being watched! **

I tried multiple things in the guardfile, even removing all of the watch :我在保护文件中尝试了多种方法,甚至删除了所有手表:

guard 'rspec',:cli => "--drb --format progress",all_after_pass: false do
  # ignore /marketadmin/ 
  # watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
  # watch(%r{^lib/(.+)\.rb$})     { |m| "spec/lib/#{m[1]}_spec.rb" }
  # watch('spec/spec_helper.rb')  { "spec" }

  # # Rails example
  # watch(%r{^app/(.+)\.rb$})                           { |m| "spec/#{m[1]}_spec.rb" }
  # watch(%r{^app/(.*)(\.erb|\.haml)$})                 { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
  # watch(%r{^app/controllers/(.+)_(controller)\.rb$})  { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
  # watch(%r{^spec/support/(.+)\.rb$})                  { "spec" }
  # watch('config/routes.rb')                           { "spec/routing" }
  # watch('app/controllers/application_controller.rb')  { "spec/controllers" }
  # # Capybara request specs
  # watch(%r{^app/views/(.+)/.*\.(erb|haml)$})          { |m| "spec/requests/#{m[1]}_spec.rb" }
end

I have tried multiple version of ignore, but it still fail.我尝试了多个版本的ignore,但它仍然失败。

The problem is basically that the tmp folder ember use to generate the preview app make guard go crazy.问题基本上是 tmp 文件夹 ember 用来生成预览应用程序让守卫发疯。 And it seems the guard ignore does not really make guard avoid the folder, it still scans it.似乎守卫忽略并没有真正让守卫避开该文件夹,它仍然会扫描它。

How can I make the guard file ignore the ember folder so that I can restore rspec-guard ?如何让保护文件忽略 ember 文件夹,以便我可以恢复 rspec-guard ?

EDIT编辑

I have edited the guardfile as following :我已经编辑了警卫文件如下:

guard 'rspec',:cli => "--drb --format progress",all_after_pass: false do
  ignore(%r{^marketadmin/(.+)}) 
end

It still fails with the following error (there is so many errors i had to set the terminal memory to 30 000 lines, 20 000 was not enough) :它仍然失败并出现以下错误(错误太多,我不得不将终端内存设置为 30 000 行,20 000 行不够):

18:24:39 - INFO - Guard::RSpec is running
18:24:39 - DEBUG - Hook :start_end executed for Guard::RSpec
D, [2017-08-24T18:25:00.166155 #20128] DEBUG -- : Waiting for processing to start...
18:25:00 - INFO - Guard is now watching at '/home/sylvain/dev/placedemarche'
18:25:00 - DEBUG - Start interactor
        ** ERROR: directory is already being watched! **

        Directory: /home/sylvain/dev/placedemarche/marketadmin/tmp/funnel-input_base_path-WVhWKrYs.tmp

        is already being watched through: /home/sylvain/dev/placedemarche/marketadmin/node_modules/qunit-notifications

        MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
        ** ERROR: directory is already being watched! **

        Directory: /home/sylvain/dev/placedemarche/marketadmin/tmp/funnel-input_base_path-ULeE6XMF.tmp

        is already being watched through: /home/sylvain/dev/placedemarche/marketadmin/app

        MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors

As I wrote in the IRC channel I didn't quite get, which subfolder you are trying to avoid ?正如我在 IRC 频道中所写的那样,我不太明白您要避开哪个子文件夹?

if I add to my guardfile at the top of the statements ignore(%r{frontend/(.+)}) , or in your case ignore(%r{marketadmin/(.+)}) it is quite successfully ignoring anything that happens in the frontend app.如果我在语句顶部添加我的保护文件ignore(%r{frontend/(.+)}) ,或者在你的情况下ignore(%r{marketadmin/(.+)})它非常成功地忽略了任何发生在前端应用程序中。

My Guardfile looks like :我的 Guardfile 看起来像:

guard :rspec, cmd: "bundle exec rspec" do
  require "guard/rspec/dsl"
  dsl = Guard::RSpec::Dsl.new(self)

  # Feel free to open issues for suggestions and improvements

  ignore(%r{frontend/(.+)})
  # RSpec files
  rspec = dsl.rspec
  watch(rspec.spec_helper) { rspec.spec_dir }
...

I have no experience with ember, and this broccoli thing that you are using , maybe the the problem is the configuration done there?我没有使用 ember 和您正在使用的西兰花的经验,也许问题在于那里的配置?

A helpful command can be:一个有用的命令可以是:

LISTEN_GEM_DEBUGGING=2 bundle exec guard -d

Hope the above helps.希望以上有帮助。 Cheers!干杯!

Update: Checked the errors you are seeing, and start seeing those on my mock setup, after installing the broccolli-funnel , which creates symlinks, and the listener gem that guard uses seem to have problems with them, which I don't have the time unfortunately today to analyze deeper... Maybe you can try a setup with ember being out of the rails dir.更新:检查你看到的错误,并开始在我的mock设置中看到那些,在安装broccolli-funnel ,它创建了符号链接,并且守卫使用的监听器 gem 似乎有问题,我没有不幸的是,今天有时间进行更深入的分析...也许您可以尝试将 ember 设置为超出 rails 目录的设置。

Guard now has a way to specify which directories to watch. Guard 现在有一种方法可以指定要监视的目录。 If you specify only the top-level directories that you need, leaving marketadmin or the name of your ember-cli subdirectory out of the list, then it will be ignored:如果您仅指定所需的顶级目录,而将marketadmin或您的 ember-cli 子目录的名称排除在列表之外,则它将被忽略:

  directories %w[app config lib spec features]

You may need additional directories depending on your application's setup, but the key is to exclude marketadmin .根据应用程序的设置,您可能需要其他目录,但关键是排除marketadmin

https://github.com/guard/guard/wiki/Guardfile-DSL---Configuring-Guard#directories https://github.com/guard/guard/wiki/Guardfile-DSL---Configuring-Guard#directories

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM