Skip to content

Commit

Permalink
Duplicate frozen CHILD_STATUS to allow rspec proxy
Browse files Browse the repository at this point in the history
Without this, a test fails because rspec is unable to proxy $CHILD_STATUS/$?. I looked around for another way to handle this but there's no way to unfreeze except through duplication.

```
1) Bundle when the system call fails emits all stdout output even if verbose is false
     Failure/Error: success = st.success?

     ArgumentError:
       Cannot proxy frozen objects, rspec-mocks relies on proxies for method stubbing and expectations.
     # ./lib/bundle/bundle.rb:18:in `block in system'
     # ./lib/bundle/bundle.rb:12:in `popen'
     # ./lib/bundle/bundle.rb:12:in `system'
     # ./spec/bundle_utils_spec.rb:22:in `block (4 levels) in <top (required)>'
     # ./spec/bundle_utils_spec.rb:22:in `block (3 levels) in <top (required)>'
     # ./spec/spec_helper.rb:73:in `block (3 levels) in <top (required)>'
     # ./spec/spec_helper.rb:73:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # FrozenError:
     #   can't modify frozen object: pid 0 exit 0
     #   ./lib/bundle/bundle.rb:18:in `block in system'
```
  • Loading branch information
colindean committed Dec 18, 2023
1 parent 706e92f commit fe11409
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/bundle/bundle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def system(cmd, *args, verbose: false)
logs << buf
end
Process.wait(pipe.pid)
success = $CHILD_STATUS.success?
success = $CHILD_STATUS.dup.success?
pipe.close
end
puts logs.join unless success
Expand Down

0 comments on commit fe11409

Please sign in to comment.