From fe114094f71534880a85eed88602cbfcd3f46a28 Mon Sep 17 00:00:00 2001 From: Colin Dean Date: Mon, 18 Dec 2023 20:42:24 +0000 Subject: [PATCH] Duplicate frozen CHILD_STATUS to allow rspec proxy 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 ' # ./spec/bundle_utils_spec.rb:22:in `block (3 levels) in ' # ./spec/spec_helper.rb:73:in `block (3 levels) in ' # ./spec/spec_helper.rb:73:in `block (2 levels) in ' # ------------------ # --- Caused by: --- # FrozenError: # can't modify frozen object: pid 0 exit 0 # ./lib/bundle/bundle.rb:18:in `block in system' ``` --- lib/bundle/bundle.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bundle/bundle.rb b/lib/bundle/bundle.rb index ffb0b6f90..c249dbb6f 100644 --- a/lib/bundle/bundle.rb +++ b/lib/bundle/bundle.rb @@ -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