Module: WWTD
- Defined in:
- lib/wwtd.rb,
lib/wwtd/cli.rb,
lib/wwtd/run.rb,
lib/wwtd/ruby.rb,
lib/wwtd/version.rb
Defined Under Namespace
Modules: CLI, Ruby Classes: Run
Constant Summary collapse
- CONFIG =
".travis.yml"
- DEFAULT_GEMFILE =
"Gemfile"
- COMBINATORS =
["rvm", "gemfile", "env"]
- UNDERSTOOD =
COMBINATORS + ["matrix", "script", "bundler_args"]
- VERSION =
"1.4.0"
Class Method Summary collapse
-
.escaped_env(env, options = {}) ⇒ Object
internal api needs the export to work on ruby 1.9 / linux.
- .read_travis_yml(options = {}) ⇒ Object
- .run(matrix, options, &block) ⇒ Object
Class Method Details
.escaped_env(env, options = {}) ⇒ Object
internal api needs the export to work on ruby 1.9 / linux
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/wwtd.rb', line 60 def escaped_env(env, ={}) return "" if env.empty? if [:rerun] && gemfile = env["BUNDLE_GEMFILE"] env["BUNDLE_GEMFILE"] = gemfile.sub("#{Dir.pwd}/", "") end env = env.map { |k,v| "#{k}=#{Shellwords.escape(v)}" } if [:rerun] env.join(" ") + " " else env.map { |e| "export #{e}" }.join(" && ") + " && " end end |
.read_travis_yml(options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/wwtd.rb', line 18 def read_travis_yml(={}) config = (File.exist?(CONFIG) ? YAML.load_file(CONFIG) : {}) config.delete("source_key") # we don't need that we already have the source ignored = (config.keys - UNDERSTOOD - Array([:use])) + Array([:ignore]) calculate_local_ruby_matrix = ( ignored.include?("rvm") && Array(config["rvm"]).include?(RUBY_VERSION) && config["matrix"] ) ignored.each { |i| config.delete(i) unless i == "rvm" && calculate_local_ruby_matrix } matrix = matrix(config) if calculate_local_ruby_matrix matrix.delete_if { |m| m["rvm"] != RUBY_VERSION } matrix.each { |m| m.delete("rvm") } end [matrix, ignored] end |
.run(matrix, options, &block) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/wwtd.rb', line 40 def run(matrix, , &block) with_clean_dot_bundle do with_clean_env do Dir.mktmpdir do |lock| in_multiple_threads(matrix.each_with_index, [:parallel]) do |config, i| # set env as parallel_tests does to reuse existing infrastructure env = {} env["TEST_ENV_NUMBER"] = (i == 0 ? "" : (i + 1).to_s) if [:parallel] if [:only_bundle] config['script'] = 'test "only bundle"' end Run.new(config, env, lock).execute(&block) end end end end end |