test-kitchen 2.7.2 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70a2b4e8550bd740b74b498d123705e34431ccc5d5a7e1fe2d103600f6ced214
4
- data.tar.gz: 596588c5ab19dd10e06ff8e1ec9781bb79e87d97f9ec55750753302de7ef524d
3
+ metadata.gz: b776d094e27dc25c3f569ad96100866c9015d60593d9d99b54e30b8b6b0e4b03
4
+ data.tar.gz: 598635116f83455b7852cee81a77efc907f6ea2a9c52f8312526b9a7e6ca0922
5
5
  SHA512:
6
- metadata.gz: c41498d1f5900b67cbee755e7b1e2eb127162bd010dc8c391bb74a34945dc915b7b160361b5344f8d96a53fb254c6415bd01327aa821d3ac1407308eccf1c636
7
- data.tar.gz: 949dffda64b62446c5de2ed0635c7f17110d4237da2c2ea0419f16bbc58d601ff642fb260e3d641659a82a1476d509e207e4f4b5fe411cd383831090b37ea155
6
+ metadata.gz: ae5d8636e834c68d3565a73b9cb5a3af46246fb9b2427a80166716366cd254947049667a80a23c569f1f9eda26eb28bac4bc50fbb8eceaf55fa54cf5548a6554
7
+ data.tar.gz: d91650528d01dcac17ad882cfd260d41b2d7c1ce3118aa0a8ddecfafd935ed1b237cf5507067a512ef5fe7dc003e23d57983f5f5f5cde994e5766a02385ea8af
@@ -28,7 +28,7 @@ module Kitchen
28
28
  plugin_version Kitchen::VERSION
29
29
 
30
30
  def connection(state, &block)
31
- options = config.to_hash.merge(state)
31
+ options = connection_options(config.to_hash.merge(state))
32
32
  Kitchen::Transport::Exec::Connection.new(options, &block)
33
33
  end
34
34
 
@@ -40,19 +40,105 @@ module Kitchen
40
40
  def execute(command)
41
41
  return if command.nil?
42
42
 
43
- run_command(command)
43
+ if host_os_windows?
44
+ run_command(run_from_file_command(command))
45
+ close
46
+ else
47
+ run_command(command)
48
+ end
49
+ end
50
+
51
+ def close
52
+ if host_os_windows?
53
+ FileUtils.remove(exec_script_file)
54
+ end
44
55
  end
45
56
 
46
57
  # "Upload" the files by copying them locally.
47
58
  #
48
59
  # @see Base#upload
49
60
  def upload(locals, remote)
50
- FileUtils.mkdir_p(remote)
61
+ # evaluate $env:temp on Windows
62
+ real_remote = remote.to_s == "\$env:TEMP\\kitchen" ? kitchen_temp : remote
63
+ FileUtils.mkdir_p(real_remote)
51
64
  Array(locals).each do |local|
52
- FileUtils.cp_r(local, remote)
65
+ FileUtils.cp_r(local, real_remote)
66
+ end
67
+ end
68
+
69
+ # (see Base#init_options)
70
+ def init_options(options)
71
+ super
72
+ @instance_name = @options.delete(:instance_name)
73
+ @kitchen_root = @options.delete(:kitchen_root)
74
+ end
75
+
76
+ private
77
+
78
+ # @return [String] display name for the associated instance
79
+ # @api private
80
+ attr_reader :instance_name
81
+
82
+ # @return [String] local path to the root of the project
83
+ # @api private
84
+ attr_reader :kitchen_root
85
+
86
+ # Takes a long command and saves it to a file and uploads it to
87
+ # the test instance. Windows has cli character limits.
88
+ #
89
+ # @param command [String] a long command to be saved and uploaded
90
+ # @return [String] a command that executes the uploaded script
91
+ # @api private
92
+ def run_from_file_command(command)
93
+ if logger.debug?
94
+ debug("Creating exec script for #{instance_name} (#{exec_script_file})")
95
+ debug("Executing #{exec_script_file}")
96
+ end
97
+ File.open(exec_script_file, "wb") { |file| file.write(command) }
98
+ %{powershell -file "#{exec_script_file}"}
99
+ end
100
+
101
+ # @return [String] evaluated $env:temp variable
102
+ # @api private
103
+ def kitchen_temp
104
+ "#{ENV["temp"]}/kitchen"
105
+ end
106
+
107
+ # @return [String] name of script using instance name
108
+ # @api private
109
+ def exec_script_name
110
+ "#{instance_name}-exec-script.ps1"
111
+ end
112
+
113
+ # @return [String] file path for exec script to be run
114
+ # @api private
115
+ def exec_script_file
116
+ File.join(kitchen_root, ".kitchen", exec_script_name)
117
+ end
118
+
119
+ def host_os_windows?
120
+ case RbConfig::CONFIG["host_os"]
121
+ when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
122
+ true
123
+ else
124
+ false
53
125
  end
54
126
  end
127
+ end
128
+
129
+ private
55
130
 
131
+ # Builds the hash of options needed by the Connection object on construction.
132
+ #
133
+ # @param data [Hash] merged configuration and mutable state data
134
+ # @return [Hash] hash of connection options
135
+ # @api private
136
+ def connection_options(data)
137
+ opts = {
138
+ instance_name: instance.name,
139
+ kitchen_root: Dir.pwd,
140
+ }
141
+ opts
56
142
  end
57
143
  end
58
144
  end
@@ -16,5 +16,5 @@
16
16
  # limitations under the License.
17
17
 
18
18
  module Kitchen
19
- VERSION = "2.7.2".freeze
19
+ VERSION = "2.8.0".freeze
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-kitchen
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.2
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fletcher Nichol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-29 00:00:00.000000000 Z
11
+ date: 2020-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout
@@ -500,7 +500,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
500
500
  - !ruby/object:Gem::Version
501
501
  version: '0'
502
502
  requirements: []
503
- rubygems_version: 3.1.2
503
+ rubygems_version: 3.1.4
504
504
  signing_key:
505
505
  specification_version: 4
506
506
  summary: Test Kitchen is an integration tool for developing and testing infrastructure