How to unblock an application with socketfilterfw? I am compiling a software from scratch and running its tests. I do this often. The tests open ports and expect connections.

Whenever I run the tests, I get the


  Do you want the application “run-tests” to accept incoming network connections?
  Clicking Deny may limit the application’s behavior. This setting can be changed in the Firewall pane of Security &amp; Privacy preferences.


dialog box. I click on Allow every time. To avoid this I am trying to unblock the application with socketfilterfw. So, I am trying the following commands in a script file

SFW="/usr/libexec/ApplicationFirewall/socketfilterfw"
TESTS_DEBUG="/Users/thefourtheye/git/libuv/out/Debug/run-tests"
${SFW} --remove "$TESTS_DEBUG"
${SFW} --add "$TESTS_DEBUG"
${SFW} --unblock "$TESTS_DEBUG"


Whenever I execute the script file, it always gives the following

The application is not part of the firewall 
Application at path ( /Users/thefourtheye/git/libuv/out/Debug/run-tests ) added to firewall 
The application is not part of the firewall 


If I run my tests after this, it still shows the dialog box.

The TESTS_DEBUG file is not a link, it is an executable binary file.

➜  libuv git:(v1.x) ✗ file /Users/thefourtheye/git/libuv/out/Debug/run-tests
/Users/thefourtheye/git/libuv/out/Debug/run-tests: Mach-O 64-bit executable x86_64
➜  libuv git:(v1.x) ✗ ls -ltrh /Users/thefourtheye/git/libuv/out/Debug/run-tests
-rwxr-xr-x  1 thefoutheye  110095815   1.1M Nov 29 17:32 /Users/thefourtheye/git/libuv/out/Debug/run-tests


My operating system details

➜  libuv git:(v1.x) ✗ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.12.6
BuildVersion:   16G1618


My questions are


Why does the ${SFW} --add says the application is added and ${SFW} --unblock says application is not part of the firewall?
How can I fix this?
I've taken a look at this and I think that the reason for the popups are still being produced is that there is another run-tests in test/.libs/run-tests.

Using this script I could get this working locally. Could you give it a try and see if this works for you?