wreq 1.2.6-x86_64-linux → 1.2.8-x86_64-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92e7474db16ed2402299619c5810018fad110426be40b823dc661427febd1dec
4
- data.tar.gz: 2bfa63ed7bba9967543083ebb792fa33b81398f37e9cf71fea5e718a50da56c7
3
+ metadata.gz: ed61b521403984486ad993107d84945937f51ee755729da7be3109885259746f
4
+ data.tar.gz: cd42e0c9fd6a2647ee66623a1d955ddcfd45ea0328c61a8329ae5a7926b45610
5
5
  SHA512:
6
- metadata.gz: 8f46547e76ac3ab622c91cab11918bb720955841d9862b6a672f113cd47113f7b96f4a2b5e2ad0b66e039962c3e0ee0f5e4a7a789b1f24a0b6278c2c78840bd4
7
- data.tar.gz: 856a9592e1fcb72a7c868e144040e10bd796cf7bd47b96e9755ed29fc2bcc683c36d4c0b1f2114692ef6cdf25c2b10560b41675faf1a6647e661b3e9220e3ab9
6
+ metadata.gz: 8c8a3d6af46a2461345a41c265a6b66ffe2769797f7fd9d7247a83e5ff5729219b62f632d862a55b6c12d20f8d56ba3f483532627660ed81daf833be7cc5d3ba
7
+ data.tar.gz: 793557a664cb7d0ee16e9f22fceae0fdde52e479ada83da5c6af566493fd286ae9b34be2a099ffafdd730c5446704a934a369ebe5f800342dd4a187463f635f9
@@ -0,0 +1,4 @@
1
+ # Rake creates or removes this host-specific file when switching platforms.
2
+ include = [
3
+ { path = "windows.toml", optional = true },
4
+ ]
data/Rakefile CHANGED
@@ -1,5 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "script/rust_env"
4
+
5
+ # Cargo needs RubyInstaller's UCRT tools when Rake builds the native extension
6
+ # on Windows. Other platforms keep their existing native Cargo environment.
7
+ Wreq::RustEnv.activate
8
+
3
9
  require "bundler/gem_tasks"
4
10
  require "rake/testtask"
5
11
  require "rb_sys/extensiontask"
@@ -43,7 +43,7 @@ async fn main() -> wreq::Result<()> {
43
43
  .build()?;
44
44
 
45
45
  // Use the API you're already familiar with
46
- let resp = client.get("https://www.google.com").send().await?;
46
+ let resp = client.get("https://pingly.us.kg/api/all").send().await?;
47
47
  println!("{}", resp.text().await?);
48
48
  Ok(())
49
49
  }
@@ -57,14 +57,60 @@ DLL Name: KERNEL32.dll
57
57
  problematic `Sleep` reference can come from Rust std, MinGW, or pthread-related
58
58
  linking paths, not only from `windows-sys`.
59
59
 
60
- Verified with:
60
+ Windows builds use the `x86_64-pc-windows-gnu` target and the RubyInstaller
61
+ UCRT toolchain. The Rakefile configures that environment automatically, so the
62
+ extension and tests can be built with:
61
63
 
62
64
  ```powershell
63
- .\script\build_windows_gnu.ps1 -SkipBundleInstall -SkipToolInstall -RunTests
65
+ rustup target add x86_64-pc-windows-gnu
66
+ ridk exec pacman -S --needed --noconfirm `
67
+ mingw-w64-ucrt-x86_64-gcc `
68
+ mingw-w64-ucrt-x86_64-clang `
69
+ mingw-w64-ucrt-x86_64-cmake `
70
+ mingw-w64-ucrt-x86_64-pkgconf
71
+ bundle exec rake test
64
72
  ```
65
73
 
74
+ The first Rake invocation also writes a machine-local `.cargo/windows.toml`.
75
+ The checked-in `.cargo/config.toml` loads it automatically, so Cargo and Rust
76
+ language servers use the same GNU target and RubyInstaller tools without
77
+ editor-specific settings.
78
+
79
+ ## RubyInstaller development tools
80
+
81
+ RubyInstaller adds Ruby itself to `PATH`, but it does not enable the bundled
82
+ MSYS2 development environment globally. Running `ridk enable` adds tools such
83
+ as GCC, CMake, and Make to the current terminal only. This is normally useful
84
+ because it avoids conflicts with other Windows toolchains.
85
+
86
+ Rust language servers start Cargo directly and do not run `ridk enable` or the
87
+ Rakefile first. Add RubyInstaller's `ucrt64\bin` and `usr\bin` directories to
88
+ the user `PATH` so Cargo can load GCC, libclang, and their dependent DLLs from
89
+ any editor:
90
+
91
+ ```powershell
92
+ $rubyRoot = ruby -rrbconfig -e "print RbConfig::CONFIG.fetch('prefix')"
93
+ $required = @(
94
+ (Join-Path $rubyRoot "msys64\ucrt64\bin"),
95
+ (Join-Path $rubyRoot "msys64\usr\bin")
96
+ )
97
+ $userPath = [Environment]::GetEnvironmentVariable("Path", "User")
98
+ $entries = @($userPath -split ";" | Where-Object {
99
+ $_ -and $_ -notin $required
100
+ })
101
+ $entries = $required + $entries
102
+ [Environment]::SetEnvironmentVariable("Path", ($entries -join ";"), "User")
103
+ ```
104
+
105
+ Restart the editor after changing `PATH` so its language server inherits the
106
+ updated environment. Run `bundle exec rake compile` once after installing or
107
+ switching Ruby so `.cargo/windows.toml` points to the active RubyInstaller.
108
+ Run a Rake command after switching the same checkout between Windows and WSL;
109
+ Windows generates this local configuration, while other platforms remove it.
110
+
66
111
  Result:
67
112
 
68
113
  ```text
69
- 160 runs, 775 assertions, 0 failures, 0 errors
114
+ 254 runs, 1198 assertions, 0 failures, 0 errors
115
+ 2 Rust tests passed
70
116
  ```
data/extconf.rb CHANGED
@@ -1,4 +1,8 @@
1
1
  require "mkmf"
2
+ require_relative "script/rust_env"
3
+
4
+ Wreq::RustEnv.activate
5
+
2
6
  # We use rb_sys for makefile generation only.
3
7
  # We can use `RB_SYS_CARGO_PROFILE` to choose Cargo profile
4
8
  # Read more https://github.com/oxidize-rb/rb-sys/blob/main/gem/README.md
Binary file
Binary file
Binary file
@@ -2,6 +2,10 @@
2
2
 
3
3
  unless defined?(Wreq)
4
4
  module Wreq
5
+ # Keep interruption outside StandardError so a broad transport rescue
6
+ # never swallows a Ruby interrupt.
7
+ class InterruptError < Interrupt; end
8
+
5
9
  # System-level and runtime errors
6
10
 
7
11
  # Memory allocation failed.
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rbconfig"
4
+ require "fileutils"
5
+
6
+ module Wreq
7
+ module RustEnv
8
+ WINDOWS_GNU_TARGET = "x86_64-pc-windows-gnu"
9
+ WINDOWS_RUBY_PLATFORM = "x64-mingw-ucrt"
10
+
11
+ # Uses the UCRT toolchain shipped with the active RubyInstaller installation.
12
+ def self.activate
13
+ unless RbConfig::CONFIG["host_os"].match?(/mingw|mswin/)
14
+ FileUtils.rm_f(cargo_config_path)
15
+ return
16
+ end
17
+
18
+ ruby_platform = RbConfig::CONFIG.fetch("arch")
19
+ unless ruby_platform == WINDOWS_RUBY_PLATFORM
20
+ raise "Unsupported Windows Ruby platform: #{ruby_platform}. " \
21
+ "Use RubyInstaller UCRT (#{WINDOWS_RUBY_PLATFORM})."
22
+ end
23
+
24
+ ruby_root = RbConfig::CONFIG.fetch("prefix")
25
+ msys_root = File.join(ruby_root, "msys64")
26
+ ucrt_bin = File.join(msys_root, "ucrt64", "bin")
27
+ msys_bin = File.join(msys_root, "usr", "bin")
28
+
29
+ validate_tools(ucrt_bin, msys_bin)
30
+ write_cargo_config(ucrt_bin, msys_bin)
31
+ ENV["CARGO_BUILD_TARGET"] = WINDOWS_GNU_TARGET
32
+ ENV["LIBCLANG_PATH"] = ucrt_bin
33
+ ENV.delete("CMAKE_GENERATOR")
34
+ ENV["PATH"] = [ucrt_bin, msys_bin, ENV.fetch("PATH", nil)].compact.join(File::PATH_SEPARATOR)
35
+ end
36
+
37
+ # Reports missing RubyInstaller packages before Cargo starts compiling.
38
+ def self.validate_tools(ucrt_bin, msys_bin)
39
+ required = %w[gcc.exe g++.exe gcc-ar.exe clang.exe libclang.dll cmake.exe]
40
+ .map { |tool| File.join(ucrt_bin, tool) }
41
+ .append(File.join(msys_bin, "make.exe"))
42
+ missing = required.reject { |tool| File.file?(tool) }
43
+ unless %w[pkgconf.exe pkg-config.exe].any? { |tool| File.file?(File.join(ucrt_bin, tool)) }
44
+ missing << File.join(ucrt_bin, "pkgconf.exe")
45
+ end
46
+ return if missing.empty?
47
+
48
+ raise "Missing RubyInstaller UCRT tools: #{missing.join(", ")}. " \
49
+ "Install the Windows build dependencies documented in " \
50
+ "docs/windows-gnu-tokio-crash.md."
51
+ end
52
+
53
+ # Generates machine-local Cargo defaults that work in command lines and IDEs.
54
+ def self.write_cargo_config(ucrt_bin, msys_bin)
55
+ config = <<~TOML
56
+ # Generated by script/rust_env.rb for the active RubyInstaller.
57
+
58
+ [build]
59
+ target = "#{WINDOWS_GNU_TARGET}"
60
+
61
+ [target.#{WINDOWS_GNU_TARGET}]
62
+ linker = "#{File.join(ucrt_bin, "gcc.exe")}"
63
+
64
+ [env]
65
+ CC_x86_64_pc_windows_gnu = { value = "#{File.join(ucrt_bin, "gcc.exe")}", force = true }
66
+ CXX_x86_64_pc_windows_gnu = { value = "#{File.join(ucrt_bin, "g++.exe")}", force = true }
67
+ AR_x86_64_pc_windows_gnu = { value = "#{File.join(ucrt_bin, "gcc-ar.exe")}", force = true }
68
+ CMAKE = { value = "#{File.join(ucrt_bin, "cmake.exe")}", force = true }
69
+ CMAKE_GENERATOR = { value = "MSYS Makefiles", force = true }
70
+ CMAKE_MAKE_PROGRAM = { value = "#{File.join(msys_bin, "make.exe")}", force = true }
71
+ LIBCLANG_PATH = { value = "#{ucrt_bin}", force = true }
72
+ TOML
73
+
74
+ return if File.exist?(cargo_config_path) && File.binread(cargo_config_path) == config
75
+
76
+ FileUtils.mkdir_p(File.dirname(cargo_config_path))
77
+ File.binwrite(cargo_config_path, config)
78
+ end
79
+
80
+ # Returns the ignored Cargo configuration shared by Rake and language servers.
81
+ def self.cargo_config_path
82
+ File.expand_path("../.cargo/windows.toml", __dir__)
83
+ end
84
+ end
85
+ end
@@ -1,6 +1,37 @@
1
1
  require "test_helper"
2
+ require "socket"
3
+ require "timeout"
2
4
 
3
5
  class ErrorHandlingTest < Minitest::Test
6
+ def test_interrupt_error_stays_outside_standard_error
7
+ assert_equal Interrupt, Wreq::InterruptError.superclass
8
+ refute_operator Wreq::InterruptError, :<, StandardError
9
+ end
10
+
11
+ def test_request_interruption_raises_interrupt_error
12
+ request_thread = nil
13
+ with_hanging_server do |url, accepted|
14
+ request_thread = Thread.new do
15
+ Wreq.get(url, timeout: 60)
16
+ rescue Interrupt, StandardError => error
17
+ error
18
+ end
19
+ request_thread.report_on_exception = false
20
+
21
+ Timeout.timeout(5) { accepted.pop }
22
+ request_thread.wakeup
23
+
24
+ assert request_thread.join(5), "Interrupted request thread should stop"
25
+
26
+ error = request_thread.value
27
+ assert_instance_of Wreq::InterruptError, error
28
+ refute_kind_of StandardError, error
29
+ end
30
+ ensure
31
+ request_thread&.kill
32
+ request_thread&.join(1)
33
+ end
34
+
4
35
  def test_network_error_handling
5
36
  # Try to connect to a non-existent domain
6
37
  response = Wreq.get("https://definitely-not-a-real-domain-12345.com")
@@ -89,4 +120,27 @@ class ErrorHandlingTest < Minitest::Test
89
120
  end
90
121
  end
91
122
  end
123
+
124
+ private
125
+
126
+ def with_hanging_server
127
+ server = TCPServer.new("127.0.0.1", 0)
128
+ accepted = Queue.new
129
+ thread = Thread.new do
130
+ socket = server.accept
131
+ accepted << true
132
+ sleep
133
+ rescue IOError, SystemCallError
134
+ nil
135
+ ensure
136
+ socket&.close unless socket&.closed?
137
+ end
138
+ thread.report_on_exception = false
139
+
140
+ yield "http://127.0.0.1:#{server.addr[1]}/", accepted
141
+ ensure
142
+ server&.close unless server&.closed?
143
+ thread&.kill
144
+ thread&.join(1)
145
+ end
92
146
  end
data/wreq.gemspec CHANGED
@@ -56,7 +56,7 @@ Gem::Specification.new do |spec|
56
56
  # Exclude non-Ruby files from RDoc to prevent parsing errors
57
57
  spec.rdoc_options = ["--exclude", "Cargo\\..*", "--exclude", "\\.rs$"]
58
58
 
59
- spec.requirements = ["Rust >= 1.85"]
59
+ spec.requirements = ["Rust >= 1.97"]
60
60
  # use a Ruby version which:
61
61
  # - supports Rubygems with the ability of compilation of Rust gem
62
62
  # - not end of life
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wreq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 1.2.8
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - SearchApi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-07-24 00:00:00.000000000 Z
11
+ date: 2026-07-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: An easy and powerful Ruby HTTP client with advanced browser fingerprinting
14
14
  that accurately emulates Chrome, Edge, Firefox, Safari, Opera, and OkHttp with precise
@@ -20,6 +20,7 @@ extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
22
  - "./extconf.rb"
23
+ - ".cargo/config.toml"
23
24
  - Gemfile
24
25
  - LICENSE
25
26
  - README.md
@@ -60,7 +61,7 @@ files:
60
61
  - lib/wreq_ruby/http.rb
61
62
  - lib/wreq_ruby/response.rb
62
63
  - script/build_platform_gem.rb
63
- - script/build_windows_gnu.ps1
64
+ - script/rust_env.rb
64
65
  - test/body_sender_test.rb
65
66
  - test/client_cookie_test.rb
66
67
  - test/client_test.rb
@@ -112,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
113
  - !ruby/object:Gem::Version
113
114
  version: '0'
114
115
  requirements:
115
- - Rust >= 1.85
116
+ - Rust >= 1.97
116
117
  rubygems_version: 3.5.23
117
118
  signing_key:
118
119
  specification_version: 4
@@ -1,270 +0,0 @@
1
- param(
2
- [switch]$SkipBundleInstall,
3
- [switch]$SkipToolInstall,
4
- [switch]$BuildGem,
5
- [switch]$TestGem,
6
- [switch]$RunTests,
7
- [string]$SmokeUrl = $env:WREQ_SMOKE_URL
8
- )
9
-
10
- $ErrorActionPreference = "Stop"
11
-
12
- $target = "x86_64-pc-windows-gnu"
13
- $platform = "x64-mingw-ucrt"
14
- $gemPattern = "pkg\wreq-*-$platform.gem"
15
- if ([string]::IsNullOrWhiteSpace($SmokeUrl)) {
16
- $SmokeUrl = "https://httpbin.io/get"
17
- }
18
- $rubyRoot = Split-Path (Split-Path (Get-Command ruby).Source -Parent) -Parent
19
- $ucrt = Join-Path $rubyRoot "msys64\ucrt64"
20
- $ucrtBin = Join-Path $ucrt "bin"
21
- $msysPackages = @(
22
- "mingw-w64-ucrt-x86_64-gcc",
23
- "mingw-w64-ucrt-x86_64-clang",
24
- "mingw-w64-ucrt-x86_64-cmake",
25
- "mingw-w64-ucrt-x86_64-pkgconf"
26
- )
27
-
28
- function Invoke-Step {
29
- param(
30
- [string]$Name,
31
- [scriptblock]$Command
32
- )
33
-
34
- Write-Host "==> $Name"
35
- # Native command failures do not honor ErrorActionPreference in Windows PowerShell.
36
- $global:LASTEXITCODE = 0
37
- & $Command
38
- if ($LASTEXITCODE -ne 0) {
39
- throw "$Name failed with exit code $LASTEXITCODE."
40
- }
41
- }
42
-
43
- function Get-MissingUcrtTools {
44
- $missing = @()
45
-
46
- if (-not (Test-Path (Join-Path $ucrtBin "gcc.exe")) -or -not (Test-Path (Join-Path $ucrtBin "g++.exe"))) {
47
- $missing += "gcc/g++"
48
- }
49
-
50
- if (-not (Test-Path (Join-Path $ucrtBin "clang.exe")) -or -not (Test-Path (Join-Path $ucrtBin "libclang.dll"))) {
51
- $missing += "clang/libclang"
52
- }
53
-
54
- if (-not (Test-Path (Join-Path $ucrtBin "cmake.exe"))) {
55
- $missing += "cmake"
56
- }
57
-
58
- if (-not (Test-Path (Join-Path $ucrtBin "pkgconf.exe")) -and -not (Test-Path (Join-Path $ucrtBin "pkg-config.exe"))) {
59
- $missing += "pkgconf"
60
- }
61
-
62
- $missing
63
- }
64
-
65
- function Get-LatestPlatformGem {
66
- $gem = Get-ChildItem -Path $gemPattern -ErrorAction SilentlyContinue |
67
- Sort-Object LastWriteTime -Descending |
68
- Select-Object -First 1
69
-
70
- if (-not $gem) {
71
- throw "No Windows GNU platform gem found at '$gemPattern'. Re-run with -BuildGem first."
72
- }
73
-
74
- $gem
75
- }
76
-
77
- function Invoke-RubySmoke {
78
- param(
79
- [string]$Name,
80
- [string]$Code
81
- )
82
-
83
- Write-Host "Smoke: $Name"
84
- ruby -e $Code
85
- if ($LASTEXITCODE -ne 0) {
86
- throw "$Name failed with exit code $LASTEXITCODE."
87
- }
88
- }
89
-
90
- Invoke-Step "Check Ruby platform" {
91
- $rubyArch = & ruby -rrbconfig -e "print RbConfig::CONFIG['arch']"
92
- if ($rubyArch -ne $platform) {
93
- throw "Expected Ruby platform '$platform', got '$rubyArch'. Use RubyInstaller UCRT for this build."
94
- }
95
-
96
- ruby -v
97
- ruby -rrbconfig -rrubygems -e "puts RbConfig::CONFIG.values_at('arch', 'host', 'CC').join(%q{ }); puts Gem::Platform.local"
98
- }
99
-
100
- Invoke-Step "Install Rust target" {
101
- $installedTargets = @(rustup target list --installed)
102
- if ($installedTargets -contains $target) {
103
- Write-Host "Rust target $target already installed; skipping rustup."
104
- return
105
- }
106
-
107
- rustup target add $target
108
- if ($LASTEXITCODE -ne 0) {
109
- throw "Failed to install Rust target $target."
110
- }
111
- }
112
-
113
- Invoke-Step "Check MSYS2 UCRT build tools" {
114
- $missing = @(Get-MissingUcrtTools)
115
- if ($missing.Count -eq 0) {
116
- Write-Host "MSYS2 UCRT build tools already present; skipping pacman."
117
- return
118
- }
119
-
120
- if ($SkipToolInstall) {
121
- throw "Missing MSYS2 UCRT build tools: $($missing -join ', '). Re-run without -SkipToolInstall or install them with ridk."
122
- }
123
-
124
- Write-Host "Missing MSYS2 UCRT build tools: $($missing -join ', ')"
125
- ridk exec pacman -S --needed --noconfirm @msysPackages
126
- if ($LASTEXITCODE -ne 0) {
127
- $stillMissing = @(Get-MissingUcrtTools)
128
- if ($stillMissing.Count -eq 0) {
129
- Write-Warning "pacman returned exit code $LASTEXITCODE, but all required tools are present; continuing."
130
- $global:LASTEXITCODE = 0
131
- return
132
- }
133
-
134
- throw "Failed to install MSYS2 UCRT build tools. Missing: $($stillMissing -join ', '). If pacman cannot lock its database, close other pacman/ridk shells, run PowerShell as Administrator, or install RubyInstaller in a user-writable directory."
135
- }
136
- }
137
-
138
- Invoke-Step "Configure Windows GNU toolchain" {
139
- $env:CARGO_BUILD_TARGET = $target
140
- $env:LIBCLANG_PATH = $ucrtBin
141
- $env:CC_x86_64_pc_windows_gnu = Join-Path $ucrtBin "gcc.exe"
142
- $env:CXX_x86_64_pc_windows_gnu = Join-Path $ucrtBin "g++.exe"
143
- $env:CMAKE = Join-Path $ucrtBin "cmake.exe"
144
- Remove-Item Env:\CMAKE_GENERATOR -ErrorAction SilentlyContinue
145
-
146
- rustc -Vv
147
- Write-Host "LIBCLANG_PATH=$env:LIBCLANG_PATH"
148
- Write-Host "CC_x86_64_pc_windows_gnu=$env:CC_x86_64_pc_windows_gnu"
149
- Write-Host "CXX_x86_64_pc_windows_gnu=$env:CXX_x86_64_pc_windows_gnu"
150
- Write-Host "CMAKE=$env:CMAKE"
151
- }
152
-
153
- if (-not $SkipBundleInstall) {
154
- Invoke-Step "Install Ruby dependencies" {
155
- bundle install
156
- }
157
- }
158
-
159
- Invoke-Step "Compile native extension" {
160
- ridk exec ruby -S bundle exec rake compile
161
- }
162
-
163
- Invoke-Step "Sync versioned extension" {
164
- $rubyMinor = & ruby -e "print RUBY_VERSION[/\A\d+\.\d+/]"
165
- $dest = "lib\wreq_ruby\$rubyMinor"
166
- New-Item -ItemType Directory -Force $dest | Out-Null
167
- Copy-Item "lib\wreq_ruby\wreq_ruby.so" (Join-Path $dest "wreq_ruby.so") -Force
168
- }
169
-
170
- Invoke-Step "Verify extension loads" {
171
- ruby -Ilib -rwreq -e "puts Wreq::VERSION; puts Wreq::Client.new.class"
172
- }
173
-
174
- if ($RunTests) {
175
- Invoke-Step "Run tests" {
176
- ridk exec ruby -S bundle exec rake test
177
- }
178
- }
179
-
180
- if ($BuildGem) {
181
- Invoke-Step "Build local platform gem" {
182
- $rubyMinor = & ruby -e "print RUBY_VERSION[/\A\d+\.\d+/]"
183
- $dest = "lib\wreq_ruby\$rubyMinor"
184
- New-Item -ItemType Directory -Force $dest | Out-Null
185
- Copy-Item "lib\wreq_ruby\wreq_ruby.so" (Join-Path $dest "wreq_ruby.so") -Force
186
-
187
- ruby script/build_platform_gem.rb $platform
188
- }
189
- }
190
-
191
- if ($TestGem) {
192
- Invoke-Step "Install and smoke test platform gem" {
193
- $gem = Get-LatestPlatformGem
194
- $gemHome = Join-Path ([System.IO.Path]::GetTempPath()) "wreq-gem-test-$PID"
195
- $gemBin = Join-Path $gemHome "bin"
196
- $testDir = Join-Path ([System.IO.Path]::GetTempPath()) "wreq-gem-test-cwd-$PID"
197
-
198
- Remove-Item -Recurse -Force $gemHome, $testDir -ErrorAction SilentlyContinue
199
- New-Item -ItemType Directory -Force $gemHome, $gemBin, $testDir | Out-Null
200
-
201
- $oldGemHome = $env:GEM_HOME
202
- $oldGemPath = $env:GEM_PATH
203
- $oldGemrc = $env:GEMRC
204
- $oldRubyopt = $env:RUBYOPT
205
- $oldRubylib = $env:RUBYLIB
206
- $oldBundleGemfile = $env:BUNDLE_GEMFILE
207
- $oldBundleBinPath = $env:BUNDLE_BIN_PATH
208
- $oldBundlerVersion = $env:BUNDLER_VERSION
209
- $oldSmokeUrl = $env:WREQ_SMOKE_URL
210
- $oldWreqGemHome = $env:WREQ_GEM_HOME
211
-
212
- try {
213
- $env:GEM_HOME = $gemHome
214
- $env:GEM_PATH = $gemHome
215
- $env:GEMRC = ""
216
- $env:RUBYOPT = ""
217
- $env:RUBYLIB = ""
218
- $env:BUNDLE_GEMFILE = ""
219
- $env:BUNDLE_BIN_PATH = ""
220
- $env:BUNDLER_VERSION = ""
221
- $env:WREQ_SMOKE_URL = $SmokeUrl
222
- $env:WREQ_GEM_HOME = $gemHome
223
-
224
- gem install --norc --local --install-dir $gemHome --bindir $gemBin --no-document --force --no-user-install $gem.FullName
225
- if ($LASTEXITCODE -ne 0) {
226
- throw "Failed to install $($gem.FullName)."
227
- }
228
-
229
- Push-Location $testDir
230
- try {
231
- Invoke-RubySmoke "Load installed platform gem" @'
232
- STDOUT.sync = true
233
- STDERR.sync = true
234
- require "wreq"
235
- spec = Gem.loaded_specs.fetch("wreq")
236
- expected = File.expand_path(ENV.fetch("WREQ_GEM_HOME"))
237
- actual = File.expand_path(spec.full_gem_path)
238
- raise "loaded #{actual}, expected under #{expected}" unless actual.start_with?(expected)
239
- puts "loaded #{spec.full_name}"
240
- puts actual
241
- puts "wreq #{Wreq::VERSION}"
242
- '@
243
-
244
- Invoke-RubySmoke "Request through installed platform gem" @'
245
- STDOUT.sync = true
246
- STDERR.sync = true
247
- require "wreq"
248
- client = Wreq::Client.new
249
- resp = client.get(ENV.fetch("WREQ_SMOKE_URL"), timeout: 20)
250
- puts "HTTP #{resp.code}"
251
- raise "unexpected status #{resp.code}" unless resp.code == 200
252
- '@
253
- } finally {
254
- Pop-Location
255
- }
256
- } finally {
257
- $env:GEM_HOME = $oldGemHome
258
- $env:GEM_PATH = $oldGemPath
259
- $env:GEMRC = $oldGemrc
260
- $env:RUBYOPT = $oldRubyopt
261
- $env:RUBYLIB = $oldRubylib
262
- $env:BUNDLE_GEMFILE = $oldBundleGemfile
263
- $env:BUNDLE_BIN_PATH = $oldBundleBinPath
264
- $env:BUNDLER_VERSION = $oldBundlerVersion
265
- $env:WREQ_SMOKE_URL = $oldSmokeUrl
266
- $env:WREQ_GEM_HOME = $oldWreqGemHome
267
- Remove-Item -Recurse -Force $gemHome, $testDir -ErrorAction SilentlyContinue
268
- }
269
- }
270
- }