Skip to content

Commit

Permalink
Revert "test"
Browse files Browse the repository at this point in the history
This reverts commit db602e1.
  • Loading branch information
AlexB52 committed Jan 9, 2025
1 parent db602e1 commit 122d9f3
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions lib/retest/watcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,10 @@ def self.watch(dir:, extensions:, polling: false)
# We need the process to still run when trying to stop the current test run
# Maybe there is another way to prevent killing these but for now a new process groups works
# Process group created with: Process.setsid
watch_rd, watch_wr = IO.pipe
pid = fork do
Process.setsid
Listen.to(dir, only: extensions_regex(extensions), relative: true, polling: polling) do |modified, added, removed|
if modified.any?
watch_wr.write "modify:#{modified.first}"
elsif added.any?
watch_wr.write "create:#{added.first}"
elsif removed.any?
watch_wr.write "remove:#{removed.first}"
end
yield modified, added, removed
end.start
sleep
end
Expand All @@ -49,28 +42,6 @@ def self.watch(dir:, extensions:, polling: false)
watch_rd.close
watch_wr.close
end

Thread.new do
loop do
ready = IO.select([watch_rd])
readable_connections = ready[0]
readable_connections.each do |conn|
data = conn.readpartial(4096)
change = /^(?<action>create|remove|modify):(?<path>.*)/.match(data.strip)

next unless change

modified, added, removed = result = [[], [], []]
case change[:action]
when 'modify' then modified << change[:path]
when 'create' then added << change[:path]
when 'remove' then removed << change[:path]
end

yield result
end
end
end
end

def self.extensions_regex(extensions)
Expand Down

0 comments on commit 122d9f3

Please sign in to comment.