File: integration_tests_spec.rb

package info (click to toggle)
chake 0.93.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 412 kB
  • sloc: ruby: 1,276; sh: 112; makefile: 5; sed: 3
file content (48 lines) | stat: -rw-r--r-- 1,079 bytes parent folder | download | duplicates (3)
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
require 'fileutils'
require 'pathname'
require 'tmpdir'

describe 'Chake' do
  include FileUtils

  def sh(*args)
    cmd = Shellwords.join(args)
    lib = [Pathname.new(__FILE__).parent.parent / 'lib', ENV.fetch('RUBYLIB', nil)].compact.join(':')
    path = [Pathname.new(__FILE__).parent.parent / 'bin', ENV.fetch('PATH', nil)].join(':')
    env = {
      'RUBYLIB' => lib,
      'PATH' => path
    }
    unless system(env, *args, out: ['.out', 'w'], err: ['.err', 'w'])
      out = File.read('.out')
      err = File.read('.err')
      raise "Command [#{cmd}] failed with exit status #{$CHILD_STATUS} (PATH = #{path}, RUBYLIB = #{lib}).\nstdout:\n#{out}\nstderr:\n#{err}"
    end
    rm_f '.log'
  end

  def chake(*args)
    cmd = [Gem.ruby, '-S', 'chake'] + args
    sh(*cmd)
  end

  def rake(*args)
    cmd = [Gem.ruby, '-S', 'rake'] + args
    sh(*cmd)
  end

  def project
    Dir.mktmpdir do |dir|
      Dir.chdir(dir) do
        yield dir
      end
    end
  end

  it 'loads node information' do
    project do
      chake 'init'
      rake 'nodes'
    end
  end
end