Skip to content

Commit

Permalink
Modernize config a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
ianks committed Jul 25, 2024
1 parent e8d1209 commit b2b7b56
Show file tree
Hide file tree
Showing 11 changed files with 128 additions and 99 deletions.
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.3.0
94 changes: 48 additions & 46 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

source "https://rubygems.org"
source 'https://rubygems.org'

gemspec

gem "rake", "~> 13.0"
gem "rake-compiler", "~> 1.2"
gem "rb_sys", "~> 0.9.65"
gem "minitest", "~> 5.16"
gem 'nicetest'
gem 'rake', '~> 13.0'
gem 'rake-compiler'
gem 'rb_sys', '~> 0.9'
27 changes: 12 additions & 15 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require "rake/testtask"
require "rb_sys/extensiontask"
require 'bundler/gem_tasks'
require 'rb_sys/extensiontask'

GEMSPEC = Gem::Specification.load("oxi-test.gemspec") || abort("Could not load oxi-test.gemspec")
GEMSPEC = Gem::Specification.load('oxi-test.gemspec') || abort('Could not load oxi-test.gemspec')

RbSys::ExtensionTask.new("oxi-test", GEMSPEC) do |ext|
ext.lib_dir = "lib/oxi/test"
RbSys::ExtensionTask.new('oxi-test', GEMSPEC) do |ext|
ext.lib_dir = 'lib/oxi/test'
end

task :fmt do
sh "cargo", "fmt"
task :ruby_test do
sh('bin/test', '--reporter', 'spec')
end

Rake::TestTask.new(:ruby_test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/*_test.rb"]
task :fmt do
sh 'cargo', 'fmt'
end

desc "Build native extension for a given platform (i.e. `rake 'native[x86_64-linux]'`)"
task :native, [:platform] do |_t, platform:|
sh "bundle", "exec", "rb-sys-dock", "--platform", platform, "--build"
sh 'bundle', 'exec', 'rb-sys-dock', '--platform', platform, '--build'
end

task :cargo_test do
sh "cargo test"
sh 'cargo test'
end

task test: [:ruby_test, :cargo_test]
task test: %i[ruby_test cargo_test]

task build: :compile

Expand Down
27 changes: 27 additions & 0 deletions bin/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'nicetest' is installed as part of a gem, and
# this file is here to facilitate running it.
#

ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)

bundle_binstub = File.expand_path('bundle', __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300).include?('This file was generated by Bundler')
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end

require 'rubygems'
require 'bundler/setup'

load Gem.bin_path('nicetest', 'nicetest')
6 changes: 3 additions & 3 deletions ext/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require "mkmf"
require "rb_sys/mkmf"
require 'mkmf'
require 'rb_sys/mkmf'

create_rust_makefile("oxi/test/oxi_test")
create_rust_makefile('oxi/test/oxi_test')
6 changes: 3 additions & 3 deletions lib/oxi/test.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true

require "oxi/test/version"
require 'oxi/test/version'

begin
RUBY_VERSION =~ /(\d+\.\d+)/
require "oxi/test/#{$1}/oxi_test"
require "oxi/test/#{Regexp.last_match(1)}/oxi_test"
rescue LoadError
require "oxi/test/oxi_test"
require 'oxi/test/oxi_test'
end

module Oxi
Expand Down
2 changes: 1 addition & 1 deletion lib/oxi/test/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Oxi
module Test
VERSION = "0.1.0"
VERSION = '0.1.0'
end
end
Loading

0 comments on commit b2b7b56

Please sign in to comment.