fix 'Failure/Error: expect(out.chomp).to eq('true')' in riscv64 for Bundler/gem analysis.
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)>'
- package version(s):ruby-pycall 1.5.2-4
- config and/or log files: ruby-pycall-1.5.2-4-riscv64-check.log
My operating environment is the riscv64 environment virtual machine of the arch architecture of Windows WSL. The process is as follows:
- I cloned your project and installed the dependencies
- Then execute py.test
- 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?
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..."?
Bundler?
Because only through building and testing can this package be successfully ported from the x86_64 architecture to the riscv64 architecture. the relevant codes in /spec/pycall_spec.rb that outputs the "Resolving dependencies..." are listed in "Patch" part
We should identify code that outputs the "Resolving dependencies..." (spec/pycall_spec.rb is not the code because it doesn't include puts("Resolving dependencies...") or something) and why it's outputted only on riscv64 before we think how to fix this.
I guess is in Bundler:lib/blunder.resolver.rb where
def before_resolution
Bundler.ui.info "Resolving dependencies...", debug?
end
OK. Could you add puts caller before Bundler.ui.info "Resolving dependencies...", debug?? It will show a hint why this is called.