diff --git a/.travis.yml b/.travis.yml index 25320325..1cb32097 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,20 +3,29 @@ language: rvm: - '2.0' - - '2.1' - - '2.2' - - '2.3.0' + - '2.3.1' matrix: fast_finish: true -install: true - before_install: - - sudo apt-get update -qq - - sudo apt-get install ruby gcc ruby-dev rake make -y + - sudo apt-get install -y lcov + +cache: bundler + + +before_script: + - bundle exec rake compile -- --enable-gcov script: - - gem build numo-narray.gemspec - - gem install numo-narray-0.9.0.3.gem + - bundle exec rake spec + - bundle exec gem build numo-narray.gemspec + - bundle exec gem install numo-narray-0.9.0.3.gem + +after_success: + - cd ${TRAVIS_BUILD_DIR} + - lcov --directory tmp --capture --output-file coverage.info # capture coverage info + - lcov --remove coverage.info '*.h' --output-file coverage.info # remove *.h coverages + - lcov --list coverage.info # debug before upload + - bundle exec coveralls-lcov --repo-token ${COVERALLS_TOKEN} coverage.info # uploads to coveralls \ No newline at end of file diff --git a/Rakefile b/Rakefile index 2b5ca481..4a3884e1 100644 --- a/Rakefile +++ b/Rakefile @@ -3,6 +3,8 @@ begin require "rake/extensiontask" require "rake_compiler_dock" require "shellwords" +require "rspec/core/rake_task" + spec = Bundler::GemHelper.gemspec @@ -12,6 +14,9 @@ Rake::ExtensionTask.new("numo/narray", spec) do |ext| ext.cross_platform = cross_platforms end +RSpec::Core::RakeTask.new("spec") +Rake::Task[:spec].prerequisites << :compile + pkg_dir = "pkg" windows_gem_paths = cross_platforms.collect do |platform| File.join(pkg_dir, "#{spec.full_name}-#{platform}.gem") diff --git a/ext/numo/narray/depend.erb b/ext/numo/narray/depend.erb index dd1c205a..7ab97c42 100644 --- a/ext/numo/narray/depend.erb +++ b/ext/numo/narray/depend.erb @@ -32,4 +32,4 @@ DEPENDS = $(C_TMPL) $(DTYPE) <%= __dir__ %>/gen/*.rb src : <%= type_c.join(" ") %> -CLEANOBJS = *.o */*.o *.bak types/*.c +CLEANOBJS = *.o */*.o *.bak types/*.c *.gcno *.gcda *.gcov types/*.gcno types/*.gcda types/*.gcov diff --git a/ext/numo/narray/extconf.rb b/ext/numo/narray/extconf.rb index db2ca207..bfb0e0cb 100644 --- a/ext/numo/narray/extconf.rb +++ b/ext/numo/narray/extconf.rb @@ -20,6 +20,11 @@ $INSTALLFILES << ['libnarray.a', '$(archdir)'] end +if enable_config("gcov") + $CFLAGS += " -coverage" + $LDFLAGS += " -coverage" +end + srcs = %w( narray array diff --git a/numo-narray.gemspec b/numo-narray.gemspec index 2c1eaec1..01ce2f1e 100644 --- a/numo-narray.gemspec +++ b/numo-narray.gemspec @@ -32,4 +32,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency "rspec", "~> 3" spec.add_development_dependency "rake-compiler", ">= 1.0.1" spec.add_development_dependency "rake-compiler-dock" + spec.add_development_dependency "coveralls-lcov" end diff --git a/spec/bit_spec.rb b/spec/bit_spec.rb index bc368635..e69ffdc7 100644 --- a/spec/bit_spec.rb +++ b/spec/bit_spec.rb @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__), "../ext/numo/narray/narray") +require_relative '../lib/numo/narray.so' #Numo::NArray.debug = true RSpec.configure do |config| diff --git a/spec/narray_spec.rb b/spec/narray_spec.rb index 93e70480..f569baaa 100644 --- a/spec/narray_spec.rb +++ b/spec/narray_spec.rb @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__), "../ext/numo/narray/narray") +require_relative "../lib/numo/narray.so" #Numo::NArray.debug = true RSpec.configure do |config|