Sha256: e8cbacb2b14820719ec2b8d6364e08914aec58d10e6cc0647b9f1b5f49f12b41

Contents?: true

Size: 785 Bytes

Versions: 4

Compression:

Stored size: 785 Bytes

Contents

module Specinfra
  module Backend
    class Lxc < Exec
      def run_command(cmd, opts={})
        cmd = build_command(cmd)
        cmd = add_pre_command(cmd)
        out, ret = ct.execute do
          out = `#{cmd}  2>&1`
          [out, $?.dup]
        end
        if @example
          @example.metadata[:command] = cmd
          @example.metadata[:stdout]  = out
        end
        CommandResult.new :stdout => out, :exit_status => ret.exitstatus
      end
      def build_command(cmd)
        cmd
      end

      def add_pre_command(cmd)
        cmd
      end

      def copy_file(from, to)
        FileUtils.cp(from, File.join(ct.config_item('lxc.rootfs'), to))
      end

      def ct
        @ct ||= ::LXC::Container.new(RSpec.configuration.lxc)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
specinfra-2.0.0.beta27 lib/specinfra/backend/lxc.rb
specinfra-2.0.0.beta26 lib/specinfra/backend/lxc.rb
specinfra-2.0.0.beta25 lib/specinfra/backend/lxc.rb
specinfra-2.0.0.beta23 lib/specinfra/backend/lxc.rb