ruby-gpgme icon indicating copy to clipboard operation
ruby-gpgme copied to clipboard

Test --use-system-libraries option in Travis CI

Open skalee opened this issue 5 years ago • 4 comments

This gem can be installed with a --use-system-libraries option, but till now it wasn't tested. This pull request fixes that.

Actually, $RUBY_GPGME_USE_SYSTEM_LIBRARIES environment variable is used instead of --use-system-libraries, but they are equivalent.

skalee avatar Mar 21 '19 22:03 skalee

Oh, I have doubled the number of build jobs so that this option is tested against every Ruby. However, if it's a problem, I can reduce it to a single additional job, e.g:

matrix:
  include:
    - env: RUBY_GPGME_USE_SYSTEM_LIBRARIES=1

skalee avatar Mar 21 '19 22:03 skalee

Coverage Status

Coverage increased (+0.1%) to 88.965% when pulling aa7722d0c8248714343dcd8f5edd45ff76dabf25 on skalee:test-with-system-libs into c9e924f33648e15775bebd12d5aff8f42d3f6efb on ueno:master.

coveralls avatar Mar 21 '19 22:03 coveralls

Coverage Status

Coverage decreased (-0.03%) to 88.798% when pulling 16a6e5afb69874dc93698059e99de6ea3453f823 on skalee:test-with-system-libs into c9e924f33648e15775bebd12d5aff8f42d3f6efb on ueno:master.

coveralls avatar Mar 21 '19 22:03 coveralls

Tests have failed for all Travis jobs which are testing --use-system-libraries option. For Ruby 2.5 build, the test summary says "111 tests, 194 assertions, 5 failures, 1 errors, 7 skips" when this option is on, and "111 tests, 205 assertions, 0 failures, 0 errors, 7 skips" when it's off.

Possibly all these errors/failures have single reason. I have investigated one of them:

  9) Error:
test_0002_selects_who_to_sign_for(GPGME::Crypto::sign):
EOFError: EOFError
    /home/travis/build/ueno/ruby-gpgme/lib/gpgme/ctx.rb:333:in `get_key'
    /home/travis/build/ueno/ruby-gpgme/lib/gpgme/key.rb:68:in `block in get'
    /home/travis/build/ueno/ruby-gpgme/lib/gpgme/ctx.rb:79:in `new'
    /home/travis/build/ueno/ruby-gpgme/lib/gpgme/key.rb:67:in `get'
    /home/travis/build/ueno/ruby-gpgme/test/crypto_test.rb:237:in `block (3 levels) in <top (required)>'
    /home/travis/.rvm/gems/ruby-2.5.0/gems/mocha-0.9.12/lib/mocha/integration/mini_test/version_201_to_202.rb:27:in `run'
    /home/travis/.rvm/gems/ruby-2.5.0/gems/minitest-2.1.0/lib/minitest/unit.rb:683:in `block in _run_suite'
    /home/travis/.rvm/gems/ruby-2.5.0/gems/minitest-2.1.0/lib/minitest/unit.rb:676:in `map'
    /home/travis/.rvm/gems/ruby-2.5.0/gems/minitest-2.1.0/lib/minitest/unit.rb:676:in `_run_suite'
    /home/travis/.rvm/gems/ruby-2.5.0/gems/minitest-2.1.0/lib/minitest/unit.rb:666:in `block in _run_suites'
    /home/travis/.rvm/gems/ruby-2.5.0/gems/minitest-2.1.0/lib/minitest/unit.rb:666:in `map'
    /home/travis/.rvm/gems/ruby-2.5.0/gems/minitest-2.1.0/lib/minitest/unit.rb:666:in `_run_suites'
    /home/travis/.rvm/gems/ruby-2.5.0/gems/minitest-2.1.0/lib/minitest/unit.rb:642:in `_run_anything'
    /home/travis/.rvm/gems/ruby-2.5.0/gems/minitest-2.1.0/lib/minitest/unit.rb:804:in `run_tests'
    /home/travis/.rvm/gems/ruby-2.5.0/gems/minitest-2.1.0/lib/minitest/unit.rb:791:in `block in _run'
    /home/travis/.rvm/gems/ruby-2.5.0/gems/minitest-2.1.0/lib/minitest/unit.rb:790:in `each'
    /home/travis/.rvm/gems/ruby-2.5.0/gems/minitest-2.1.0/lib/minitest/unit.rb:790:in `_run'
    /home/travis/.rvm/gems/ruby-2.5.0/gems/minitest-2.1.0/lib/minitest/unit.rb:779:in `run'
    /home/travis/.rvm/gems/ruby-2.5.0/gems/minitest-2.1.0/lib/minitest/unit.rb:560:in `block in autorun'

A failing test looks as follows:

    it "selects who to sign for" do
      crypto  = GPGME::Crypto.new
      sign    = crypto.sign "Hi there", :signer => KEYS.last[:sha]
      key     = GPGME::Key.get(KEYS.last[:sha]) # <= FAILS HERE
      # ...
    end

The KEYS Array contains four items as defined in test/support/resources.rb:

KEYS.map { |k| k[:sha] }
# => ["[email protected]", "[email protected]", "[email protected]", "[email protected]"]

However, the last key is unavailable in GPGME for some reason:

GPGME::Key.find(:public).flat_map(&:uids)
# => [#<GPGME::UserID Test number 1 <[email protected]> validity=unknown, signatures=[]>, #<GPGME::UserID Test number 2 <[email protected]> validity=unknown, signatures=[]>, #<GPGME::UserID Test number 3 <[email protected]> validity=unknown, signatures=[]>]
GPGME::Key.find(:secret).flat_map(&:uids)
# => [#<GPGME::UserID Test number 1 <[email protected]> validity=unknown, signatures=[]>, #<GPGME::UserID Test number 2 <[email protected]> validity=unknown, signatures=[]>, #<GPGME::UserID Test number 3 <[email protected]> validity=unknown, signatures=[]>]

Interestingly, when I tried to import that missing key by hand, it has been added:

GPGME::Key.import(KEYS.last[:public])
GPGME::Key.find(:public).flat_map(&:uids)
# => [#<GPGME::UserID Test number 1 <[email protected]> validity=unknown, signatures=[]>, #<GPGME::UserID Test number 2 <[email protected]> validity=unknown, signatures=[]>, #<GPGME::UserID Test number 3 <[email protected]> validity=unknown, signatures=[]>, #<GPGME::UserID Test number 4 <[email protected]> validity=unknown, signatures=[]>]
GPGME::Key.get(KEYS.last[:sha]) # <= NO ERROR!

Some race condition, perhaps? (EDIT: Adding sleep 1 at the end of #import_keys in test_helper.rb didn't help).

skalee avatar Mar 22 '19 18:03 skalee

Closing in favor of https://github.com/ueno/ruby-gpgme/pull/191.

stanhu avatar Aug 28 '24 05:08 stanhu