aboutsummaryrefslogtreecommitdiff
path: root/.vim/test/helper.rb
blob: 5c509774ea6b0b07d0626762d3a7c99b770890e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
require "minitest/autorun"
require "vimrunner"
require "fileutils"
require "tempfile"

MiniTest::Unit::TestCase.define_singleton_method(:test_order) do :alpha end

begin
  require "minitest/reporters"
  MiniTest::Reporters.use! MiniTest::Reporters::SpecReporter.new
rescue LoadError
end

$vimrc = File.expand_path("../vimrc", __FILE__)
$vim = Vimrunner::Server.new(:vimrc => $vimrc).start
Minitest::Unit.after_tests { $vim.kill }

module WithTemporaryDirectory
  def self.included(base)
    require "tmpdir"
  end

  def setup
    super
    # Mac has the temporary directory symlinked, so need File.realpath to
    # match the paths that Vim returns.
    @dir = File.realpath(Dir.mktmpdir)
  end

  def teardown
    FileUtils.remove_entry_secure @dir
    super
  end
end

def touch(path, contents = nil)
  FileUtils.mkpath File.dirname(path)

  if contents.nil? || contents.empty?
    FileUtils.touch(path)
  else
    File.open(path, "w") {|f| f.write contents }
  end

  path
end

CORE_MODULES = %w[_debugger _http_agent _http_client _http_common
  _http_incoming _http_outgoing _http_server _linklist _stream_duplex
  _stream_passthrough _stream_readable _stream_transform _stream_writable
  _tls_legacy _tls_wrap assert buffer child_process cluster console
  constants crypto dgram dns domain events freelist fs http https module
  net node os path punycode querystring readline repl smalloc stream
  string_decoder sys timers tls tty url util vm zlib]