summaryrefslogtreecommitdiff
path: root/rubylib
diff options
context:
space:
mode:
authorJon Cairns <jon@joncairns.com>2014-06-06 14:49:45 +0100
committerJon Cairns <jon@joncairns.com>2014-06-06 14:49:45 +0100
commitb9290c1cae0d56427217f7adc88233a9a8eb3d5f (patch)
treee6b3d8872ce0e4cf322b1022367441657905f581 /rubylib
parentb1682ef6b44d7b02e20ca5bcb4ef5f7899796f40 (diff)
downloadvdebug-b9290c1cae0d56427217f7adc88233a9a8eb3d5f.zip
Allow for parralel execution of cucumber tests
Diffstat (limited to 'rubylib')
-rw-r--r--rubylib/vdebug.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/rubylib/vdebug.rb b/rubylib/vdebug.rb
index d251452..d80812d 100644
--- a/rubylib/vdebug.rb
+++ b/rubylib/vdebug.rb
@@ -1,13 +1,18 @@
+require 'securerandom'
+
class Vdebug
class BufferNotFound < StandardError; end;
attr_reader :vim
def initialize(vim)
+ @lock_file = "../vdebug.lock"
+ @instance_id = SecureRandom::hex(3)
@vim = vim
end
def start_listening
+ write_lock_file!
clear_buffer_cache!
vim.server.remote_send ":python debugger.run()<CR>"
sleep 1
@@ -103,7 +108,22 @@ class Vdebug
/Status: (\S+)/.match(status_window_content)[1]
end
+ def remove_lock_file!
+ if File.exists?(@lock_file) && File.read(@lock_file) == @instance_id
+ puts "Deleting lock file for #{@instance_id}"
+ File.delete(@lock_file)
+ end
+ end
+
protected
+ def write_lock_file!
+ while File.exists?(@lock_file)
+ sleep 0.1
+ end
+ puts "Creating lock file for #{@instance_id}"
+ File.write(@lock_file, @instance_id)
+ end
+
def fetch_buffer_content(name)
bufnum = buffers.invert.fetch(name)
vim.echo(%Q{join(getbufline(#{bufnum}, 1, "$"), "\\n")})