Skip to content

fix 'Failure/Error: expect(out.chomp).to eq('true')' in riscv64 for Bundler/gem analysis. #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gyx47
Copy link

@gyx47 gyx47 commented Mar 18, 2025

Description:

There is a problem with the test code of the ruby-pycall 1.5.2-4 package. The package builds failed under the riscv64 and goes well under x86-64 architectures. According to the log output, the signature test file reported an error when entering the test phase.

Failures:

  1) PyCall.init returns true if initialization was succeeded
     Failure/Error: expect(out.chomp).to eq('true')

       expected: "true"
            got: "Resolving dependencies...\ntrue"

       (compared using ==)

       Diff:
       @@ -1 +1,2 @@
       +Resolving dependencies...
        true
     # ./spec/pycall_spec.rb:155:in `block (3 levels) in <top (required)>'

My operating environment is the riscv64 environment virtual machine of the arch architecture of Windows WSL.
The process is as follows:

  1. I cloned your project and installed the dependencies
  2. Then execute py.test
  3. Wait for about 7 seconds and find an error

Patch

I modified the test file. Here are my ideas for modification:

This is the relevant code for the command line truncation error in /spec/pycall_spec.rb

require 'pycall'
puts(PyCall.init ? 'true' : 'false')
RUBY
      expect(status).to be_success
      expect(out.chomp).to eq('true')
    end

    it 'returns false if already initialized' do
      out, err, status = ruby(<<RUBY)

The test expects the output to be 'true', but the actual output includes an extra line Resolving dependencies...

This means that PyCall.init prints some extra information while initializing, such as "resolving dependencies" or loading libraries. On the specific architecture of riscv64, it may add some extra logging output.
To fix this, the assertion in the test can be adjusted to not strictly require every part of the output, but only focus on the last line of the output. This can be achieved by modifying the expect(out.chomp).to eq('true') statement in the test to ensure that the test only focuses on the last line of output.
expect(out.lines.last.chomp).to eq('true')

Do you think this is a good change?

@kou
Copy link
Member

kou commented May 7, 2025

Then execute py.test

Why did you execute py.test?

The test expects the output to be 'true', but the actual output includes an extra line Resolving dependencies...

Could you invest who outputs the "Resolving dependencies..."?

@kou
Copy link
Member

kou commented May 7, 2025

Bundler?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants