raise error when circular dependencies are found - close #38
This commit is contained in:
parent
eca01c38df
commit
6dd70ff65e
5
build_tests/simple/error_circular_dependency.rb
Normal file
5
build_tests/simple/error_circular_dependency.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Rscons::Environment.new do |env|
|
||||||
|
env.Command("foo", "bar")
|
||||||
|
env.Command("bar", "baz")
|
||||||
|
env.Command("baz", "foo")
|
||||||
|
end
|
3
build_tests/simple/error_circular_dependency2.rb
Normal file
3
build_tests/simple/error_circular_dependency2.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Rscons::Environment.new do |env|
|
||||||
|
env.Command("foo", "foo")
|
||||||
|
end
|
@ -47,12 +47,18 @@ module Rscons
|
|||||||
# @return [nil, Hash]
|
# @return [nil, Hash]
|
||||||
# The next job to run.
|
# The next job to run.
|
||||||
def get_next_job_to_run(targets_still_building)
|
def get_next_job_to_run(targets_still_building)
|
||||||
|
targets_skipped = Set.new
|
||||||
@jobs.keys.each do |target|
|
@jobs.keys.each do |target|
|
||||||
skip = false
|
skip = false
|
||||||
(@jobs[target][0][:sources] + (@build_dependencies[target] || []).to_a).each do |src|
|
(@jobs[target][0][:sources] + (@build_dependencies[target] || []).to_a).each do |src|
|
||||||
if @jobs.include?(src)
|
if @jobs.include?(src)
|
||||||
|
if targets_skipped.include?(src) or (src == target)
|
||||||
|
# We have encountered a circular dependency.
|
||||||
|
raise "Circular build dependency for #{src}"
|
||||||
|
end
|
||||||
# Skip this target because it depends on another target later in
|
# Skip this target because it depends on another target later in
|
||||||
# the job set.
|
# the job set.
|
||||||
|
targets_skipped << target
|
||||||
skip = true
|
skip = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
@ -732,6 +732,20 @@ EOF
|
|||||||
expect(`./test-static.exe`).to match /Hi from one/
|
expect(`./test-static.exe`).to match /Hi from one/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "raises an error for a circular dependency" do
|
||||||
|
test_dir("simple")
|
||||||
|
result = run_test(rsconsfile: "error_circular_dependency.rb")
|
||||||
|
expect(result.stderr).to match /Circular build dependency for (foo|bar|baz)/
|
||||||
|
expect(result.status).to_not eq 0
|
||||||
|
end
|
||||||
|
|
||||||
|
it "raises an error for a circular dependency where a build target contains itself in its source list" do
|
||||||
|
test_dir("simple")
|
||||||
|
result = run_test(rsconsfile: "error_circular_dependency2.rb")
|
||||||
|
expect(result.stderr).to match /Circular build dependency for foo/
|
||||||
|
expect(result.status).to_not eq 0
|
||||||
|
end
|
||||||
|
|
||||||
context "backward compatibility" do
|
context "backward compatibility" do
|
||||||
it "allows a builder to call Environment#run_builder in a non-threaded manner" do
|
it "allows a builder to call Environment#run_builder in a non-threaded manner" do
|
||||||
test_dir("simple")
|
test_dir("simple")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user