File: Rakefile

package info (click to toggle)
ruby-train 3.16.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,272 kB
  • sloc: ruby: 10,507; sh: 17; makefile: 8
file content (66 lines) | stat: -rwxr-xr-x 1,904 bytes parent folder | download | duplicates (2)
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
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env rake
require "bundler"
require "bundler/gem_helper"
require "rake/testtask"
require "chefstyle"
require "rubocop/rake_task"

Bundler::GemHelper.install_tasks name: "train"

RuboCop::RakeTask.new(:lint) do |task|
  task.options << "--display-cop-names"
end

# run tests
task default: %i{test}

Rake::TestTask.new do |t|
  t.libs << "test"
  t.pattern = "test/unit/**/*_test.rb"
  t.warning = false
  t.verbose = true
  t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION)
end

namespace :test do
  task :docker do
    path = File.join(__dir__, "test", "integration")
    sh("sh", "-c", "cd #{path} && ruby -I ../../lib docker_test.rb tests/*")
  end

  task :windows do
    Dir.glob("test/windows/*_test.rb").all? do |file|
      sh(Gem.ruby, "-w", '-I .\test\windows', file)
    end || raise("Failures")
  end

  task :vm do
    concurrency = ENV["CONCURRENCY"] || 4
    path = File.join(__dir__, "test", "integration")
    sh("sh", "-c", "cd #{path} && kitchen test -c #{concurrency}")
  end

  # Target required:
  #   rake "test:ssh[user@server]"
  #   sh -c cd /home/foobarbam/src/gems/train/test/integration \
  #     && target=user@server ruby -I ../../lib test_ssh.rb tests/*
  #   ...
  # Turn debug logging back on:
  #   debug=1 rake "test:ssh[user@server]"
  # Use a different ssh key:
  #   key_files=/home/foobarbam/.ssh/id_rsa2 rake "test:ssh[user@server]"
  # Run with a specific test:
  #   test=path_block_device_test.rb rake "test:ssh[user@server]"
  task :ssh, [:target] do |t, args|
    path = File.join(__dir__, "test", "integration")
    key_files = ENV["key_files"] || File.join(ENV["HOME"], ".ssh", "id_rsa")

    sh_cmd = "cd #{path} && target=#{args[:target]} key_files=#{key_files}"

    sh_cmd += " debug=#{ENV["debug"]}" if ENV["debug"]
    sh_cmd += " ruby -I ../../lib test_ssh.rb tests/"
    sh_cmd += ENV["test"] || "*"

    sh("sh", "-c", sh_cmd)
  end
end