qor_test 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -2
- data/README.md +3 -7
- data/Rakefile +1 -1
- data/bin/qor_test.rb +63 -0
- data/lib/qor_test.rb +5 -5
- data/lib/qor_test/cli.rb +60 -64
- data/lib/qor_test/configuration.rb +71 -42
- data/lib/qor_test/gem.rb +3 -3
- data/lib/qor_test/gemfile.rb +53 -0
- data/lib/qor_test/rubies.rb +43 -0
- data/lib/qor_test/version.rb +1 -1
- data/shell/qor_test +6 -0
- metadata +8 -8
- data/bin/qor_test +0 -11
- data/lib/qor_test/bundler.rb +0 -70
- data/lib/qor_test/test_help.rb +0 -9
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -20,15 +20,11 @@
|
|
20
20
|
gem 'rails', ['3.1', '3.2']
|
21
21
|
end
|
22
22
|
|
23
|
-
test/test_helper.rb
|
24
|
-
|
25
|
-
load_dummy_rails_env #:models_path => [], :migrations_path => []
|
26
|
-
|
27
|
-
|
28
23
|
Run:
|
29
24
|
|
30
|
-
qor_test
|
31
|
-
qor_test -e
|
25
|
+
qor_test
|
26
|
+
COMMAND='ruby test/xxxx' qor_test -e default
|
27
|
+
COMMAND='rake test' qor_test -e 1.8.7
|
32
28
|
|
33
29
|
## Contributing
|
34
30
|
|
data/Rakefile
CHANGED
data/bin/qor_test.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require "optparse"
|
5
|
+
|
6
|
+
$:.unshift File.expand_path("../../lib", __FILE__)
|
7
|
+
require "qor_test"
|
8
|
+
require "qor_test/configuration"
|
9
|
+
|
10
|
+
options = {}
|
11
|
+
|
12
|
+
OptionParser.new do |opts|
|
13
|
+
opts.on( '-e', '--env env', 'Test Env') do |env|
|
14
|
+
options[:env] = env
|
15
|
+
end
|
16
|
+
|
17
|
+
opts.on( '-c', '--clean', 'Clean up temporary files') do
|
18
|
+
puts "Cleaning temporary files..."
|
19
|
+
FileUtils.rm_rf(Dir[File.join(Qor::Test::CLI.temp_directory, "qor_test-gemfiles-*")])
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
|
23
|
+
opts.on( '-p', '--pretend', 'Skip run command, only generate Gemfiles') do
|
24
|
+
options[:pretend] = true
|
25
|
+
end
|
26
|
+
|
27
|
+
opts.on( '-i', '--init', 'Init') do
|
28
|
+
Qor::Test::CLI.init
|
29
|
+
exit
|
30
|
+
end
|
31
|
+
|
32
|
+
opts.on( '-s', '--sample', 'Create sample configuration') do
|
33
|
+
Qor::Test::CLI.copy_sample_configuration
|
34
|
+
exit
|
35
|
+
end
|
36
|
+
|
37
|
+
opts.on( '-h', '--help', 'Display this help') do
|
38
|
+
puts opts
|
39
|
+
exit
|
40
|
+
end
|
41
|
+
|
42
|
+
opts.on( '-v', '--version', 'Show version number') do |version|
|
43
|
+
puts "Version: #{Qor::Test::VERSION}"
|
44
|
+
exit
|
45
|
+
end
|
46
|
+
end.parse!
|
47
|
+
|
48
|
+
# Default command to run tests
|
49
|
+
options[:command] = ENV['COMMAND'] || "rake #{File.exist?('spec') ? 'spec' : 'test'}"
|
50
|
+
|
51
|
+
# Run all envs by default
|
52
|
+
envs = options[:env] ? [options[:env]] : Qor::Test::Configuration.envs
|
53
|
+
envs = [nil] if envs.size == 0
|
54
|
+
|
55
|
+
$case_num = 0
|
56
|
+
scripts = envs.map do |env|
|
57
|
+
Qor::Test::CLI.new(options.merge(:env => env)).run.scripts
|
58
|
+
end
|
59
|
+
scripts.unshift "total_cases_num=#{$case_num}"
|
60
|
+
|
61
|
+
open(ENV['QOR_TEST_SCRIPT_FILE'] || 'qor_test.sh', 'a') do |f|
|
62
|
+
f.puts scripts.compact.join("\n")
|
63
|
+
end
|
data/lib/qor_test.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'qor_dsl'
|
2
|
-
require 'qor_test/version'
|
3
|
-
require 'qor_test/bundler'
|
4
|
-
require 'qor_test/gem'
|
5
|
-
require 'qor_test/configuration'
|
6
|
-
require 'qor_test/test_help'
|
7
2
|
require 'qor_test/cli'
|
3
|
+
require 'qor_test/configuration'
|
4
|
+
require 'qor_test/gemfile'
|
5
|
+
require 'qor_test/gem'
|
6
|
+
require 'qor_test/version'
|
7
|
+
require 'qor_test/rubies'
|
8
8
|
|
9
9
|
module Qor
|
10
10
|
module Test
|
data/lib/qor_test/cli.rb
CHANGED
@@ -1,92 +1,88 @@
|
|
1
|
-
require "optparse"
|
2
1
|
require 'tempfile'
|
3
2
|
require "fileutils"
|
4
3
|
|
5
4
|
module Qor
|
6
5
|
module Test
|
7
6
|
class CLI
|
8
|
-
|
9
|
-
attr_accessor :options
|
7
|
+
attr_accessor :options, :scripts
|
10
8
|
|
11
9
|
def initialize(options={})
|
12
10
|
self.options = options
|
11
|
+
self.scripts = []
|
13
12
|
end
|
14
13
|
|
15
|
-
def
|
16
|
-
|
17
|
-
|
18
|
-
puts ">> Generated #{gemfiles.count} Gemfile\n\n"
|
19
|
-
|
20
|
-
gemfiles.map do |gemfile|
|
21
|
-
begin
|
22
|
-
new_gemfile = "QorTest_" + File.basename(gemfile)
|
23
|
-
FileUtils.cp(gemfile, new_gemfile)
|
24
|
-
with_clean_gemfile(new_gemfile) do
|
25
|
-
puts ">> BUNDLE_GEMFILE=#{gemfile}"
|
26
|
-
["bundle update", "#{options[:command]}\n\n"].map do |command|
|
27
|
-
puts ">> #{command}"
|
28
|
-
system(command) unless options[:pretend]
|
29
|
-
end
|
30
|
-
end
|
31
|
-
ensure
|
32
|
-
FileUtils.rm(new_gemfile)
|
33
|
-
end
|
34
|
-
end
|
14
|
+
def gemfile
|
15
|
+
@gemfile ||= Qor::Test::Gemfile.new(options)
|
35
16
|
end
|
36
17
|
|
37
|
-
def
|
38
|
-
|
39
|
-
BUNDLER_ENV_VARS.each do |key|
|
40
|
-
original_env[key] = ENV[key]
|
41
|
-
ENV[key] = nil
|
42
|
-
end
|
43
|
-
|
44
|
-
ENV['BUNDLE_GEMFILE'] = gemfile
|
45
|
-
yield
|
46
|
-
ensure
|
47
|
-
original_env.each { |key, value| ENV[key] = value }
|
18
|
+
def gemfiles
|
19
|
+
@gemfiles ||= gemfile.generate_gemfiles.reverse
|
48
20
|
end
|
49
21
|
|
50
|
-
def
|
51
|
-
|
52
|
-
|
53
|
-
OptionParser.new do |opts|
|
54
|
-
opts.on( '-e', '--env env', 'Test Env') do |env|
|
55
|
-
options[:env] = env
|
56
|
-
end
|
57
|
-
|
58
|
-
opts.on( '-c', '--command command', 'Command') do |command|
|
59
|
-
options[:command] = command
|
60
|
-
end
|
61
|
-
|
62
|
-
opts.on( '-C', '--clean', 'Clean old temp files') do
|
63
|
-
puts "Cleaning temp files..."
|
64
|
-
FileUtils.rm_rf(Dir[File.join(temp_directory, "qor_test-tmp-*")])
|
65
|
-
exit
|
66
|
-
end
|
67
|
-
|
68
|
-
opts.on( '-p', '--pretend', 'Skip run command, only generate Gemfiles') do
|
69
|
-
options[:pretend] = true
|
70
|
-
end
|
22
|
+
def rubies
|
23
|
+
gemfile.ruby_versions
|
24
|
+
end
|
71
25
|
|
72
|
-
|
73
|
-
|
74
|
-
|
26
|
+
def run
|
27
|
+
rubies.map do |version|
|
28
|
+
scripts << Qor::Test::Rubies.switch_ruby_version(version)
|
29
|
+
gemfiles.map do |file|
|
30
|
+
$case_num += 1
|
31
|
+
scripts << "echo -n '\n\e[01;31m[ENV #{gemfile.group_name}] \e[0m'"
|
32
|
+
scripts << "echo -n '\e[31mRunning case #{$case_num} with ruby #{version}, '$[$total_cases_num-#{$case_num}]' cases left\e[0m\n'"
|
33
|
+
run_with_gemfile(file)
|
75
34
|
end
|
35
|
+
end
|
36
|
+
self
|
37
|
+
rescue Qor::Dsl::ConfigurationNotFound
|
38
|
+
puts "ConfigurationNotFound, please run `qor_test --init` in project's root to get a sample configuration"
|
39
|
+
end
|
76
40
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
41
|
+
def run_with_gemfile(file)
|
42
|
+
lock_file = "#{file}.lock"
|
43
|
+
temp_file = "QorTest_" + File.basename(file)
|
44
|
+
temp_lock = "#{temp_file}.lock"
|
45
|
+
|
46
|
+
# Copy Gemfile and Gemfile.lock if exist
|
47
|
+
scripts << "cp '#{file}' '#{temp_file}'"
|
48
|
+
scripts << "[ -f '#{lock_file}' ] && cp '#{lock_file}' '#{temp_lock}'"
|
49
|
+
|
50
|
+
# Export Gemfile
|
51
|
+
scripts << "echo '>> BUNDLE_GEMFILE=#{file}'"
|
52
|
+
scripts << "export BUNDLE_GEMFILE=#{temp_file}"
|
53
|
+
|
54
|
+
# Test commands. 1, bundle install, 2, rake test
|
55
|
+
[
|
56
|
+
"bundle install --quiet",
|
57
|
+
"#{options[:command]}".sub(/^(bundle\s+exec\s+)?/, 'bundle exec ')
|
58
|
+
].map do |command|
|
59
|
+
scripts << "echo '>> #{command}'"
|
60
|
+
scripts << command unless options[:pretend]
|
61
|
+
end
|
82
62
|
|
83
|
-
|
63
|
+
# Backup & Cleanup
|
64
|
+
scripts << "[ -f '#{temp_lock}' ] && cp '#{temp_lock}' '#{lock_file}'"
|
65
|
+
[temp_file, temp_lock].map do |file|
|
66
|
+
scripts << "[ -f '#{file}' ] && rm '#{file}'"
|
67
|
+
end
|
84
68
|
end
|
85
69
|
|
86
70
|
def self.temp_directory
|
87
71
|
tempfile = Tempfile.new('fake')
|
88
72
|
File.dirname(tempfile.path)
|
89
73
|
end
|
74
|
+
|
75
|
+
def self.copy_sample_configuration
|
76
|
+
FileUtils.mkdir_p(File.dirname(Qor::Test::Configuration.config_path))
|
77
|
+
FileUtils.cp(Qor::Test::Configuration.sample_file, Qor::Test::Configuration.config_path)
|
78
|
+
puts("Copied sample configuration to #{Qor::Test::Configuration.config_path}!")
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.init
|
82
|
+
command = "sudo ln -nfs #{File.expand_path("../../../shell/qor_test", __FILE__)} /usr/bin/"
|
83
|
+
puts command
|
84
|
+
system command
|
85
|
+
end
|
90
86
|
end
|
91
87
|
end
|
92
88
|
end
|
@@ -1,78 +1,107 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
|
1
3
|
module Qor
|
2
4
|
module Test
|
3
|
-
|
5
|
+
class Configuration
|
4
6
|
include Qor::Dsl
|
5
|
-
default_configs ["config/qor/test.rb"]
|
6
7
|
|
7
8
|
node :source
|
8
9
|
node :ruby
|
9
10
|
node :gemspec
|
10
11
|
node :gem
|
11
12
|
|
12
|
-
|
13
|
-
node
|
14
|
-
|
13
|
+
[:git, :platforms, :path, :group, :env].map do |name|
|
14
|
+
node name do
|
15
|
+
node :ruby
|
16
|
+
node :gem
|
17
|
+
end
|
15
18
|
end
|
16
19
|
|
17
|
-
def self.
|
18
|
-
|
19
|
-
n.parent.root? || ((n.parent.config_name == :env) && n.parent.name.to_s == (options[:env] || 'default'))
|
20
|
-
end
|
20
|
+
def self.config_path
|
21
|
+
"config/qor/test.rb"
|
21
22
|
end
|
22
23
|
|
23
|
-
def self.
|
24
|
-
|
25
|
-
n.parent.root? || ((n.parent.config_name == :env) && n.parent.name.to_s == (options[:env] || 'default'))
|
26
|
-
end
|
24
|
+
def self.gemfile_path
|
25
|
+
[ENV['QOR_TEST_GEMFILE'], ENV['BUNDLE_GEMFILE'], 'Gemfile'].detect {|x| File.exist?(x.to_s)}
|
27
26
|
end
|
28
27
|
|
29
|
-
def self.
|
30
|
-
|
31
|
-
|
32
|
-
end
|
28
|
+
def self.configuration_digest(options={})
|
29
|
+
hexdigest = Digest::MD5.hexdigest(options.inspect + File.read(config_path) + File.read(gemfile_path))
|
30
|
+
"qor_test-gemfiles-#{hexdigest}"
|
33
31
|
end
|
34
|
-
end
|
35
32
|
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
def self.sample_file
|
34
|
+
File.expand_path("#{File.dirname(__FILE__)}/../../config/qor/test.rb")
|
35
|
+
end
|
39
36
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
node :gem
|
37
|
+
def self.root_from_config
|
38
|
+
@root_from_config ||= Qor::Test::Configuration.load(config_path, :force => true)
|
39
|
+
end
|
44
40
|
|
45
|
-
|
46
|
-
|
41
|
+
def self.root_from_gemfile
|
42
|
+
@root_from_gemfile ||= Qor::Test::Configuration.load(gemfile_path, :force => true)
|
47
43
|
end
|
48
44
|
|
49
|
-
|
50
|
-
node
|
45
|
+
def self.find_block(options={})
|
46
|
+
lambda do |node|
|
47
|
+
parent = node.parent
|
48
|
+
parent.root? || parent.is_node?(:env, options[:env] || 'default') || parent.is_node?(:group, 'test')
|
49
|
+
end
|
51
50
|
end
|
52
51
|
|
53
|
-
|
54
|
-
|
52
|
+
def self.ruby_versions(options)
|
53
|
+
ruby_versions = [root_from_config, root_from_gemfile].map {|x| x.deep_find('ruby', &find_block(options)) }
|
54
|
+
ruby_versions.flatten.compact.map(&:value)
|
55
55
|
end
|
56
56
|
|
57
|
-
|
58
|
-
|
57
|
+
def self.envs(options={})
|
58
|
+
envs = root_from_config.deep_find('env').map(&:value)
|
59
|
+
options[:env] ? envs.select {|x| x == options[:env]} : envs
|
59
60
|
end
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
|
62
|
+
{:gemspecs => :gemspec, :sources => :source}.map do |key, value|
|
63
|
+
self.class.class_eval do
|
64
|
+
define_method key do |options|
|
65
|
+
objs_from_config = root_from_config.deep_find(value, &find_block(options))
|
66
|
+
objs_from_gemfile = root_from_gemfile.deep_find(value, &find_block(options))
|
67
|
+
[objs_from_config, objs_from_gemfile].flatten.compact
|
68
|
+
end
|
64
69
|
end
|
65
70
|
end
|
66
71
|
|
67
|
-
def self.
|
68
|
-
|
69
|
-
|
72
|
+
def self.combined_sources(options={})
|
73
|
+
sources(options).map { |source| "source #{source.value.inspect}\n" }.uniq.join("")
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.combined_gemspecs(options={})
|
77
|
+
gemspecs(options).map do |gemspec|
|
78
|
+
"gemspec #{gemspec.value.nil? ? '' : gemspec.value.inspect.gsub(/^\{|\}$/,'')}\n"
|
79
|
+
end.uniq.join("")
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.gems_set_from_config(options={})
|
83
|
+
all_gems = root_from_config.deep_find(:gem, &find_block(options)).inject({}) do |sum, node|
|
84
|
+
sum[node.name] ||= []
|
85
|
+
sum[node.name].concat Qor::Test::Gem.parse(node)
|
86
|
+
sum
|
87
|
+
end.values
|
88
|
+
|
89
|
+
gems_set = all_gems.length > 0 ? all_gems[0].product(*all_gems[1..-1]) : []
|
90
|
+
gems_set.map { |gems| gems_to_hash(gems) }
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.gems_hash_from_gemfile(options={})
|
94
|
+
gems = root_from_gemfile.deep_find(:gem, &find_block(options)).map do |node|
|
95
|
+
Qor::Test::Gem.parse(node)[0]
|
70
96
|
end
|
97
|
+
gems_to_hash(gems)
|
71
98
|
end
|
72
99
|
|
73
|
-
|
74
|
-
|
75
|
-
|
100
|
+
private
|
101
|
+
def self.gems_to_hash(gems)
|
102
|
+
gems.inject({}) do |sum, gem|
|
103
|
+
sum[gem.name.to_s] = gem
|
104
|
+
sum
|
76
105
|
end
|
77
106
|
end
|
78
107
|
end
|
data/lib/qor_test/gem.rb
CHANGED
@@ -7,9 +7,9 @@ module Qor
|
|
7
7
|
self.name = node.name.to_s
|
8
8
|
self.gem_option = gem_option
|
9
9
|
|
10
|
-
[:git, :path, :platforms].map do |
|
11
|
-
if node.parent.
|
12
|
-
self.options = {
|
10
|
+
[:git, :path, :platforms].map do |type|
|
11
|
+
if node.parent.is_node?(type)
|
12
|
+
self.options = {type => node.parent.value}.merge(node.parent.options)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Qor
|
2
|
+
module Test
|
3
|
+
class Gemfile
|
4
|
+
attr_accessor :options
|
5
|
+
|
6
|
+
def initialize options={}
|
7
|
+
self.options = options
|
8
|
+
end
|
9
|
+
|
10
|
+
def ruby_versions
|
11
|
+
versions = Qor::Test::Configuration.ruby_versions(options)
|
12
|
+
versions.empty? ? [RUBY_VERSION] : versions
|
13
|
+
end
|
14
|
+
|
15
|
+
def group_name
|
16
|
+
Qor::Test::Configuration.envs(options)[0]
|
17
|
+
end
|
18
|
+
|
19
|
+
def generate_gemfiles
|
20
|
+
gems_set_from_config = Qor::Test::Configuration.gems_set_from_config(options)
|
21
|
+
gems_hash_from_gemfile = Qor::Test::Configuration.gems_hash_from_gemfile(options)
|
22
|
+
gemfile_length = [gems_set_from_config.length, 1].max
|
23
|
+
|
24
|
+
gemfile_dir = File.join(Qor::Test::CLI.temp_directory, Qor::Test::Configuration.configuration_digest(options))
|
25
|
+
|
26
|
+
if File.exist?(gemfile_dir)
|
27
|
+
Dir[File.join(gemfile_dir, '*')].select {|x| x !~ /.lock$/ }
|
28
|
+
else
|
29
|
+
FileUtils.mkdir_p(gemfile_dir)
|
30
|
+
|
31
|
+
(0...gemfile_length).map do |index|
|
32
|
+
filename = File.join(gemfile_dir, "Gemfile.#{index}")
|
33
|
+
write_gemfile(gems_set_from_config[index] || {}, gems_hash_from_gemfile, filename)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def write_gemfile(gems_from_config, gems_from_gemfile, filename)
|
39
|
+
gem_names = [gems_from_config.keys, gems_from_gemfile.keys].flatten.compact.uniq
|
40
|
+
|
41
|
+
gems = gem_names.map do |name|
|
42
|
+
gems_from_config[name] || gems_from_gemfile[name]
|
43
|
+
end.compact
|
44
|
+
|
45
|
+
File.open(filename, "w+") do |f|
|
46
|
+
f << Qor::Test::Configuration.combined_sources(options)
|
47
|
+
f << Qor::Test::Configuration.combined_gemspecs(options)
|
48
|
+
f << gems.map(&:to_s).join("\n")
|
49
|
+
end.path
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Qor
|
2
|
+
module Test
|
3
|
+
class Rubies
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def rvm?
|
7
|
+
%x(sh -c "command -v rvm").size > 0
|
8
|
+
end
|
9
|
+
|
10
|
+
def rbenv?
|
11
|
+
%x(sh -c "command -v rbenv").size > 0
|
12
|
+
end
|
13
|
+
|
14
|
+
def version_manager_installed?
|
15
|
+
rvm? || rbenv?
|
16
|
+
end
|
17
|
+
|
18
|
+
def versions
|
19
|
+
if rvm?
|
20
|
+
`rvm list strings`.split("\n")
|
21
|
+
elsif rbenv?
|
22
|
+
`rbenv versions | cut -d '(' -f1`.split("\n").map {|x| x.sub(/\*/,'') }.map(&:strip)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def matched_version(version)
|
27
|
+
result = versions.select {|x| x =~ Regexp.new(version) }[-1]
|
28
|
+
puts("ruby '#{version}' is not installed! please install it first!") && exit unless result
|
29
|
+
result
|
30
|
+
end
|
31
|
+
|
32
|
+
def switch_ruby_version(version)
|
33
|
+
if rvm?
|
34
|
+
"rvm use #{matched_version(version)}"
|
35
|
+
elsif rbenv?
|
36
|
+
"export RBENV_VERSION=#{matched_version(version)}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/qor_test/version.rb
CHANGED
data/shell/qor_test
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qor_test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: qor_dsl
|
@@ -31,7 +31,7 @@ description: ! 'Qor Test: Make test easier!'
|
|
31
31
|
email:
|
32
32
|
- wosmvp@gmail.com
|
33
33
|
executables:
|
34
|
-
- qor_test
|
34
|
+
- qor_test.rb
|
35
35
|
extensions: []
|
36
36
|
extra_rdoc_files: []
|
37
37
|
files:
|
@@ -41,15 +41,16 @@ files:
|
|
41
41
|
- LICENSE
|
42
42
|
- README.md
|
43
43
|
- Rakefile
|
44
|
-
- bin/qor_test
|
44
|
+
- bin/qor_test.rb
|
45
45
|
- lib/qor_test.rb
|
46
|
-
- lib/qor_test/bundler.rb
|
47
46
|
- lib/qor_test/cli.rb
|
48
47
|
- lib/qor_test/configuration.rb
|
49
48
|
- lib/qor_test/gem.rb
|
50
|
-
- lib/qor_test/
|
49
|
+
- lib/qor_test/gemfile.rb
|
50
|
+
- lib/qor_test/rubies.rb
|
51
51
|
- lib/qor_test/version.rb
|
52
52
|
- qor_test.gemspec
|
53
|
+
- shell/qor_test
|
53
54
|
homepage: ''
|
54
55
|
licenses: []
|
55
56
|
post_install_message:
|
@@ -70,9 +71,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
71
|
version: '0'
|
71
72
|
requirements: []
|
72
73
|
rubyforge_project:
|
73
|
-
rubygems_version: 1.8.
|
74
|
+
rubygems_version: 1.8.23
|
74
75
|
signing_key:
|
75
76
|
specification_version: 3
|
76
77
|
summary: ! 'Qor Test: Make test easier!'
|
77
78
|
test_files: []
|
78
|
-
has_rdoc:
|
data/bin/qor_test
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
require "pathname"
|
5
|
-
bin_file = Pathname.new(__FILE__).realpath
|
6
|
-
$:.unshift File.expand_path("../../lib", bin_file)
|
7
|
-
|
8
|
-
require "qor_test"
|
9
|
-
|
10
|
-
options = Qor::Test::CLI.option_parser
|
11
|
-
Qor::Test::CLI.new(options).run
|
data/lib/qor_test/bundler.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
module Qor
|
2
|
-
module Test
|
3
|
-
class Bundler
|
4
|
-
attr_accessor :options
|
5
|
-
|
6
|
-
def initialize options={}
|
7
|
-
self.options = options
|
8
|
-
end
|
9
|
-
|
10
|
-
def gems_set_from_config
|
11
|
-
gems = Qor::Test::Configuration.gems(options).inject({}) do |s, node|
|
12
|
-
s[node.name] ||= []
|
13
|
-
s[node.name].concat Qor::Test::Gem.parse(node)
|
14
|
-
s
|
15
|
-
end.values
|
16
|
-
|
17
|
-
gems.length > 0 ? gems[0].product(*gems[1..-1]) : []
|
18
|
-
end
|
19
|
-
|
20
|
-
def gems_hash_from_gemfile
|
21
|
-
Qor::Test::Gemfile.gems(options).inject({}) do |s, node|
|
22
|
-
s[node.name.to_s] = Qor::Test::Gem.parse(node)[0]
|
23
|
-
s
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def gemspecs
|
28
|
-
[Qor::Test::Configuration.gemspecs(options), Qor::Test::Gemfile.gemspecs(options)].flatten.compact
|
29
|
-
end
|
30
|
-
|
31
|
-
def sources
|
32
|
-
[Qor::Test::Configuration.sources(options), Qor::Test::Gemfile.sources(options)].flatten.compact
|
33
|
-
end
|
34
|
-
|
35
|
-
def generate_gemfiles
|
36
|
-
gems_set = gems_set_from_config
|
37
|
-
gems_hash = gems_hash_from_gemfile
|
38
|
-
gems_name = gems_hash.keys
|
39
|
-
gemfile_length = [gems_set.length, 1].max
|
40
|
-
|
41
|
-
gemfile_dir = File.join(Qor::Test::CLI.temp_directory, "qor_test-tmp-#{Time.now.to_i}")
|
42
|
-
FileUtils.mkdir_p(gemfile_dir)
|
43
|
-
|
44
|
-
filenames = (0...gemfile_length).map do |t|
|
45
|
-
gems = []
|
46
|
-
gem_names = gems_set[t].map(&:name)
|
47
|
-
gem_names.concat(gems_name).uniq!
|
48
|
-
|
49
|
-
gem_names.map do |name|
|
50
|
-
gems << (gems_set[t].select {|g| g.name == name}[0] || gems_hash[name])
|
51
|
-
end
|
52
|
-
|
53
|
-
file = File.new(File.join(gemfile_dir, "Gemfile.#{t}"), "w+")
|
54
|
-
# Add sources
|
55
|
-
file << sources.map { |source| "source #{source.value.inspect}\n" }.uniq.join("")
|
56
|
-
# Add gemspec
|
57
|
-
file << gemspecs.map do |gemspec|
|
58
|
-
"gemspec #{gemspec.value.nil? ? '' : gemspec.value.inspect.gsub(/^\{|\}$/,'')}\n"
|
59
|
-
end.uniq.join("")
|
60
|
-
# Add gems
|
61
|
-
file << gems.map(&:to_s).join("\n")
|
62
|
-
file.close
|
63
|
-
file.path
|
64
|
-
end
|
65
|
-
|
66
|
-
filenames
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|