在本地我正在运行这些东西:
ruby: 2.5
bundler: 2.0.1
rspec: 3.8
我正在尝试使用 CircleCI 为多个文件运行测试,但没有任何记录的方法似乎有效。
TESTFILES=$(circleci tests glob "spec/**/*.rb" | circleci tests split --split-by=timings)
bundle exec rspec -- ${TESTFILES}
给出:
An error occurred while loading ./vendor/bundle/gems/diff-lcs-1.3/spec/change_spec.rb.
Failure/Error:
describe Diff::LCS::Change do
describe "an add" do
subject { described_class.new('+', 0, 'element') }
it { should_not be_deleting }
it { should be_adding }
it { should_not be_unchanged }
it { should_not be_changed }
it { should_not be_finished_a }
it { should_not be_finished_b }
end
NameError:
uninitialized constant Diff
# ./vendor/bundle/gems/diff-lcs-1.3/spec/change_spec.rb:5:in `<top (required)>'
所以我尝试了:
TESTFILES=$(circleci tests glob "**/*spec*.rb") # | circleci tests split --split-by=timings)
bundle exec rspec -- ${TESTFILES}
但这给出了同样的错误。
所以我改为
TESTFILES=$(circleci tests glob "**/*spec*.rb") # | circleci tests split --split-by=timings)
bundle exec rspec -- ${TESTFILES}
但这给了
/bin/bash: line 1: glob: command not found
所以我尝试只使用 find
TESTFILES=$(find . -name "*_spec.rb")
但这又回到了相同的原始信息:
An error occurred while loading ./vendor/bundle/gems/diff-lcs-1.3/spec/lcs_spec.rb.
Failure/Error:
describe Diff::LCS::Internals, ".lcs" do
include Diff::LCS::SpecHelper::Matchers
唯一可行的方法是不要尝试准备文件名列表,而只是拥有
bundle exec rspec
在我的
.circleci/config file in a `run:` `command:` section
这样可行。虽然它实际上并没有选择顶级目录中*_spec.rb
的文件,但只选择了目录中的文件 - 这有点奇怪,因为 find 命令同时记录了当前目录和子目录,但在这里使用它只能找到 1 个文件。rspec/
然后我设法通过使用来解决这个问题
bundle exec rspec . # Note the dot at the end
虽然我现在可以运行所有测试,但问题仍然存在 - 我如何选择文件列表?当我目前正在尝试 CircleCI 时,所有方法似乎都以几种方式被破坏了。