autoproj 2.14.0 → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/lint.yml +25 -0
  3. data/.github/workflows/test.yml +30 -0
  4. data/.rubocop.yml +79 -91
  5. data/.rubocop_todo.yml +1473 -0
  6. data/Gemfile +9 -9
  7. data/Rakefile +24 -24
  8. data/autoproj.gemspec +22 -22
  9. data/bin/alocate +4 -4
  10. data/bin/alog +5 -7
  11. data/bin/amake +4 -4
  12. data/bin/aup +4 -4
  13. data/bin/autoproj +3 -3
  14. data/bin/autoproj_bootstrap +185 -182
  15. data/bin/autoproj_bootstrap.in +7 -8
  16. data/bin/autoproj_install +184 -181
  17. data/bin/autoproj_install.in +6 -7
  18. data/lib/autoproj/aruba_minitest.rb +6 -11
  19. data/lib/autoproj/autobuild.rb +5 -6
  20. data/lib/autoproj/autobuild_extensions/archive_importer.rb +10 -11
  21. data/lib/autoproj/autobuild_extensions/dsl.rb +38 -34
  22. data/lib/autoproj/autobuild_extensions/git.rb +27 -26
  23. data/lib/autoproj/autobuild_extensions/package.rb +23 -22
  24. data/lib/autoproj/autobuild_extensions/svn.rb +1 -2
  25. data/lib/autoproj/base.rb +1 -1
  26. data/lib/autoproj/bash_completion.rb +5 -6
  27. data/lib/autoproj/build_option.rb +22 -24
  28. data/lib/autoproj/cli/base.rb +26 -26
  29. data/lib/autoproj/cli/bootstrap.rb +14 -16
  30. data/lib/autoproj/cli/build.rb +10 -7
  31. data/lib/autoproj/cli/cache.rb +11 -11
  32. data/lib/autoproj/cli/clean.rb +10 -10
  33. data/lib/autoproj/cli/commit.rb +7 -8
  34. data/lib/autoproj/cli/doc.rb +2 -2
  35. data/lib/autoproj/cli/envsh.rb +1 -2
  36. data/lib/autoproj/cli/exec.rb +60 -20
  37. data/lib/autoproj/cli/inspection_tool.rb +13 -7
  38. data/lib/autoproj/cli/locate.rb +30 -41
  39. data/lib/autoproj/cli/log.rb +7 -7
  40. data/lib/autoproj/cli/main.rb +213 -204
  41. data/lib/autoproj/cli/main_doc.rb +22 -21
  42. data/lib/autoproj/cli/main_global.rb +44 -19
  43. data/lib/autoproj/cli/main_plugin.rb +18 -18
  44. data/lib/autoproj/cli/main_test.rb +28 -27
  45. data/lib/autoproj/cli/manifest.rb +7 -7
  46. data/lib/autoproj/cli/osdeps.rb +12 -11
  47. data/lib/autoproj/cli/patcher.rb +2 -3
  48. data/lib/autoproj/cli/query.rb +17 -18
  49. data/lib/autoproj/cli/reconfigure.rb +1 -2
  50. data/lib/autoproj/cli/reset.rb +9 -12
  51. data/lib/autoproj/cli/show.rb +38 -39
  52. data/lib/autoproj/cli/status.rb +45 -39
  53. data/lib/autoproj/cli/switch_config.rb +5 -6
  54. data/lib/autoproj/cli/tag.rb +12 -11
  55. data/lib/autoproj/cli/test.rb +7 -7
  56. data/lib/autoproj/cli/update.rb +35 -37
  57. data/lib/autoproj/cli/utility.rb +11 -10
  58. data/lib/autoproj/cli/version.rb +42 -40
  59. data/lib/autoproj/cli/versions.rb +14 -15
  60. data/lib/autoproj/cli/watch.rb +33 -37
  61. data/lib/autoproj/cli/which.rb +16 -20
  62. data/lib/autoproj/cli.rb +4 -2
  63. data/lib/autoproj/configuration.rb +77 -84
  64. data/lib/autoproj/environment.rb +28 -13
  65. data/lib/autoproj/exceptions.rb +9 -3
  66. data/lib/autoproj/find_workspace.rb +20 -25
  67. data/lib/autoproj/git_server_configuration.rb +40 -44
  68. data/lib/autoproj/gitorious.rb +1 -1
  69. data/lib/autoproj/installation_manifest.rb +64 -29
  70. data/lib/autoproj/local_package_set.rb +13 -11
  71. data/lib/autoproj/manifest.rb +132 -130
  72. data/lib/autoproj/metapackage.rb +2 -6
  73. data/lib/autoproj/ops/atomic_write.rb +7 -6
  74. data/lib/autoproj/ops/build.rb +4 -6
  75. data/lib/autoproj/ops/cache.rb +41 -43
  76. data/lib/autoproj/ops/cached_env.rb +5 -4
  77. data/lib/autoproj/ops/configuration.rb +511 -506
  78. data/lib/autoproj/ops/import.rb +73 -63
  79. data/lib/autoproj/ops/install.rb +178 -174
  80. data/lib/autoproj/ops/loader.rb +77 -76
  81. data/lib/autoproj/ops/main_config_switcher.rb +36 -45
  82. data/lib/autoproj/ops/phase_reporting.rb +4 -4
  83. data/lib/autoproj/ops/snapshot.rb +250 -247
  84. data/lib/autoproj/ops/tools.rb +76 -78
  85. data/lib/autoproj/ops/watch.rb +6 -6
  86. data/lib/autoproj/ops/which.rb +17 -14
  87. data/lib/autoproj/options.rb +13 -2
  88. data/lib/autoproj/os_package_installer.rb +102 -92
  89. data/lib/autoproj/os_package_query.rb +7 -13
  90. data/lib/autoproj/os_package_resolver.rb +189 -140
  91. data/lib/autoproj/os_repository_installer.rb +4 -4
  92. data/lib/autoproj/os_repository_resolver.rb +8 -6
  93. data/lib/autoproj/package_definition.rb +12 -13
  94. data/lib/autoproj/package_managers/apt_dpkg_manager.rb +10 -10
  95. data/lib/autoproj/package_managers/bundler_manager.rb +147 -111
  96. data/lib/autoproj/package_managers/debian_version.rb +25 -21
  97. data/lib/autoproj/package_managers/emerge_manager.rb +2 -3
  98. data/lib/autoproj/package_managers/gem_manager.rb +68 -77
  99. data/lib/autoproj/package_managers/homebrew_manager.rb +3 -4
  100. data/lib/autoproj/package_managers/manager.rb +8 -3
  101. data/lib/autoproj/package_managers/pacman_manager.rb +2 -3
  102. data/lib/autoproj/package_managers/pip_manager.rb +20 -22
  103. data/lib/autoproj/package_managers/pkg_manager.rb +3 -4
  104. data/lib/autoproj/package_managers/port_manager.rb +2 -3
  105. data/lib/autoproj/package_managers/shell_script_manager.rb +32 -22
  106. data/lib/autoproj/package_managers/unknown_os_manager.rb +5 -8
  107. data/lib/autoproj/package_managers/yum_manager.rb +12 -15
  108. data/lib/autoproj/package_managers/zypper_manager.rb +11 -14
  109. data/lib/autoproj/package_manifest.rb +27 -26
  110. data/lib/autoproj/package_selection.rb +187 -187
  111. data/lib/autoproj/package_set.rb +127 -113
  112. data/lib/autoproj/python.rb +55 -55
  113. data/lib/autoproj/query_base.rb +20 -14
  114. data/lib/autoproj/reporter.rb +19 -19
  115. data/lib/autoproj/repository_managers/apt.rb +101 -67
  116. data/lib/autoproj/repository_managers/unknown_os_manager.rb +3 -3
  117. data/lib/autoproj/shell_completion.rb +16 -13
  118. data/lib/autoproj/source_package_query.rb +29 -36
  119. data/lib/autoproj/system.rb +32 -21
  120. data/lib/autoproj/test.rb +127 -104
  121. data/lib/autoproj/variable_expansion.rb +7 -9
  122. data/lib/autoproj/vcs_definition.rb +35 -32
  123. data/lib/autoproj/version.rb +1 -1
  124. data/lib/autoproj/workspace.rb +123 -107
  125. data/lib/autoproj/zsh_completion.rb +8 -9
  126. data/lib/autoproj.rb +53 -55
  127. data/samples/autoproj/init.rb +1 -2
  128. metadata +53 -51
  129. data/.travis.yml +0 -24
@@ -11,7 +11,7 @@ module Autoproj
11
11
 
12
12
  # Returns true if +path+ is part of an autoproj installation
13
13
  def self.in_autoproj_installation?(path)
14
- !!find_workspace_dir(path, 'workspace')
14
+ !!find_workspace_dir(path, "workspace")
15
15
  end
16
16
 
17
17
  # Forcefully sets the root directory
@@ -22,6 +22,7 @@ module Autoproj
22
22
  if @workspace && dir != @workspace.root_dir
23
23
  raise WorkspaceAlreadyCreated, "cannot switch global root directory after a workspace object got created"
24
24
  end
25
+
25
26
  @root_dir = dir
26
27
  end
27
28
 
@@ -36,10 +37,10 @@ module Autoproj
36
37
  @root_dir = ni
37
38
  return
38
39
  end
40
+
39
41
  path = Autoproj.find_workspace_dir(dir)
40
- if !path
41
- raise UserError, "not in a Autoproj installation"
42
- end
42
+ raise UserError, "not in a Autoproj installation" unless path
43
+
43
44
  path
44
45
  end
45
46
 
@@ -49,12 +50,14 @@ module Autoproj
49
50
  caller.each { |l| Autoproj.warn " #{l}" }
50
51
  workspace.config_dir
51
52
  end
53
+
52
54
  # @deprecated use workspace.overrides_dir instead
53
55
  def self.overrides_dir
54
56
  Autoproj.warn "#{__method__} is deprecated, use workspace.overrides_dir instead"
55
57
  caller.each { |l| Autoproj.warn " #{l}" }
56
58
  workspace.overrides_dir
57
59
  end
60
+
58
61
  # @deprecated use Autobuild.find_in_path instead
59
62
  #
60
63
  # Warning: the autobuild method returns nil (instead of raising) if the
@@ -62,62 +65,71 @@ module Autoproj
62
65
  def self.find_in_path(name)
63
66
  Autoproj.warn "#{__method__} is deprecated, use Autobuild.find_in_path instead"
64
67
  caller.each { |l| Autoproj.warn " #{l}" }
65
- if path = Autobuild.find_in_path(name)
66
- return path
67
- else raise ArgumentError, "cannot find #{name} in PATH (#{ENV['PATH']})"
68
+ unless (path = Autobuild.find_in_path(name))
69
+ raise ArgumentError, "cannot find #{name} in PATH (#{ENV['PATH']})"
68
70
  end
71
+
72
+ path
69
73
  end
74
+
70
75
  # @deprecated use workspace.prefix_dir instead
71
76
  def self.prefix
72
- Autoproj.warn_deprecated(__method__, 'workspace.prefix_dir')
77
+ Autoproj.warn_deprecated(__method__, "workspace.prefix_dir")
73
78
  workspace.prefix_dir
74
79
  end
80
+
75
81
  # @deprecated use workspace.prefix_dir= instead
76
82
  def self.prefix=(path)
77
- Autoproj.warn_deprecated(__method__, 'workspace.prefix_dir=')
83
+ Autoproj.warn_deprecated(__method__, "workspace.prefix_dir=")
78
84
  workspace.prefix_dir = path
79
85
  end
86
+
80
87
  # @deprecated use workspace.prefix_dir instead
81
88
  def self.build_dir
82
- Autoproj.warn_deprecated(__method__, 'workspace.prefix_dir')
89
+ Autoproj.warn_deprecated(__method__, "workspace.prefix_dir")
83
90
  workspace.prefix_dir
84
91
  end
92
+
85
93
  # @deprecated compute the full path with File.join(config_dir, file)
86
94
  # directly instead
87
95
  def self.config_file(file)
88
- Autoproj.warn_deprecated(__method__, 'compute the full path with File.join(config_dir, ...) instead')
96
+ Autoproj.warn_deprecated(__method__, "compute the full path with File.join(config_dir, ...) instead")
89
97
  File.join(config_dir, file)
90
98
  end
99
+
91
100
  # @deprecated use workspace.remotes_dir instead
92
101
  def self.remotes_dir
93
- Autoproj.warn_deprecated(__method__, 'use workspace.remotes_dir instead')
102
+ Autoproj.warn_deprecated(__method__, "use workspace.remotes_dir instead")
94
103
  workspace.remotes_dir
95
104
  end
105
+
96
106
  # @deprecated use workspace.load or add a separate Loader object to your class
97
107
  def self.load(package_set, *path)
98
108
  Autoproj.warn_deprecated(
99
109
  __method__,
100
- 'use workspace.load or add a separate Loader object to your class')
110
+ "use workspace.load or add a separate Loader object to your class"
111
+ )
101
112
  workspace.load(package_set, *path)
102
113
  end
114
+
103
115
  # @deprecated use workspace.load_if_present or add a separate Loader object to your class
104
116
  def self.load_if_present(package_set, *path)
105
117
  Autoproj.warn_deprecated(
106
118
  __method__,
107
- 'use workspace.load_if_present or add a separate Loader object to your class')
119
+ "use workspace.load_if_present or add a separate Loader object to your class"
120
+ )
108
121
  workspace.load_if_present(package_set, *path)
109
122
  end
110
123
 
111
124
  # Run the provided command as user
112
125
  def self.run_as_user(*args)
113
- if !system(*args)
114
- raise "failed to run #{args.join(" ")}"
115
- end
126
+ raise "failed to run #{args.join(' ')}" unless system(*args)
116
127
  end
128
+
117
129
  # Run the provided command as root, using sudo to gain root access
118
- def self.run_as_root(*args, env: self.workspace.env)
119
- if !system(Autobuild.tool_in_path('sudo', env: env), *args)
120
- raise "failed to run #{args.join(" ")} as root"
130
+ def self.run_as_root(*args, env: workspace.env)
131
+ unless system(Autobuild.tool_in_path("sudo", env: env), *args)
132
+ raise "failed to run #{args.join(' ')} as root"
121
133
  end
122
134
  end
123
135
 
@@ -135,4 +147,3 @@ module Autoproj
135
147
  end
136
148
  end
137
149
  end
138
-
data/lib/autoproj/test.rb CHANGED
@@ -1,30 +1,30 @@
1
1
  # simplecov must be loaded FIRST. Only the files required after it gets loaded
2
2
  # will be profiled !!!
3
- if ENV['TEST_ENABLE_COVERAGE'] == '1'
3
+ if ENV["TEST_ENABLE_COVERAGE"] == "1"
4
4
  begin
5
- require 'simplecov'
5
+ require "simplecov"
6
6
  SimpleCov.start do
7
- command_name 'master'
7
+ command_name "master"
8
8
  add_filter "/test/"
9
9
  end
10
10
  rescue LoadError
11
- require 'autoproj'
11
+ require "autoproj"
12
12
  Autoproj.warn "coverage is disabled because the 'simplecov' gem cannot be loaded"
13
13
  rescue Exception => e
14
- require 'autoproj'
14
+ require "autoproj"
15
15
  Autoproj.warn "coverage is disabled: #{e.message}"
16
16
  end
17
17
  end
18
18
 
19
- require 'minitest/autorun'
20
- require 'autoproj'
21
- require 'flexmock/minitest'
19
+ require "minitest/autorun"
20
+ require "autoproj"
21
+ require "flexmock/minitest"
22
22
  FlexMock.partials_are_based = true
23
- require 'minitest/spec'
23
+ require "minitest/spec"
24
24
 
25
- if ENV['TEST_ENABLE_PRY'] != '0'
25
+ if ENV["TEST_ENABLE_PRY"] != "0"
26
26
  begin
27
- require 'pry'
27
+ require "pry"
28
28
  rescue Exception
29
29
  Autoproj.warn "debugging is disabled because the 'pry' gem cannot be loaded"
30
30
  end
@@ -55,11 +55,13 @@ module Autoproj
55
55
  attr_reader :ws
56
56
 
57
57
  def setup
58
- if ENV['AUTOPROJ_CURRENT_ROOT']
58
+ if ENV["AUTOPROJ_CURRENT_ROOT"]
59
59
  raise "cannot have a workspace's env.sh loaded while running the "\
60
60
  "Autoproj test suite"
61
61
  end
62
62
 
63
+ Autobuild.progress_display_mode = :newline
64
+
63
65
  if defined?(Autoproj::CLI::Main)
64
66
  Autoproj::CLI::Main.default_report_on_package_failures = :raise
65
67
  end
@@ -69,8 +71,8 @@ module Autoproj
69
71
  @ws = nil
70
72
  @ws_package_managers = Hash.new
71
73
  Autobuild.logdir = make_tmpdir
72
- ws_define_package_manager 'os'
73
- ws_define_package_manager 'os_indep'
74
+ ws_define_package_manager "os"
75
+ ws_define_package_manager "os_indep"
74
76
  Autobuild.progress_display_period = 0
75
77
 
76
78
  super
@@ -91,14 +93,14 @@ module Autoproj
91
93
  if defined?(Autoproj::CLI::Main)
92
94
  Autoproj::CLI::Main.default_report_on_package_failures = nil
93
95
  end
94
- if ENV.delete('AUTOPROJ_CURRENT_ROOT')
96
+ if ENV.delete("AUTOPROJ_CURRENT_ROOT")
95
97
  raise "AUTOPROJ_CURRENT_ROOT has been set by this test !!!!"
96
98
  end
97
99
  end
98
100
 
99
101
  def data_path(*args)
100
102
  File.expand_path(File.join(*args),
101
- File.join(__dir__, '..', '..', 'test', 'data'))
103
+ File.join(__dir__, "..", "..", "test", "data"))
102
104
  end
103
105
 
104
106
  def create_bootstrap
@@ -106,7 +108,7 @@ module Autoproj
106
108
  end
107
109
 
108
110
  def skip_long_tests?
109
- ENV['AUTOPROJ_SKIP_LONG_TESTS'] == '1'
111
+ ENV["AUTOPROJ_SKIP_LONG_TESTS"] == "1"
110
112
  end
111
113
 
112
114
  def make_tmpdir
@@ -116,7 +118,7 @@ module Autoproj
116
118
  end
117
119
 
118
120
  def scripts_dir
119
- File.expand_path(File.join('..', '..', 'test', 'scripts'), __dir__)
121
+ File.expand_path(File.join("..", "..", "test", "scripts"), __dir__)
120
122
  end
121
123
 
122
124
  def find_gem_dir(gem_name)
@@ -127,38 +129,43 @@ module Autoproj
127
129
  end
128
130
 
129
131
  def autoproj_gemfile_to_local_checkout
130
- autoproj_dir = find_gem_dir('autoproj').full_gem_path
131
- autobuild_dir = find_gem_dir('autobuild').full_gem_path
132
- "source \"http://localhost:8808\"
133
- gem 'autoproj', path: '#{autoproj_dir}'
134
- gem 'autobuild', path: '#{autobuild_dir}'
135
- "
132
+ autoproj_dir = find_gem_dir("autoproj").full_gem_path
133
+ autobuild_dir = find_gem_dir("autobuild").full_gem_path
134
+ <<~GEMFILE
135
+ source "https://rubygems.org"
136
+ gem "autoproj", path: "#{autoproj_dir}"
137
+ gem "autobuild", path: "#{autobuild_dir}"
138
+ GEMFILE
136
139
  end
137
140
 
138
141
  def invoke_test_script(name, *arguments,
139
- dir: nil,
140
- gemfile_source: nil,
141
- use_autoproj_from_rubygems: (ENV['USE_AUTOPROJ_FROM_RUBYGEMS'] == '1'),
142
- interactive: true,
143
- seed_config: File.join(scripts_dir, 'seed-config.yml'),
144
- env: Hash.new, display_output: false, copy_from: nil,
145
- **system_options)
146
- package_base_dir = File.expand_path(File.join('..', '..'), __dir__)
142
+ dir: make_tmpdir,
143
+ gemfile_source: nil,
144
+ use_autoproj_from_rubygems: (ENV["USE_AUTOPROJ_FROM_RUBYGEMS"] == "1"),
145
+ interactive: true,
146
+ seed_config: File.join(scripts_dir, "seed-config.yml"),
147
+ env: {}, display_output: false, copy_from: nil,
148
+ **system_options)
149
+ package_base_dir = File.expand_path(File.join("..", ".."), __dir__)
147
150
 
148
151
  script = File.expand_path(name, scripts_dir)
149
152
  unless File.file?(script)
150
153
  raise ArgumentError, "no test script #{name} in #{scripts_dir}"
151
154
  end
152
155
 
153
- arguments << '--seed-config' << seed_config if seed_config
154
- dir ||= make_tmpdir
156
+ if env["HOME"]
157
+ @home_dir = env["HOME"]
158
+ else
159
+ env["HOME"] = (@home_dir ||= make_tmpdir)
160
+ end
161
+ arguments << "--seed-config" << seed_config if seed_config
155
162
 
156
163
  if gemfile_source || !use_autoproj_from_rubygems
157
- gemfile_path = File.join(dir, 'Gemfile-dev')
158
- File.open(gemfile_path, 'w') do |io|
164
+ gemfile_path = File.join(dir, "Gemfile-dev")
165
+ File.open(gemfile_path, "w") do |io|
159
166
  io.puts(gemfile_source || autoproj_gemfile_to_local_checkout)
160
167
  end
161
- arguments << "--gemfile" << gemfile_path << "--gem-source" << "http://localhost:8808"
168
+ arguments << "--gemfile" << gemfile_path
162
169
  end
163
170
 
164
171
  arguments << "--no-interactive" unless interactive
@@ -173,13 +180,14 @@ gem 'autobuild', path: '#{autobuild_dir}'
173
180
  result = nil
174
181
  stdout, stderr = capture_subprocess_io do
175
182
  default_env = Hash[
176
- 'TEST_COMMAND_NAME' => to_s.gsub(/[^\w]/, '_'),
177
- 'PACKAGE_BASE_DIR' => package_base_dir,
178
- 'RUBY' => Gem.ruby
183
+ "TEST_COMMAND_NAME" => to_s.gsub(/[^\w]/, "_"),
184
+ "PACKAGE_BASE_DIR" => package_base_dir,
185
+ "RUBY" => Gem.ruby
179
186
  ]
180
187
  result = Autoproj.bundler_unbundled_system(
181
188
  default_env.merge(env), script, *arguments,
182
- in: :close, **Hash[chdir: dir].merge(system_options))
189
+ in: :close, **Hash[chdir: dir].merge(system_options)
190
+ )
183
191
  end
184
192
 
185
193
  if !result
@@ -194,59 +202,64 @@ gem 'autobuild', path: '#{autobuild_dir}'
194
202
  end
195
203
 
196
204
  def fixture_gem_home
197
- File.join(__dir__, '..', '..', 'vendor', 'test_gem_home')
205
+ File.join(__dir__, "..", "..", "vendor", "test_gem_home")
198
206
  end
199
207
 
200
208
  def prepare_fixture_gem_home
201
209
  FileUtils.rm_rf fixture_gem_home
210
+ FileUtils.mkdir_p File.dirname(fixture_gem_home)
202
211
  bundled_gems_path = File.expand_path(File.join("..", ".."),
203
- find_gem_dir('utilrb').full_gem_path)
212
+ find_gem_dir("utilrb").full_gem_path)
204
213
  FileUtils.cp_r bundled_gems_path, fixture_gem_home
205
214
 
206
- vendor = File.join(__dir__, '..', '..', 'vendor')
215
+ vendor = File.join(__dir__, "..", "..", "vendor")
207
216
  bundler_filename = "bundler-#{Bundler::VERSION}.gem"
208
217
  cached_bundler_gem = File.join(vendor, bundler_filename)
209
218
  unless File.file?(cached_bundler_gem)
210
219
  FileUtils.mkdir_p vendor
211
220
  Autoproj.bundler_unbundled_system(
212
- Ops::Install.guess_gem_program, 'fetch', '-v',
213
- Bundler::VERSION, 'bundler', chdir: vendor)
214
-
215
- unless File.file?(bundler_filename)
216
- raise "cannot download the bundler gem"
221
+ Ops::Install.guess_gem_program, "fetch", "-v",
222
+ Bundler::VERSION, "bundler", chdir: vendor
223
+ )
224
+
225
+ unless File.file?(cached_bundler_gem)
226
+ existing = Dir.enum_for(:glob, File.join(vendor, "*")).to_a.sort
227
+ raise "cannot download the bundler gem. "\
228
+ "Expected #{bundler_filename}, found: #{existing.join(', ')}"
217
229
  end
218
230
  end
219
231
 
220
232
  capture_subprocess_io do
221
233
  Autoproj.bundler_unbundled_system(
222
- Hash['GEM_HOME' => fixture_gem_home, 'GEM_PATH' => nil],
223
- Ops::Install.guess_gem_program, 'install', '--no-document',
224
- cached_bundler_gem)
234
+ Hash["GEM_HOME" => fixture_gem_home, "GEM_PATH" => nil],
235
+ Ops::Install.guess_gem_program, "install", "--no-document",
236
+ cached_bundler_gem
237
+ )
225
238
  end
226
239
  end
227
240
 
228
241
  def start_gem_server(path = fixture_gem_home)
229
- require 'socket'
230
- require 'rubygems/server'
242
+ require "socket"
243
+ require "rubygems/server"
231
244
  if @gem_server_pid
232
- raise ArgumentError, "#start_gem_server already called, "\
233
- "call stop_gem_server before calling start_gem_server again"
245
+ raise ArgumentError,
246
+ "#start_gem_server already called, "\
247
+ "call stop_gem_server before calling start_gem_server again"
234
248
  end
235
249
  @gem_server_pid = spawn(
236
- Hash['RUBYOPT' => nil],
237
- Gem.ruby, Ops::Install.guess_gem_program, 'server',
238
- '--quiet', '--dir', path, out: :close, err: :close)
250
+ Hash["RUBYOPT" => nil],
251
+ Gem.ruby, Ops::Install.guess_gem_program, "server",
252
+ "--quiet", "--dir", path, out: :close, err: :close
253
+ )
239
254
  loop do
240
- begin
241
- TCPSocket.new('127.0.0.1', 8808)
242
- break
243
- rescue Errno::ECONNREFUSED # rubocop:disable Lint/HandleExceptions
244
- end
255
+ TCPSocket.new("127.0.0.1", 8808)
256
+ break
257
+ rescue Errno::ECONNREFUSED
245
258
  end
246
259
  end
247
260
 
248
261
  def stop_gem_server
249
- Process.kill 'INT', @gem_server_pid
262
+ Process.kill "INT", @gem_server_pid
250
263
  Process.waitpid @gem_server_pid
251
264
  @gem_server_pid = nil
252
265
  end
@@ -264,17 +277,18 @@ gem 'autobuild', path: '#{autobuild_dir}'
264
277
  def find_bundled_gem_path(bundler, gem_name, gemfile)
265
278
  out_r, out_w = IO.pipe
266
279
  result = Autoproj.bundler_unbundled_system(
267
- bundler, 'show', gem_name,
280
+ bundler, "show", gem_name,
268
281
  out: out_w,
269
- chdir: File.dirname(gemfile))
282
+ chdir: File.dirname(gemfile)
283
+ )
270
284
  out_w.close
271
285
  output = out_r.read.chomp
272
286
  assert result, "bundler show #{gem_name} failed, output: '#{output}'"
273
287
  output
274
288
  end
275
289
 
276
- def workspace_env(varname)
277
- _, stdout, = invoke_test_script 'display-env.sh', varname, dir: install_dir
290
+ def workspace_env(dir, varname)
291
+ _, stdout, = invoke_test_script "display-env.sh", varname, dir: dir
278
292
  stdout.chomp
279
293
  end
280
294
 
@@ -298,34 +312,36 @@ gem 'autobuild', path: '#{autobuild_dir}'
298
312
 
299
313
  def ws_create_os_package_resolver
300
314
  @ws_os_package_resolver = OSPackageResolver.new(
301
- operating_system: [['test_os_family'], ['test_os_version']],
315
+ operating_system: [["test_os_family"], ["test_os_version"]],
302
316
  package_managers: ws_package_managers.keys,
303
- os_package_manager: 'os')
317
+ os_package_manager: "os"
318
+ )
304
319
  end
305
320
 
306
321
  def ws_create(dir = make_tmpdir, partial_config: false)
307
- require 'autoproj/ops/main_config_switcher'
322
+ require "autoproj/ops/main_config_switcher"
308
323
  FileUtils.cp_r Ops::MainConfigSwitcher::MAIN_CONFIGURATION_TEMPLATE,
309
- File.join(dir, 'autoproj')
310
- FileUtils.mkdir_p File.join(dir, '.autoproj')
324
+ File.join(dir, "autoproj")
325
+ FileUtils.mkdir_p File.join(dir, ".autoproj")
311
326
 
312
327
  ws_create_os_package_resolver
313
328
  @ws = Workspace.new(
314
329
  dir, os_package_resolver: ws_os_package_resolver,
315
- package_managers: ws_package_managers)
330
+ package_managers: ws_package_managers
331
+ )
316
332
 
317
333
  unless partial_config
318
- ws.config.set 'osdeps_mode', 'all'
319
- ws.config.set 'apt_dpkg_update', true
334
+ ws.config.set "osdeps_mode", "all"
335
+ ws.config.set "apt_dpkg_update", true
320
336
  end
321
- ws.config.set 'GITHUB', 'http,ssh', true
322
- ws.config.set 'GITORIOUS', 'http,ssh', true
323
- ws.config.set 'gems_install_path', File.join(dir, 'gems')
337
+ ws.config.set "GITHUB", "http,ssh", true
338
+ ws.config.set "GITORIOUS", "http,ssh", true
339
+ ws.config.set "gems_install_path", File.join(dir, "gems")
324
340
  ws.prefix_dir = make_tmpdir
325
341
  ws.config.save
326
342
 
327
343
  # Make a valid (albeit empty) Gemfile
328
- File.open(File.join(ws.dot_autoproj_dir, 'Gemfile'), 'w').close
344
+ File.open(File.join(ws.dot_autoproj_dir, "Gemfile"), "w").close
329
345
  ws
330
346
  end
331
347
 
@@ -334,26 +350,29 @@ gem 'autobuild', path: '#{autobuild_dir}'
334
350
  end
335
351
 
336
352
  def ws_define_package_set(
337
- name, vcs = VCSDefinition.from_raw({ type: 'none' }), **options
353
+ name, vcs = VCSDefinition.from_raw({ type: "none" }),
354
+ raw_local_dir: PackageSet.raw_local_dir_of(ws, vcs)
338
355
  )
339
- package_set = PackageSet.new(ws, vcs, name: name, **options)
356
+ package_set = PackageSet.new(
357
+ ws, vcs, name: name, raw_local_dir: raw_local_dir
358
+ )
340
359
  ws.manifest.register_package_set(package_set)
341
360
  package_set
342
361
  end
343
362
 
344
363
  def ws_create_local_package_set(name, path, source_data: Hash.new, **options)
345
- vcs = VCSDefinition.from_raw(type: 'local', url: path)
364
+ vcs = VCSDefinition.from_raw({ type: "local", url: path })
346
365
  package_set = PackageSet.new(ws, vcs, name: name, **options)
347
366
  FileUtils.mkdir_p(path)
348
- File.open(File.join(path, 'source.yml'), 'w') do |io|
349
- YAML.dump(Hash['name' => name].merge(source_data), io)
367
+ File.open(File.join(path, "source.yml"), "w") do |io|
368
+ YAML.dump(Hash["name" => name].merge(source_data), io)
350
369
  end
351
370
  ws.manifest.register_package_set(package_set)
352
371
  package_set
353
372
  end
354
373
 
355
374
  def ws_add_package_set_to_layout(
356
- name, vcs = VCSDefinition.from_raw({ type: 'none' }), **options
375
+ name, vcs = VCSDefinition.from_raw({ type: "none" }), **options
357
376
  )
358
377
  package_set = ws_define_package_set(name, vcs, **options)
359
378
  ws.manifest.add_package_set_to_layout(package_set)
@@ -378,8 +397,8 @@ gem 'autobuild', path: '#{autobuild_dir}'
378
397
  end
379
398
 
380
399
  def ws_define_package(package_type, package_name,
381
- package_set: ws.manifest.main_package_set,
382
- create: true, &block)
400
+ package_set: ws.manifest.main_package_set,
401
+ create: true, &block)
383
402
  package = Autobuild.send(package_type, package_name)
384
403
  ws_setup_package(
385
404
  package, package_set: package_set, create: create, &block
@@ -387,7 +406,7 @@ gem 'autobuild', path: '#{autobuild_dir}'
387
406
  end
388
407
 
389
408
  def ws_setup_package(package, package_set: ws.manifest.main_package_set,
390
- create: true)
409
+ create: true)
391
410
  package.srcdir = File.join(ws.root_dir, package.name.to_s)
392
411
  FileUtils.mkdir_p package.srcdir if create
393
412
  autoproj_package = ws.register_package(package, nil, package_set)
@@ -399,14 +418,18 @@ gem 'autobuild', path: '#{autobuild_dir}'
399
418
  package.package_set.add_version_control_entry(package.name, vcs_spec)
400
419
  end
401
420
 
421
+ def ws_resolve_vcs(package)
422
+ package.vcs = ws.manifest.importer_definition_for(package)
423
+ end
424
+
402
425
  def ws_define_package_overrides(package, package_set, vcs_spec)
403
426
  package_set.add_overrides_entry(package.name, vcs_spec)
404
427
  end
405
428
 
406
429
  def ws_add_package_to_layout(package_type, package_name,
407
- package_set: ws.manifest.main_package_set, &block)
430
+ package_set: ws.manifest.main_package_set, &block)
408
431
  pkg = ws_define_package(package_type, package_name,
409
- package_set: package_set, &block)
432
+ package_set: package_set, &block)
410
433
  ws.manifest.add_package_to_layout(pkg)
411
434
  pkg
412
435
  end
@@ -427,26 +450,26 @@ gem 'autobuild', path: '#{autobuild_dir}'
427
450
  FileUtils.rm_rf srcdir
428
451
  end
429
452
  package.autobuild.builddir = builddir =
430
- File.join(ws.root_dir, 'build', package.name)
453
+ File.join(ws.root_dir, "build", package.name)
431
454
  package.autobuild.prefix = prefix =
432
- File.join(ws.root_dir, 'prefix', package.name)
455
+ File.join(ws.root_dir, "prefix", package.name)
433
456
  [srcdir, builddir, prefix]
434
457
  end
435
458
 
436
459
  def ws_create_git_package_set(name, source_data = Hash.new)
437
460
  dir = make_tmpdir
438
- unless system('git', 'init', chdir: dir, out: :close)
461
+ unless system("git", "init", chdir: dir, out: :close)
439
462
  raise "failed to run git init"
440
463
  end
441
464
 
442
- File.open(File.join(dir, 'source.yml'), 'w') do |io|
443
- YAML.dump(Hash['name' => name].merge(source_data), io)
465
+ File.open(File.join(dir, "source.yml"), "w") do |io|
466
+ YAML.dump(Hash["name" => name].merge(source_data), io)
444
467
  end
445
- unless system('git', 'add', 'source.yml', chdir: dir, out: :close)
468
+ unless system("git", "add", "source.yml", chdir: dir, out: :close)
446
469
  raise "failed to add the source.yml"
447
470
  end
448
471
 
449
- unless system('git', 'commit', '-m', 'add source.yml',
472
+ unless system("git", "commit", "-m", "add source.yml",
450
473
  chdir: dir, out: :close)
451
474
  raise "failed to commit the source.yml"
452
475
  end
@@ -457,7 +480,7 @@ gem 'autobuild', path: '#{autobuild_dir}'
457
480
  def ws_create_package_set_file(pkg_set, name, content)
458
481
  path = File.join(pkg_set.raw_local_dir, name)
459
482
  FileUtils.mkdir_p File.dirname(path)
460
- File.open(path, 'w') do |io|
483
+ File.open(path, "w") do |io|
461
484
  io.write content
462
485
  end
463
486
  path
@@ -466,16 +489,16 @@ gem 'autobuild', path: '#{autobuild_dir}'
466
489
  def ws_create_package_file(pkg, name, content)
467
490
  path = File.join(pkg.autobuild.srcdir, name)
468
491
  FileUtils.mkdir_p File.dirname(path)
469
- File.open(path, 'w') do |io|
492
+ File.open(path, "w") do |io|
470
493
  io.write content
471
494
  end
472
495
  path
473
496
  end
474
497
 
475
498
  def gemfile_aruba
476
- base_dir = File.expand_path('../../', __dir__)
477
- gemfile_path = File.join(base_dir, 'tmp', 'Gemfile.local')
478
- File.open(gemfile_path, 'w') do |io|
499
+ base_dir = File.expand_path("../../", __dir__)
500
+ gemfile_path = File.join(base_dir, "tmp", "Gemfile.local")
501
+ File.open(gemfile_path, "w") do |io|
479
502
  io.write <<~GEMFILE
480
503
  source 'https://rubygems.org'
481
504
  gem 'autoproj', path: '#{base_dir}'