Skip to content

Commit

Permalink
Merge pull request #121 from mvz/rubocop-rake
Browse files Browse the repository at this point in the history
Add rubocop-rake and fix offenses
  • Loading branch information
mvz committed Jun 3, 2023
2 parents af77732 + bd3ef1b commit d7bba83
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 20 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require:
- rubocop-minitest
- rubocop-packaging
- rubocop-performance
- rubocop-rake

AllCops:
NewCops: enable
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ Rake::Manifest::Task.new do |t|
t.patterns = ["lib/**/*.rb", "*.md", "COPYING.LIB"]
end

task build: "manifest:check"
task build: ["manifest:check"]

task default: [:test, "manifest:check"]
1 change: 1 addition & 0 deletions gir_ffi-gtk.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "rubocop-minitest", "~> 0.31.0"
spec.add_development_dependency "rubocop-packaging", "~> 0.5.2"
spec.add_development_dependency "rubocop-performance", "~> 1.18"
spec.add_development_dependency "rubocop-rake", "~> 0.6.0"
spec.add_development_dependency "simplecov", "~> 0.22.0"
end
20 changes: 5 additions & 15 deletions tasks/test.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,17 @@ require "rake/testtask"

namespace :test do
Rake::TestTask.new(:gtk3) do |t|
t.libs = ["lib"]
t.libs << "test"
t.test_files = FileList["test/**/*_test.rb"]
t.ruby_opts += ["-w", "-Itest"]
t.ruby_opts += ["-rgir_ffi-gtk3"]
end

Rake::TestTask.new(:gtk2) do |t|
t.libs = ["lib"]
t.libs << "test"
t.test_files = FileList["test/**/*_test.rb"]
t.ruby_opts += ["-w", "-Itest"]
end

task gtk2: :set_gtk_version_2

task :set_gtk_version_2 do
ENV["GTK_VERSION"] = "2"
end

task :sleep do
sleep 1
t.ruby_opts += ["-rgir_ffi-gtk2"]
end
end

desc "Run unit tests"
task test: ["test:gtk3", "test:sleep", "test:gtk2"]
task test: ["test:gtk3", "test:gtk2"]
12 changes: 8 additions & 4 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@

Thread.abort_on_exception = true

if ENV["GTK_VERSION"] == "2"
require "gir_ffi-gtk2"
else
require "gir_ffi-gtk3"
unless defined? Gtk
if ENV["GTK_VERSION"] == "2"
require "gir_ffi-gtk2"
else
require "gir_ffi-gtk3"
end
end

warn "Testing with Gtk version #{Gtk::MAJOR_VERSION}.#{Gtk::MINOR_VERSION}"

module BaseTestExtensions
def assert_nothing_raised
yield
Expand Down

0 comments on commit d7bba83

Please sign in to comment.