Skip to content

Commit

Permalink
Implemented 'generate only these targets'
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed Jun 13, 2023
1 parent 0432e20 commit deaf03d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
3 changes: 1 addition & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ Thinks it may make sense to add:

* Tasks without file output
* Tasks with more than one output
* Run only tasks needed to produce specific outputs
* Run only listed tasks
* ~~Run only tasks needed to produce specific outputs~~
13 changes: 13 additions & 0 deletions spec/croupier_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,19 @@ describe Croupier::Task do
end
end

it "should run only required tasks to produce specified outputs" do
with_tasks do
Dir.cd "spec/files" do
Croupier::Task.run_tasks(["output4", "output5"])
File.exists?("output1").should be_false
File.exists?("output2").should be_false
File.exists?("output3").should be_true # Required for output4
File.exists?("output4").should be_true # Required
File.exists?("output5").should be_true # Required
end
end
end

it "should fail if asked for dependencies of an unknown output" do
with_tasks do
Dir.cd "spec/files" do
Expand Down
4 changes: 2 additions & 2 deletions src/croupier.cr
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ module Croupier
end

# Run the tasks needed to create or update the requested targets
def self.run_tasks(targets : Array(String))
def self.run_tasks(targets : Array(String), run_all : Bool = false)
mark_stale_inputs
tasks = dependencies(targets)
_run_tasks(tasks, run_all)
Expand All @@ -174,7 +174,7 @@ module Croupier
_, tasks = Task.sorted_task_graph
_run_tasks(tasks, run_all)
end

# Helper to run tasks
def self._run_tasks(tasks, run_all : Bool = false)
tasks.each do |task|
Expand Down

0 comments on commit deaf03d

Please sign in to comment.