From bccf40dd51e06ece51a023cf75b0cc8bce904d30 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 7 Sep 2013 22:39:27 +0000 Subject: splitfx: flesh out functionality + integration test This seems to be working out nicely. Having a basic integration test should be enough to get us started for now. --- lib/dtas/splitfx.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/dtas/splitfx.rb b/lib/dtas/splitfx.rb index 7a5d705..2326546 100644 --- a/lib/dtas/splitfx.rb +++ b/lib/dtas/splitfx.rb @@ -120,7 +120,7 @@ class DTAS::SplitFX # :nodoc: { command: CMD, format: DTAS::Format.load(fmt) } end - def spawn(target, t, dryrun = false) + def spawn(target, t, opts) target = @targets[target] || generic_target(target) outfmt = target[:format] env = outfmt.to_env @@ -156,12 +156,14 @@ class DTAS::SplitFX # :nodoc: qx(env, "printf %s \"#{arg}\"") end echo = "echo #{xs(tmp)}" - if dryrun + if opts[:dryrun] command = echo else - system(echo) + system(echo) unless opts[:silent] end - [ dtas_spawn(env, command, {}), comments ] + + # pgroup: false so Ctrl-C on command-line will immediately stop everything + [ dtas_spawn(env, command, pgroup: false), comments ] end def load_tracks!(hash) @@ -245,14 +247,14 @@ class DTAS::SplitFX # :nodoc: @infmt.hhmmss_to_samples(time) end - def run(target, jobs = 1, dryrun = false) + def run(target, opts = {}) fails = [] tracks = @tracks.dup pids = {} - jobs ||= tracks.size # jobs == nil => everything at once + jobs = opts[:jobs] || tracks.size # jobs == nil => everything at once jobs.times.each do t = tracks.shift or break - pid, tmp = spawn(target, t, dryrun) + pid, tmp = spawn(target, t, opts) pids[pid] = [ t, tmp ] end @@ -261,7 +263,7 @@ class DTAS::SplitFX # :nodoc: done = pids.delete(pid) if status.success? if t = tracks.shift - pid, tmp = spawn(target, t, dryrun) + pid, tmp = spawn(target, t, opts) pids[pid] = [ t, tmp ] end puts "DONE #{done[0].inspect}" if $DEBUG -- cgit v1.2.3-24-ge0c7