summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2019-10-14 09:59:20 -0700
committerGitHub <noreply@github.com>2019-10-14 09:59:20 -0700
commit8ddb647b92dc3081e5c4b33590360baf98724f85 (patch)
treefd30bd64a6bf1b33c2d5a94af790604bf6e0f0a6
parent95ee05bb6dca6788ecd6d3663e15a442abfe40ba (diff)
parent6b53b70c67a5e4cb29b66d5765f182c46c8732d3 (diff)
downloadffi-yajl-8ddb647b92dc3081e5c4b33590360baf98724f85.tar.gz
Merge pull request #103 from chef/jsinha/fix_verify
Fix verification tests
-rw-r--r--.expeditor/buildkite/verify.ps129
-rw-r--r--.expeditor/config.yml3
-rw-r--r--.expeditor/verify.pipeline.yml57
-rw-r--r--Gemfile3
-rw-r--r--Rakefile4
-rw-r--r--appveyor.yml34
-rw-r--r--lib/ffi_yajl/ffi.rb56
-rw-r--r--lib/ffi_yajl/ffi/encoder.rb2
-rw-r--r--lib/ffi_yajl/ffi/parser.rb13
-rw-r--r--spec/ffi_yajl/map_library_name_spec.rb20
10 files changed, 123 insertions, 98 deletions
diff --git a/.expeditor/buildkite/verify.ps1 b/.expeditor/buildkite/verify.ps1
index cb4e5c8..106e1bf 100644
--- a/.expeditor/buildkite/verify.ps1
+++ b/.expeditor/buildkite/verify.ps1
@@ -2,22 +2,37 @@ echo "--- system details"
$Properties = 'Caption', 'CSName', 'Version', 'BuildType', 'OSArchitecture'
Get-CimInstance Win32_OperatingSystem | Select-Object $Properties | Format-Table -AutoSize
-# Set-Item -Path Env:Path -Value ($Env:Path + ";C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin")
-$Env:Path="C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\ruby26\bin;C:\ci-studio-common\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Users\ContainerAdministrator\AppData\Local\Microsoft\WindowsApps;C:\Go\bin;C:\Users\ContainerAdministrator\go\bin"
+echo "--- Install make and ruby2.devkit"
+choco install make ruby ruby2.devkit -y
+refreshenv
+echo - c:\tools\ruby26 > c:\tools\Devkit2\config.yml
+ruby c:\tools\Devkit2\dk.rb install
+
+choco install msys2 -y
+refreshenv
+
+Write-Output 'Updating PATH'
+$env:PATH = "C:\tools\ruby26\bin;C:\tools\DevKit2\mingw\bin;C:\tools\DevKit2\bin;" + $env:PATH
+[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine)
ruby -v
bundle --version
gem -v
-echo "--- bundle install"
-bundle install --jobs=7 --retry=3 --without docs debug
+C:\tools\ruby26\ridk_use\ridk.cmd install 3
+C:\tools\ruby26\ridk_use\ridk.cmd enable
-echo "--- bundle env"
-bundle env
+echo "--- gem install bundler"
+gem install bundler
-echo "+++ bundle exec rake"
+echo "--- bundle install"
+bundle install --without development_extras --jobs 3 --retry 3 --path vendor/bundle
+
+echo "+++ bundle exec rake compile"
bundle exec rake compile
+
+echo "+++ bundle exec rake spec"
bundle exec rake spec
exit $LASTEXITCODE \ No newline at end of file
diff --git a/.expeditor/config.yml b/.expeditor/config.yml
index ac559df..62e9610 100644
--- a/.expeditor/config.yml
+++ b/.expeditor/config.yml
@@ -7,6 +7,7 @@ slack:
# This publish is triggered by the `built_in:publish_rubygems` artifact_action.
rubygems:
- ffi-yajl
+ - ffi-yajl-universal-java
github:
# This deletes the GitHub PR branch after successfully merged into the release branch
@@ -44,4 +45,4 @@ promote:
pipelines:
- verify:
description: Pull Request validation tests
- public: true
+ public: true \ No newline at end of file
diff --git a/.expeditor/verify.pipeline.yml b/.expeditor/verify.pipeline.yml
index 825e2a1..06ca2f3 100644
--- a/.expeditor/verify.pipeline.yml
+++ b/.expeditor/verify.pipeline.yml
@@ -1,33 +1,69 @@
steps:
-- label: run-lint-and-specs-ruby-2.4
+# Allow ruby-2.4 to softfail since it was configured so in travis too
+- label: ":ruby: 2.4"
command:
- - bundle install --jobs=7 --retry=3 --without docs development
+ - ruby --version
+ - bundle --version
+ - gem update --system
+ - bundle install --without development_extras --jobs 3 --retry 3 --path vendor/bundle
+ - gem install yajl-ruby json psych
- bundle exec rake
+ soft_fail:
+ - exit_status: 1
expeditor:
executor:
docker:
- image: ruby:2.4-stretch
- privileged: true
+ image: ruby:2.4
+ environment:
+ - BUNDLE_GEMFILE=/workdir/Gemfile
+ - FORCE_FFI_YAJL="ext"
+
+- label: ":ruby: 2.5"
+ command:
+ - ruby --version
+ - bundle --version
+ - gem update --system
+ - bundle install --without development_extras --jobs 3 --retry 3 --path vendor/bundle
+ - gem install yajl-ruby json psych
+ - bundle exec rake
+ expeditor:
+ executor:
+ docker:
+ image: ruby:2.5
environment:
- BUNDLE_GEMFILE=/workdir/Gemfile
+ - FORCE_FFI_YAJL="ext"
-- label: run-lint-and-specs-ruby-2.6
+- label: ":ruby: 2.6"
command:
- - bundle install --jobs=7 --retry=3 --without docs development
+ - ruby --version
+ - bundle --version
+ - gem update --system
+ - bundle install --without development_extras --jobs 3 --retry 3 --path vendor/bundle
+ - gem install yajl-ruby json psych
- bundle exec rake
expeditor:
executor:
docker:
- image: ruby:2.6-stretch
+ image: ruby:2.6
privileged: true
environment:
- BUNDLE_GEMFILE=/workdir/Gemfile
+ - FORCE_FFI_YAJL="ext"
+# Allow jruby to softfail since it was configured so in travis too
- label: run-lint-and-specs-jruby
command:
- - bundle install --jobs=7 --retry=3 --without docs development
+ - ruby --version
+ - bundle --version
+ - gem update --system
+ - apt-get update -y && apt-get install -y git make gcc
+ - bundle install --without development_extras --jobs 3 --retry 3 --path vendor/bundle
+ - gem install ffi json psych
- bundle exec rake
+ soft_fail:
+ - exit_status: 1
expeditor:
executor:
docker:
@@ -35,10 +71,13 @@ steps:
privileged: true
environment:
- BUNDLE_GEMFILE=/workdir/Gemfile
+ - RUBY_PLATFORM="jruby"
+ - FORCE_FFI_YAJL="ffi"
-- label: run-specs-windows
+- label: "run specs :windows:"
command:
- /workdir/.expeditor/buildkite/verify.ps1
+ timeout_in_minutes: 20
expeditor:
executor:
docker:
diff --git a/Gemfile b/Gemfile
index eb1dc6c..352df49 100644
--- a/Gemfile
+++ b/Gemfile
@@ -9,7 +9,8 @@ end
group :development do
# for testing loading concurrently with yajl-ruby, not on jruby
# gem 'yajl-ruby', platforms: [ :ruby, :mswin, :mingw ]
- gem "github_changelog_generator"
+ gem "rspec"
+ gem "rake-compiler"
end
group :development_extras do
diff --git a/Rakefile b/Rakefile
index 67fe352..ce105db 100644
--- a/Rakefile
+++ b/Rakefile
@@ -22,7 +22,7 @@ rescue LoadError
end
desc "Build it and ship it"
-task ship: [:clean, :gem] do
+task ship: %i{clean gem} do
sh("git tag #{FFI_Yajl::VERSION}")
sh("git push --tags")
Dir[File.expand_path("../pkg/*.gem", __FILE__)].reverse_each do |built_gem|
@@ -133,7 +133,7 @@ desc "Run all style checks"
task style: ["style:rubocop"]
desc "Run style + spec tests by default on travis"
-task travis: %w{style spec}
+task buildkite: %w{style spec}
desc "Run style + spec tests by default"
task default: %w{compile style spec}
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index acaceed..0000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,34 +0,0 @@
-version: "master-{build}"
-
-os: Windows Server 2012 R2
-platform:
- - x64
-
-environment:
- matrix:
- - RUBY_VERSION: "23"
-
-clone_folder: c:\projects\ffi-yajl
-clone_depth: 1
-skip_tags: true
-branches:
- only:
- - master
-
-install:
- - SET PATH=C:\Ruby%RUBY_VERSION%\bin;C:\Ruby23\DevKit\mingw\bin;C:\Ruby23\DevKit\bin;%PATH%
- - echo %PATH%
- - ruby --version
- - gem update --system || gem update --system || gem update --system
- - gem --version
- - bundler --version
-
-build_script:
- - bundle install || bundle install || bundle install
-
-test_script:
- # compile needs to have the devkit loaded up
- # - C:\Ruby21\DevKit\devkitvars.bat
- - echo %PATH%
- - bundle exec rake compile
- - bundle exec rake spec
diff --git a/lib/ffi_yajl/ffi.rb b/lib/ffi_yajl/ffi.rb
index 7211c79..25bb852 100644
--- a/lib/ffi_yajl/ffi.rb
+++ b/lib/ffi_yajl/ffi.rb
@@ -42,24 +42,24 @@ module FFI_Yajl
class YajlCallbacks < ::FFI::Struct
layout :yajl_null, :pointer,
- :yajl_boolean, :pointer,
- :yajl_integer, :pointer,
- :yajl_double, :pointer,
- :yajl_number, :pointer,
- :yajl_string, :pointer,
- :yajl_start_map, :pointer,
- :yajl_map_key, :pointer,
- :yajl_end_map, :pointer,
- :yajl_start_array, :pointer,
- :yajl_end_array, :pointer
+ :yajl_boolean, :pointer,
+ :yajl_integer, :pointer,
+ :yajl_double, :pointer,
+ :yajl_number, :pointer,
+ :yajl_string, :pointer,
+ :yajl_start_map, :pointer,
+ :yajl_map_key, :pointer,
+ :yajl_end_map, :pointer,
+ :yajl_start_array, :pointer,
+ :yajl_end_array, :pointer
end
- enum :yajl_status, [
- :yajl_status_ok,
- :yajl_status_client_canceled,
- :yajl_status_insufficient_data,
- :yajl_status_error,
- ]
+ enum :yajl_status, %i{
+ yajl_status_ok
+ yajl_status_client_canceled
+ yajl_status_insufficient_data
+ yajl_status_error
+ }
# FFI::Enums are slow, should remove the rest
# enum :yajl_gen_status, [
@@ -97,22 +97,22 @@ module FFI_Yajl
# const char *yajl_status_to_string (yajl_status code)
attach_function :yajl_status_to_string, [ :yajl_status ], :string
# yajl_handle yajl_alloc(const yajl_callbacks * callbacks, yajl_alloc_funcs * afs, void * ctx)
- attach_function :yajl_alloc, [:pointer, :pointer, :pointer], :yajl_handle
+ attach_function :yajl_alloc, %i{pointer pointer pointer}, :yajl_handle
# void yajl_free (yajl_handle handle)
attach_function :yajl_free, [:yajl_handle], :void
# yajl_status yajl_parse (yajl_handle hand, const unsigned char *jsonText, unsigned int jsonTextLength)
- attach_function :yajl_parse, [:yajl_handle, :ustring, :uint], :yajl_status
+ attach_function :yajl_parse, %i{yajl_handle ustring uint}, :yajl_status
# yajl_status yajl_parse_complete (yajl_handle hand)
attach_function :yajl_complete_parse, [:yajl_handle], :yajl_status
# unsigned char *yajl_get_error (yajl_handle hand, int verbose, const unsigned char *jsonText, unsigned int jsonTextLength)
- attach_function :yajl_get_error, [:yajl_handle, :int, :ustring, :int], :ustring
+ attach_function :yajl_get_error, %i{yajl_handle int ustring int}, :ustring
# void yajl_free_error (yajl_handle hand, unsigned char *str)
- attach_function :yajl_free_error, [:yajl_handle, :ustring], :void
+ attach_function :yajl_free_error, %i{yajl_handle ustring}, :void
#
- attach_function :yajl_config, [:yajl_handle, :yajl_option, :varargs], :int
+ attach_function :yajl_config, %i{yajl_handle yajl_option varargs}, :int
- attach_function :yajl_gen_config, [:yajl_gen, :yajl_gen_option, :varargs], :int
+ attach_function :yajl_gen_config, %i{yajl_gen yajl_gen_option varargs}, :int
# yajl_gen yajl_gen_alloc (const yajl_alloc_funcs *allocFuncs)
attach_function :yajl_gen_alloc, [:pointer], :yajl_gen
@@ -121,18 +121,18 @@ module FFI_Yajl
# void yajl_gen_free (yajl_gen handle)
attach_function :yajl_gen_free, [:yajl_gen], :void
- attach_function :yajl_gen_integer, [:yajl_gen, :long_long], :int
- attach_function :yajl_gen_double, [:yajl_gen, :double], :int
- attach_function :yajl_gen_number, [:yajl_gen, :ustring, :int], :int
- attach_function :yajl_gen_string, [:yajl_gen, :ustring, :int], :int
+ attach_function :yajl_gen_integer, %i{yajl_gen long_long}, :int
+ attach_function :yajl_gen_double, %i{yajl_gen double}, :int
+ attach_function :yajl_gen_number, %i{yajl_gen ustring int}, :int
+ attach_function :yajl_gen_string, %i{yajl_gen ustring int}, :int
attach_function :yajl_gen_null, [:yajl_gen], :int
- attach_function :yajl_gen_bool, [:yajl_gen, :int], :int
+ attach_function :yajl_gen_bool, %i{yajl_gen int}, :int
attach_function :yajl_gen_map_open, [:yajl_gen], :int
attach_function :yajl_gen_map_close, [:yajl_gen], :int
attach_function :yajl_gen_array_open, [:yajl_gen], :int
attach_function :yajl_gen_array_close, [:yajl_gen], :int
# yajl_gen_status yajl_gen_get_buf (yajl_gen hand, const unsigned char **buf, unsigned int *len)
- attach_function :yajl_gen_get_buf, [:yajl_gen, :pointer, :pointer], :int
+ attach_function :yajl_gen_get_buf, %i{yajl_gen pointer pointer}, :int
# void yajl_gen_clear (yajl_gen hand)
attach_function :yajl_gen_clear, [:yajl_gen], :void
end
diff --git a/lib/ffi_yajl/ffi/encoder.rb b/lib/ffi_yajl/ffi/encoder.rb
index 62b2c96..e5fbfdb 100644
--- a/lib/ffi_yajl/ffi/encoder.rb
+++ b/lib/ffi_yajl/ffi/encoder.rb
@@ -161,6 +161,7 @@ class Integer
if str == "NaN" || str == "Infinity" || str == "-Infinity"
raise ::FFI_Yajl::EncodeError, "'#{str}' is an invalid number"
end
+
if state[:processing_key]
if ( status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize) ) != 0
FFI_Yajl::Encoder.raise_error_for_status(status, str)
@@ -179,6 +180,7 @@ class Float
if str == "NaN" || str == "Infinity" || str == "-Infinity"
raise ::FFI_Yajl::EncodeError, "'#{str}' is an invalid number"
end
+
if state[:processing_key]
if ( status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize) ) != 0
FFI_Yajl::Encoder.raise_error_for_status(status, str)
diff --git a/lib/ffi_yajl/ffi/parser.rb b/lib/ffi_yajl/ffi/parser.rb
index fa9d599..d991d67 100644
--- a/lib/ffi_yajl/ffi/parser.rb
+++ b/lib/ffi_yajl/ffi/parser.rb
@@ -30,6 +30,7 @@ module FFI_Yajl
if @opts[:unique_key_checking] && stack.last.key?(key)
raise FFI_Yajl::ParseError, "repeated key: #{key}"
end
+
stack.last[key] = val
when Array
stack.last.push(val)
@@ -55,15 +56,15 @@ module FFI_Yajl
set_value(nil)
1
end
- @boolean_callback = ::FFI::Function.new(:int, [:pointer, :int]) do |ctx, boolval|
+ @boolean_callback = ::FFI::Function.new(:int, %i{pointer int}) do |ctx, boolval|
set_value(boolval == 1 ? true : false)
1
end
- @integer_callback = ::FFI::Function.new(:int, [:pointer, :long_long]) do |ctx, intval|
+ @integer_callback = ::FFI::Function.new(:int, %i{pointer long_long}) do |ctx, intval|
set_value(intval)
1
end
- @number_callback = ::FFI::Function.new(:int, [:pointer, :string, :size_t ]) do |ctx, stringval, stringlen|
+ @number_callback = ::FFI::Function.new(:int, %i{pointer string size_t}) do |ctx, stringval, stringlen|
s = stringval.slice(0, stringlen)
s.force_encoding("UTF-8") if defined? Encoding
# XXX: I can't think of a better way to do this right now. need to call to_f if and only if its a float.
@@ -71,11 +72,11 @@ module FFI_Yajl
set_value(v)
1
end
- @double_callback = ::FFI::Function.new(:int, [:pointer, :double]) do |ctx, doubleval|
+ @double_callback = ::FFI::Function.new(:int, %i{pointer double}) do |ctx, doubleval|
set_value(doubleval)
1
end
- @string_callback = ::FFI::Function.new(:int, [:pointer, :string, :size_t]) do |ctx, stringval, stringlen|
+ @string_callback = ::FFI::Function.new(:int, %i{pointer string size_t}) do |ctx, stringval, stringlen|
s = stringval.slice(0, stringlen)
s.force_encoding("UTF-8") if defined? Encoding
set_value(s)
@@ -86,7 +87,7 @@ module FFI_Yajl
stack.push({})
1
end
- @map_key_callback = ::FFI::Function.new(:int, [:pointer, :string, :size_t]) do |ctx, key, keylen|
+ @map_key_callback = ::FFI::Function.new(:int, %i{pointer string size_t}) do |ctx, key, keylen|
s = key.slice(0, keylen)
s.force_encoding("UTF-8") if defined? Encoding
self.key = @opts[:symbolize_keys] ? s.to_sym : s
diff --git a/spec/ffi_yajl/map_library_name_spec.rb b/spec/ffi_yajl/map_library_name_spec.rb
index b16483f..6ec8bb6 100644
--- a/spec/ffi_yajl/map_library_name_spec.rb
+++ b/spec/ffi_yajl/map_library_name_spec.rb
@@ -27,17 +27,17 @@ class Test
end
host_os_library_name_mapping = {
- "mingw" => [ "libyajl.so", "yajl.dll" ],
- "mswin" => [ "libyajl.so", "yajl.dll" ],
- "cygwin" => [ "libyajl.so", "cygyajl.dll" ],
- "darwin" => [ "libyajl.bundle", "libyajl.dylib" ],
+ "mingw" => [ "libyajl.so", "yajl.dll" ],
+ "mswin" => [ "libyajl.so", "yajl.dll" ],
+ "cygwin" => [ "libyajl.so", "cygyajl.dll" ],
+ "darwin" => [ "libyajl.bundle", "libyajl.dylib" ],
"solaris2" => [ "libyajl.so" ],
- "linux" => [ "libyajl.so" ],
- "aix" => [ "libyajl.so" ],
- "hpux" => [ "libyajl.so" ],
- "netbsd" => [ "libyajl.so" ],
- "openbsd" => [ "libyajl.so" ],
- "freebsd" => [ "libyajl.so" ],
+ "linux" => [ "libyajl.so" ],
+ "aix" => [ "libyajl.so" ],
+ "hpux" => [ "libyajl.so" ],
+ "netbsd" => [ "libyajl.so" ],
+ "openbsd" => [ "libyajl.so" ],
+ "freebsd" => [ "libyajl.so" ],
}
describe "FFI_Yajl::MapLibraryName" do