Skip to content

Commit

Permalink
Fix FreeTDS utility wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
andyundso committed Jan 8, 2025
1 parent b81d563 commit 95d9bce
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 64 deletions.
40 changes: 39 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ jobs:
ruby -e "require 'tiny_tds'; puts TinyTds::Gem.root_path"
exit $LASTEXITCODE
- name: Test if tsql wrapper works
shell: pwsh
run: |
tsql-ttds -C
exit $LASTEXITCODE
- name: Test if defncopy wrapper works
shell: pwsh
run: |
defncopy
exit $LASTEXITCODE
test-windows-mingw:
needs:
- cross-compile
Expand Down Expand Up @@ -207,6 +219,18 @@ jobs:
ruby -e "require 'tiny_tds'; puts TinyTds::Gem.root_path"
exit $LASTEXITCODE
- name: Test if tsql wrapper works
shell: pwsh
run: |
tsql-ttds -C
exit $LASTEXITCODE
- name: Test if defncopy wrapper works
shell: pwsh
run: |
defncopy
exit $LASTEXITCODE
test-windows-ucrt:
needs:
- cross-compile
Expand Down Expand Up @@ -317,6 +341,18 @@ jobs:
ruby -e "require 'tiny_tds'; puts TinyTds::Gem.root_path"
exit $LASTEXITCODE
- name: Test if tsql wrapper works
shell: pwsh
run: |
tsql-ttds -C
exit $LASTEXITCODE
- name: Test if defncopy wrapper works
shell: pwsh
run: |
defncopy
exit $LASTEXITCODE
install-linux:
needs:
- cross-compile
Expand Down Expand Up @@ -372,7 +408,9 @@ jobs:
gem update --system 3.3.22 &&
${{ matrix.bootstrap }}
gem install --no-document ./gems/tiny_tds-$(cat VERSION)-${{ matrix.platform }}.gem &&
ruby -e \"require 'tiny_tds'; puts TinyTds::Gem.root_path\"
ruby -e \"require 'tiny_tds'; puts TinyTds::Gem.root_path\" &&
tsql-ttds -C &&
defncopy-ttds
"
test-linux:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* Reduce number of files shipped with precompiled Windows gem
* Provide precompiled gem for Linux (GNU + MUSL / 64-bit x86 + ARM)
* Fix wrappers for `tsql` and `defncopy` utility.

## 3.1.0

Expand Down
12 changes: 10 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,17 @@ Rake::ExtensionTask.new('tiny_tds', SPEC) do |ext|
spec.metadata.delete('msys2_mingw_dependencies')

if spec.platform.to_s =~ /mingw/
spec.files << "ports/#{spec.platform.to_s}/bin/libsybdb-5.dll"
spec.files += [
"ports/#{spec.platform.to_s}/bin/libsybdb-5.dll",
"ports/#{spec.platform.to_s}/bin/defncopy.exe",
"ports/#{spec.platform.to_s}/bin/tsql.exe"
]
elsif spec.platform.to_s =~ /linux/
spec.files << "ports/#{spec.platform.to_s}/lib/libsybdb.so.5"
spec.files += [
"ports/#{spec.platform.to_s}/lib/libsybdb.so.5",
"ports/#{spec.platform.to_s}/bin/defncopy",
"ports/#{spec.platform.to_s}/bin/tsql"
]
end
end

Expand Down
8 changes: 2 additions & 6 deletions lib/tiny_tds/gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@ def ports_root_path
end

def ports_bin_paths
Dir.glob(File.join(ports_root_path,ports_host,'**','bin'))
Dir.glob(File.join(ports_root_path, '**', 'bin'))
end

def ports_lib_paths
Dir.glob(File.join(ports_root_path,ports_host,'**','lib'))
end

def ports_host
RbConfig::CONFIG["arch"]
Dir.glob(File.join(ports_root_path, '**', 'lib'))
end
end
end
Expand Down
55 changes: 0 additions & 55 deletions test/gem_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,61 +99,6 @@ class GemTest < Minitest::Spec
end
end

describe '#ports_lib_paths' do
let(:ports_lib_paths) { TinyTds::Gem.ports_lib_paths }

describe 'when the ports directories exist' do
let(:fake_lib_paths) do
ports_host_root = File.join(gem_root, 'ports', 'fake-host-with-dirs')
[
File.join('a','lib'),
File.join('a','inner','lib'),
File.join('b','lib')
].map do |p|
File.join(ports_host_root, p)
end
end

before do
RbConfig::CONFIG['arch'] = 'fake-host-with-dirs'
fake_lib_paths.each do |path|
FileUtils.mkdir_p(path)
end
end

after do
FileUtils.remove_entry_secure(
File.join(gem_root, 'ports', 'fake-host-with-dirs'), true
)
end

it 'should return all the lib directories' do
_(ports_lib_paths.sort).must_equal fake_lib_paths.sort
end

it 'should return all the lib directories regardless of cwd' do
Dir.chdir '/'
_(ports_lib_paths.sort).must_equal fake_lib_paths.sort
end
end

describe 'when the ports directories are missing' do
before do
RbConfig::CONFIG['arch'] = 'fake-host-without-dirs'
end


it 'should return no directories' do
_(ports_lib_paths).must_be_empty
end

it 'should return no directories regardless of cwd' do
Dir.chdir '/'
_(ports_lib_paths).must_be_empty
end
end
end

describe '#ports_host' do
{
'x64-mingw-ucrt' => 'x64-mingw-ucrt',
Expand Down

0 comments on commit 95d9bce

Please sign in to comment.