tiny_tds 3.1.0-x64-mingw32 → 3.2.0-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +187 -74
- data/CHANGELOG.md +8 -0
- data/Gemfile +1 -1
- data/README.md +59 -50
- data/Rakefile +46 -37
- data/VERSION +1 -1
- data/ext/tiny_tds/extconf.rb +169 -70
- data/ext/tiny_tds/extconsts.rb +3 -4
- data/lib/tiny_tds/2.7/tiny_tds.so +0 -0
- data/lib/tiny_tds/3.0/tiny_tds.so +0 -0
- data/lib/tiny_tds/bin.rb +12 -26
- data/lib/tiny_tds/client.rb +38 -42
- data/lib/tiny_tds/error.rb +0 -2
- data/lib/tiny_tds/gem.rb +5 -9
- data/lib/tiny_tds/result.rb +0 -2
- data/lib/tiny_tds/version.rb +1 -1
- data/lib/tiny_tds.rb +28 -47
- data/ports/x64-mingw32/{freetds/1.4.23/bin → bin}/defncopy.exe +0 -0
- data/ports/x64-mingw32/bin/libsybdb-5.dll +0 -0
- data/ports/x64-mingw32/bin/tsql.exe +0 -0
- data/tasks/native_gem.rake +11 -18
- data/tasks/package.rake +1 -3
- data/tasks/ports.rake +7 -91
- data/tasks/test.rake +3 -5
- data/test/bin/install-freetds.sh +2 -4
- data/test/bin/restore-from-native-gem.ps1 +10 -0
- data/test/client_test.rb +106 -112
- data/test/gem_test.rb +31 -107
- data/test/result_test.rb +208 -221
- data/test/schema_test.rb +177 -181
- data/test/test_helper.rb +58 -63
- data/test/thread_test.rb +22 -31
- data/tiny_tds.gemspec +28 -29
- metadata +25 -41
- data/ports/x64-mingw32/freetds/1.4.23/bin/bsqldb.exe +0 -0
- data/ports/x64-mingw32/freetds/1.4.23/bin/datacopy.exe +0 -0
- data/ports/x64-mingw32/freetds/1.4.23/bin/freebcp.exe +0 -0
- data/ports/x64-mingw32/freetds/1.4.23/bin/libct-4.dll +0 -0
- data/ports/x64-mingw32/freetds/1.4.23/bin/libsybdb-5.dll +0 -0
- data/ports/x64-mingw32/freetds/1.4.23/bin/osql +0 -393
- data/ports/x64-mingw32/freetds/1.4.23/bin/tdspool.exe +0 -0
- data/ports/x64-mingw32/freetds/1.4.23/bin/tsql.exe +0 -0
- data/ports/x64-mingw32/freetds/1.4.23/lib/libct.dll.a +0 -0
- data/ports/x64-mingw32/freetds/1.4.23/lib/libct.la +0 -41
- data/ports/x64-mingw32/freetds/1.4.23/lib/libsybdb.dll.a +0 -0
- data/ports/x64-mingw32/freetds/1.4.23/lib/libsybdb.la +0 -41
- data/ports/x64-mingw32/libiconv/1.17/bin/iconv.exe +0 -0
- data/ports/x64-mingw32/libiconv/1.17/bin/libcharset-1.dll +0 -0
- data/ports/x64-mingw32/libiconv/1.17/bin/libiconv-2.dll +0 -0
- data/ports/x64-mingw32/libiconv/1.17/lib/libcharset.dll.a +0 -0
- data/ports/x64-mingw32/libiconv/1.17/lib/libcharset.la +0 -41
- data/ports/x64-mingw32/libiconv/1.17/lib/libiconv.dll.a +0 -0
- data/ports/x64-mingw32/libiconv/1.17/lib/libiconv.la +0 -41
- data/ports/x64-mingw32/openssl/3.4.0/bin/c_rehash +0 -252
- data/ports/x64-mingw32/openssl/3.4.0/bin/libcrypto-3-x64.dll +0 -0
- data/ports/x64-mingw32/openssl/3.4.0/bin/libssl-3-x64.dll +0 -0
- data/ports/x64-mingw32/openssl/3.4.0/bin/openssl.exe +0 -0
- data/tasks/ports/freetds.rb +0 -32
- data/tasks/ports/libiconv.rb +0 -26
- data/tasks/ports/openssl.rb +0 -62
- data/tasks/ports/recipe.rb +0 -64
- data/test/benchmark/query.rb +0 -77
- data/test/benchmark/query_odbc.rb +0 -106
- data/test/benchmark/query_tinytds.rb +0 -126
data/test/client_test.rb
CHANGED
@@ -1,124 +1,123 @@
|
|
1
|
-
|
2
|
-
require 'test_helper'
|
1
|
+
require "test_helper"
|
3
2
|
|
4
3
|
class ClientTest < TinyTds::TestCase
|
5
|
-
describe
|
4
|
+
describe "with valid credentials" do
|
6
5
|
before do
|
7
6
|
@client = new_connection
|
8
7
|
end
|
9
8
|
|
10
|
-
it
|
9
|
+
it "must not be closed" do
|
11
10
|
assert !@client.closed?
|
12
11
|
assert @client.active?
|
13
12
|
end
|
14
13
|
|
15
|
-
it
|
14
|
+
it "allows client connection to be closed" do
|
16
15
|
assert @client.close
|
17
16
|
assert @client.closed?
|
18
17
|
assert !@client.active?
|
19
18
|
assert @client.dead?
|
20
|
-
action = lambda { @client.execute(
|
19
|
+
action = lambda { @client.execute("SELECT 1 as [one]").each }
|
21
20
|
assert_raise_tinytds_error(action) do |e|
|
22
|
-
assert_match %r{closed connection}i, e.message,
|
21
|
+
assert_match %r{closed connection}i, e.message, "ignore if non-english test run"
|
23
22
|
end
|
24
23
|
end
|
25
24
|
|
26
|
-
it
|
25
|
+
it "has getters for the tds version information (brittle since conf takes precedence)" do
|
27
26
|
if @client.tds_73?
|
28
27
|
assert_equal 11, @client.tds_version
|
29
|
-
assert_equal
|
28
|
+
assert_equal "DBTDS_7_3 - Microsoft SQL Server 2008", @client.tds_version_info
|
30
29
|
else
|
31
30
|
assert_equal 9, @client.tds_version
|
32
|
-
assert_equal
|
31
|
+
assert_equal "DBTDS_7_1/DBTDS_8_0 - Microsoft SQL Server 2000", @client.tds_version_info
|
33
32
|
end
|
34
33
|
end
|
35
34
|
|
36
|
-
it
|
37
|
-
assert_equal
|
38
|
-
assert_equal Encoding.find(
|
35
|
+
it "uses UTF-8 client charset/encoding by default" do
|
36
|
+
assert_equal "UTF-8", @client.charset
|
37
|
+
assert_equal Encoding.find("UTF-8"), @client.encoding
|
39
38
|
end
|
40
39
|
|
41
|
-
it
|
40
|
+
it "has a #escape method used for quote strings" do
|
42
41
|
assert_equal "''hello''", @client.escape("'hello'")
|
43
42
|
end
|
44
43
|
|
45
|
-
[
|
44
|
+
["CP850", "CP1252", "ISO-8859-1"].each do |encoding|
|
46
45
|
it "allows valid iconv character set - #{encoding}" do
|
46
|
+
client = new_connection(encoding: encoding)
|
47
|
+
assert_equal encoding, client.charset
|
48
|
+
assert_equal Encoding.find(encoding), client.encoding
|
49
|
+
ensure
|
50
|
+
client&.close
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
unless sqlserver_azure?
|
55
|
+
it "must be able to use :host/:port connection" do
|
56
|
+
host = ENV["TINYTDS_UNIT_HOST_TEST"] || ENV["TINYTDS_UNIT_HOST"] || "localhost"
|
57
|
+
port = ENV["TINYTDS_UNIT_PORT_TEST"] || ENV["TINYTDS_UNIT_PORT"] || 1433
|
47
58
|
begin
|
48
|
-
client = new_connection
|
49
|
-
assert_equal encoding, client.charset
|
50
|
-
assert_equal Encoding.find(encoding), client.encoding
|
59
|
+
client = new_connection dataserver: nil, host: host, port: port
|
51
60
|
ensure
|
52
|
-
client
|
61
|
+
client&.close
|
53
62
|
end
|
54
63
|
end
|
55
64
|
end
|
56
|
-
|
57
|
-
it 'must be able to use :host/:port connection' do
|
58
|
-
host = ENV['TINYTDS_UNIT_HOST_TEST'] || ENV['TINYTDS_UNIT_HOST'] || 'localhost'
|
59
|
-
port = ENV['TINYTDS_UNIT_PORT_TEST'] || ENV['TINYTDS_UNIT_PORT'] || 1433
|
60
|
-
begin
|
61
|
-
client = new_connection dataserver: nil, host: host, port: port
|
62
|
-
ensure
|
63
|
-
client.close if client
|
64
|
-
end
|
65
|
-
end unless sqlserver_azure?
|
66
65
|
end
|
67
66
|
|
68
|
-
describe
|
67
|
+
describe "With in-valid options" do
|
69
68
|
before(:all) do
|
70
69
|
init_toxiproxy
|
71
70
|
end
|
72
71
|
|
73
|
-
it
|
74
|
-
assert_raises(ArgumentError) { new_connection :
|
72
|
+
it "raises an argument error when no :host given and :dataserver is blank" do
|
73
|
+
assert_raises(ArgumentError) { new_connection dataserver: nil, host: nil }
|
75
74
|
end
|
76
75
|
|
77
|
-
it
|
78
|
-
assert_raises(ArgumentError) { TinyTds::Client.new :
|
76
|
+
it "raises an argument error when no :username is supplied" do
|
77
|
+
assert_raises(ArgumentError) { TinyTds::Client.new username: nil }
|
79
78
|
end
|
80
79
|
|
81
|
-
it
|
82
|
-
options = connection_options :
|
80
|
+
it "raises TinyTds exception with undefined :dataserver" do
|
81
|
+
options = connection_options login_timeout: 1, dataserver: "DOESNOTEXIST"
|
83
82
|
action = lambda { new_connection(options) }
|
84
83
|
assert_raise_tinytds_error(action) do |e|
|
85
84
|
# Not sure why tese are different.
|
86
85
|
if ruby_darwin?
|
87
86
|
assert_equal 20009, e.db_error_number
|
88
87
|
assert_equal 9, e.severity
|
89
|
-
assert_match %r{is unavailable or does not exist}i, e.message,
|
88
|
+
assert_match %r{is unavailable or does not exist}i, e.message, "ignore if non-english test run"
|
90
89
|
else
|
91
90
|
assert_equal 20012, e.db_error_number
|
92
91
|
assert_equal 2, e.severity
|
93
|
-
assert_match %r{server name not found in configuration files}i, e.message,
|
92
|
+
assert_match %r{server name not found in configuration files}i, e.message, "ignore if non-english test run"
|
94
93
|
end
|
95
94
|
end
|
96
95
|
assert_new_connections_work
|
97
96
|
end
|
98
97
|
|
99
|
-
it
|
100
|
-
client = new_connection :
|
98
|
+
it "raises TinyTds exception with long query past :timeout option" do
|
99
|
+
client = new_connection timeout: 1
|
101
100
|
action = lambda { client.execute("WaitFor Delay '00:00:02'").do }
|
102
101
|
assert_raise_tinytds_error(action) do |e|
|
103
102
|
assert_equal 20003, e.db_error_number
|
104
103
|
assert_equal 6, e.severity
|
105
|
-
assert_match %r{timed out}i, e.message,
|
104
|
+
assert_match %r{timed out}i, e.message, "ignore if non-english test run"
|
106
105
|
end
|
107
106
|
assert_client_works(client)
|
108
107
|
close_client(client)
|
109
108
|
assert_new_connections_work
|
110
109
|
end
|
111
110
|
|
112
|
-
it
|
113
|
-
client = new_connection :
|
111
|
+
it "must not timeout per sql batch when not under transaction" do
|
112
|
+
client = new_connection timeout: 2
|
114
113
|
client.execute("WaitFor Delay '00:00:01'").do
|
115
114
|
client.execute("WaitFor Delay '00:00:01'").do
|
116
115
|
client.execute("WaitFor Delay '00:00:01'").do
|
117
116
|
close_client(client)
|
118
117
|
end
|
119
118
|
|
120
|
-
it
|
121
|
-
client = new_connection :
|
119
|
+
it "must not timeout per sql batch when under transaction" do
|
120
|
+
client = new_connection timeout: 2
|
122
121
|
begin
|
123
122
|
client.execute("BEGIN TRANSACTION").do
|
124
123
|
client.execute("WaitFor Delay '00:00:01'").do
|
@@ -130,32 +129,30 @@ class ClientTest < TinyTds::TestCase
|
|
130
129
|
end
|
131
130
|
end
|
132
131
|
|
133
|
-
it
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
action = lambda { client.execute("waitfor delay '00:00:05'").do }
|
132
|
+
it "raises TinyTds exception with tcp socket network failure" do
|
133
|
+
client = new_connection timeout: 2, port: 1234, host: ENV["TOXIPROXY_HOST"]
|
134
|
+
assert_client_works(client)
|
135
|
+
action = lambda { client.execute("waitfor delay '00:00:05'").do }
|
138
136
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
end
|
137
|
+
# Use toxiproxy to close the TCP socket after 1 second.
|
138
|
+
# We want TinyTds to execute the statement, hit the timeout configured above, and then not be able to use the network to cancel
|
139
|
+
# the network connection needs to close after the sql batch is sent and before the timeout above is hit
|
140
|
+
Toxiproxy[:sqlserver_test].toxic(:slow_close, delay: 1000).apply do
|
141
|
+
assert_raise_tinytds_error(action) do |e|
|
142
|
+
assert_equal 20003, e.db_error_number
|
143
|
+
assert_equal 6, e.severity
|
144
|
+
assert_match %r{timed out}i, e.message, "ignore if non-english test run"
|
148
145
|
end
|
149
|
-
ensure
|
150
|
-
assert_new_connections_work
|
151
146
|
end
|
147
|
+
ensure
|
148
|
+
assert_new_connections_work
|
152
149
|
end
|
153
150
|
|
154
|
-
it
|
151
|
+
it "raises TinyTds exception with dead connection network failure" do
|
155
152
|
skip if ruby_windows?
|
156
153
|
|
157
154
|
begin
|
158
|
-
client = new_connection timeout: 2, port: 1234, host: ENV[
|
155
|
+
client = new_connection timeout: 2, port: 1234, host: ENV["TOXIPROXY_HOST"]
|
159
156
|
assert_client_works(client)
|
160
157
|
action = lambda { client.execute("waitfor delay '00:00:05'").do }
|
161
158
|
|
@@ -165,8 +162,8 @@ class ClientTest < TinyTds::TestCase
|
|
165
162
|
Toxiproxy[:sqlserver_test].toxic(:timeout, timeout: 1000).apply do
|
166
163
|
assert_raise_tinytds_error(action) do |e|
|
167
164
|
assert_equal 20047, e.db_error_number
|
168
|
-
assert_includes [1,9], e.severity
|
169
|
-
assert_match %r{dead or not enabled}i, e.message,
|
165
|
+
assert_includes [1, 9], e.severity
|
166
|
+
assert_match %r{dead or not enabled}i, e.message, "ignore if non-english test run"
|
170
167
|
end
|
171
168
|
end
|
172
169
|
ensure
|
@@ -174,99 +171,96 @@ class ClientTest < TinyTds::TestCase
|
|
174
171
|
end
|
175
172
|
end
|
176
173
|
|
177
|
-
it
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
new_connection login_timeout: 1, port: 1234, host: ENV['TOXIPROXY_HOST']
|
182
|
-
end
|
183
|
-
end
|
184
|
-
assert_raise_tinytds_error(action) do |e|
|
185
|
-
assert_equal 20003, e.db_error_number
|
186
|
-
assert_equal 6, e.severity
|
187
|
-
assert_match %r{timed out}i, e.message, 'ignore if non-english test run'
|
174
|
+
it "raises TinyTds exception with login timeout" do
|
175
|
+
action = lambda do
|
176
|
+
Toxiproxy[:sqlserver_test].toxic(:timeout, timeout: 0).apply do
|
177
|
+
new_connection login_timeout: 1, port: 1234, host: ENV["TOXIPROXY_HOST"]
|
188
178
|
end
|
189
|
-
ensure
|
190
|
-
assert_new_connections_work
|
191
179
|
end
|
180
|
+
assert_raise_tinytds_error(action) do |e|
|
181
|
+
assert_equal 20003, e.db_error_number
|
182
|
+
assert_equal 6, e.severity
|
183
|
+
assert_match %r{timed out}i, e.message, "ignore if non-english test run"
|
184
|
+
end
|
185
|
+
ensure
|
186
|
+
assert_new_connections_work
|
192
187
|
end
|
193
188
|
|
194
|
-
it
|
195
|
-
skip if ENV[
|
196
|
-
options = connection_options :
|
189
|
+
it "raises TinyTds exception with wrong :username" do
|
190
|
+
skip if ENV["CI"] && sqlserver_azure? # Some issue with db_error_number.
|
191
|
+
options = connection_options username: "willnotwork"
|
197
192
|
action = lambda { new_connection(options) }
|
198
193
|
assert_raise_tinytds_error(action) do |e|
|
199
194
|
assert_equal 18456, e.db_error_number
|
200
195
|
assert_equal 14, e.severity
|
201
|
-
assert_match %r{login failed}i, e.message,
|
196
|
+
assert_match %r{login failed}i, e.message, "ignore if non-english test run"
|
202
197
|
end
|
203
198
|
assert_new_connections_work
|
204
199
|
end
|
205
|
-
|
206
200
|
end
|
207
201
|
|
208
|
-
describe
|
202
|
+
describe "#parse_username" do
|
209
203
|
let(:client) { @client = new_connection }
|
210
204
|
|
211
|
-
it
|
205
|
+
it "returns username if azure is not true" do
|
212
206
|
_(
|
213
|
-
client.send(:parse_username, username:
|
214
|
-
).must_equal
|
207
|
+
client.send(:parse_username, username: "user@abc123.database.windows.net")
|
208
|
+
).must_equal "user@abc123.database.windows.net"
|
215
209
|
end
|
216
210
|
|
217
|
-
it
|
211
|
+
it "returns short username if azure is true" do
|
218
212
|
_(
|
219
213
|
client.send(
|
220
214
|
:parse_username,
|
221
|
-
username:
|
222
|
-
host:
|
223
|
-
azure:
|
215
|
+
username: "user@abc123.database.windows.net",
|
216
|
+
host: "abc123.database.windows.net",
|
217
|
+
azure: true
|
224
218
|
)
|
225
|
-
).must_equal
|
219
|
+
).must_equal "user@abc123"
|
226
220
|
end
|
227
221
|
|
228
|
-
it
|
222
|
+
it "returns full username if azure is false" do
|
229
223
|
_(
|
230
224
|
client.send(
|
231
225
|
:parse_username,
|
232
|
-
username:
|
233
|
-
host:
|
234
|
-
azure:
|
226
|
+
username: "user@abc123.database.windows.net",
|
227
|
+
host: "abc123.database.windows.net",
|
228
|
+
azure: false
|
235
229
|
)
|
236
|
-
).must_equal
|
230
|
+
).must_equal "user@abc123.database.windows.net"
|
237
231
|
end
|
238
232
|
|
239
|
-
it
|
233
|
+
it "returns short username if passed and azure is true" do
|
240
234
|
_(
|
241
235
|
client.send(
|
242
236
|
:parse_username,
|
243
|
-
username:
|
244
|
-
host:
|
245
|
-
azure:
|
237
|
+
username: "user@abc123",
|
238
|
+
host: "abc123.database.windows.net",
|
239
|
+
azure: true
|
246
240
|
)
|
247
|
-
).must_equal
|
241
|
+
).must_equal "user@abc123"
|
248
242
|
end
|
249
243
|
|
250
|
-
it
|
244
|
+
it "returns username with servername if passed and azure is true" do
|
251
245
|
_(
|
252
246
|
client.send(
|
253
247
|
:parse_username,
|
254
|
-
username:
|
255
|
-
host:
|
256
|
-
azure:
|
248
|
+
username: "user",
|
249
|
+
host: "abc123.database.windows.net",
|
250
|
+
azure: true
|
257
251
|
)
|
258
|
-
).must_equal
|
252
|
+
).must_equal "user@abc123"
|
259
253
|
end
|
260
254
|
|
261
|
-
it
|
255
|
+
it "returns username with servername if passed and azure is false" do
|
262
256
|
_(
|
263
257
|
client.send(
|
264
258
|
:parse_username,
|
265
|
-
username:
|
266
|
-
host:
|
267
|
-
azure:
|
259
|
+
username: "user",
|
260
|
+
host: "abc123.database.windows.net",
|
261
|
+
azure: false
|
268
262
|
)
|
269
|
-
).must_equal
|
263
|
+
).must_equal "user"
|
270
264
|
end
|
271
265
|
end
|
272
266
|
end
|
data/test/gem_test.rb
CHANGED
@@ -1,67 +1,65 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
require 'tiny_tds/gem'
|
1
|
+
require "test_helper"
|
2
|
+
require "tiny_tds/gem"
|
4
3
|
|
5
4
|
class GemTest < Minitest::Spec
|
6
|
-
gem_root ||= File.expand_path
|
5
|
+
gem_root ||= File.expand_path "../..", __FILE__
|
7
6
|
|
8
7
|
describe TinyTds::Gem do
|
9
|
-
|
10
8
|
# We're going to muck with some system globals so lets make sure
|
11
9
|
# they get set back later
|
12
|
-
original_platform = RbConfig::CONFIG[
|
10
|
+
original_platform = RbConfig::CONFIG["arch"]
|
13
11
|
original_pwd = Dir.pwd
|
14
12
|
|
15
13
|
after do
|
16
|
-
RbConfig::CONFIG[
|
14
|
+
RbConfig::CONFIG["arch"] = original_platform
|
17
15
|
Dir.chdir original_pwd
|
18
16
|
end
|
19
17
|
|
20
|
-
describe
|
18
|
+
describe "#root_path" do
|
21
19
|
let(:root_path) { TinyTds::Gem.root_path }
|
22
20
|
|
23
|
-
it
|
21
|
+
it "should be the root path" do
|
24
22
|
_(root_path).must_equal gem_root
|
25
23
|
end
|
26
24
|
|
27
|
-
it
|
28
|
-
Dir.chdir
|
25
|
+
it "should be the root path no matter the cwd" do
|
26
|
+
Dir.chdir "/"
|
29
27
|
|
30
28
|
_(root_path).must_equal gem_root
|
31
29
|
end
|
32
30
|
end
|
33
31
|
|
34
|
-
describe
|
32
|
+
describe "#ports_root_path" do
|
35
33
|
let(:ports_root_path) { TinyTds::Gem.ports_root_path }
|
36
34
|
|
37
|
-
it
|
38
|
-
_(ports_root_path).must_equal File.join(gem_root,
|
35
|
+
it "should be the ports path" do
|
36
|
+
_(ports_root_path).must_equal File.join(gem_root, "ports")
|
39
37
|
end
|
40
38
|
|
41
|
-
it
|
42
|
-
Dir.chdir
|
39
|
+
it "should be the ports path no matter the cwd" do
|
40
|
+
Dir.chdir "/"
|
43
41
|
|
44
|
-
_(ports_root_path).must_equal File.join(gem_root,
|
42
|
+
_(ports_root_path).must_equal File.join(gem_root, "ports")
|
45
43
|
end
|
46
44
|
end
|
47
45
|
|
48
|
-
describe
|
46
|
+
describe "#ports_bin_paths" do
|
49
47
|
let(:ports_bin_paths) { TinyTds::Gem.ports_bin_paths }
|
50
48
|
|
51
|
-
describe
|
49
|
+
describe "when the ports directories exist" do
|
52
50
|
let(:fake_bin_paths) do
|
53
|
-
ports_host_root = File.join(gem_root,
|
51
|
+
ports_host_root = File.join(gem_root, "ports", "fake-host-with-dirs")
|
54
52
|
[
|
55
|
-
File.join(
|
56
|
-
File.join(
|
57
|
-
File.join(
|
53
|
+
File.join("a", "bin"),
|
54
|
+
File.join("a", "inner", "bin"),
|
55
|
+
File.join("b", "bin")
|
58
56
|
].map do |p|
|
59
57
|
File.join(ports_host_root, p)
|
60
58
|
end
|
61
59
|
end
|
62
60
|
|
63
61
|
before do
|
64
|
-
RbConfig::CONFIG[
|
62
|
+
RbConfig::CONFIG["arch"] = "fake-host-with-dirs"
|
65
63
|
fake_bin_paths.each do |path|
|
66
64
|
FileUtils.mkdir_p(path)
|
67
65
|
end
|
@@ -69,108 +67,34 @@ class GemTest < Minitest::Spec
|
|
69
67
|
|
70
68
|
after do
|
71
69
|
FileUtils.remove_entry_secure(
|
72
|
-
File.join(gem_root,
|
70
|
+
File.join(gem_root, "ports", "fake-host-with-dirs"), true
|
73
71
|
)
|
74
72
|
end
|
75
73
|
|
76
|
-
it
|
74
|
+
it "should return all the bin directories" do
|
77
75
|
_(ports_bin_paths.sort).must_equal fake_bin_paths.sort
|
78
76
|
end
|
79
77
|
|
80
|
-
it
|
81
|
-
Dir.chdir
|
78
|
+
it "should return all the bin directories regardless of cwd" do
|
79
|
+
Dir.chdir "/"
|
82
80
|
_(ports_bin_paths.sort).must_equal fake_bin_paths.sort
|
83
81
|
end
|
84
82
|
end
|
85
83
|
|
86
|
-
describe
|
84
|
+
describe "when the ports directories are missing" do
|
87
85
|
before do
|
88
|
-
RbConfig::CONFIG[
|
86
|
+
RbConfig::CONFIG["arch"] = "fake-host-without-dirs"
|
89
87
|
end
|
90
88
|
|
91
|
-
it
|
89
|
+
it "should return no directories" do
|
92
90
|
_(ports_bin_paths).must_be_empty
|
93
91
|
end
|
94
92
|
|
95
|
-
it
|
96
|
-
Dir.chdir
|
93
|
+
it "should return no directories regardless of cwd" do
|
94
|
+
Dir.chdir "/"
|
97
95
|
_(ports_bin_paths).must_be_empty
|
98
96
|
end
|
99
97
|
end
|
100
98
|
end
|
101
|
-
|
102
|
-
describe '#ports_lib_paths' do
|
103
|
-
let(:ports_lib_paths) { TinyTds::Gem.ports_lib_paths }
|
104
|
-
|
105
|
-
describe 'when the ports directories exist' do
|
106
|
-
let(:fake_lib_paths) do
|
107
|
-
ports_host_root = File.join(gem_root, 'ports', 'fake-host-with-dirs')
|
108
|
-
[
|
109
|
-
File.join('a','lib'),
|
110
|
-
File.join('a','inner','lib'),
|
111
|
-
File.join('b','lib')
|
112
|
-
].map do |p|
|
113
|
-
File.join(ports_host_root, p)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
before do
|
118
|
-
RbConfig::CONFIG['arch'] = 'fake-host-with-dirs'
|
119
|
-
fake_lib_paths.each do |path|
|
120
|
-
FileUtils.mkdir_p(path)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
after do
|
125
|
-
FileUtils.remove_entry_secure(
|
126
|
-
File.join(gem_root, 'ports', 'fake-host-with-dirs'), true
|
127
|
-
)
|
128
|
-
end
|
129
|
-
|
130
|
-
it 'should return all the lib directories' do
|
131
|
-
_(ports_lib_paths.sort).must_equal fake_lib_paths.sort
|
132
|
-
end
|
133
|
-
|
134
|
-
it 'should return all the lib directories regardless of cwd' do
|
135
|
-
Dir.chdir '/'
|
136
|
-
_(ports_lib_paths.sort).must_equal fake_lib_paths.sort
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
describe 'when the ports directories are missing' do
|
141
|
-
before do
|
142
|
-
RbConfig::CONFIG['arch'] = 'fake-host-without-dirs'
|
143
|
-
end
|
144
|
-
|
145
|
-
|
146
|
-
it 'should return no directories' do
|
147
|
-
_(ports_lib_paths).must_be_empty
|
148
|
-
end
|
149
|
-
|
150
|
-
it 'should return no directories regardless of cwd' do
|
151
|
-
Dir.chdir '/'
|
152
|
-
_(ports_lib_paths).must_be_empty
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
describe '#ports_host' do
|
158
|
-
{
|
159
|
-
'x64-mingw-ucrt' => 'x64-mingw-ucrt',
|
160
|
-
'x64-mingw32' => 'x64-mingw32',
|
161
|
-
'x86_64-linux' => 'x86_64-linux',
|
162
|
-
}.each do |host,expected|
|
163
|
-
describe "on a #{host} architecture" do
|
164
|
-
before do
|
165
|
-
RbConfig::CONFIG['arch'] = host
|
166
|
-
end
|
167
|
-
|
168
|
-
it "should return a #{expected} ports host" do
|
169
|
-
_(TinyTds::Gem.ports_host).must_equal expected
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
99
|
end
|
175
100
|
end
|
176
|
-
|