Skip to content

Instantly share code, notes, and snippets.

@tazjin
Created July 13, 2018 00:22
Show Gist options
  • Save tazjin/848813f0224d0731345ea1a11124074c to your computer and use it in GitHub Desktop.
Save tazjin/848813f0224d0731345ea1a11124074c to your computer and use it in GitHub Desktop.
Git bisect test for cmullaparthi/ibrowse#160
#!/usr/bin/env bash
set -e
function cleanup {
git checkout src/ibrowse.erl
}
trap cleanup EXIT
echo "Patching in main/1 function with hex.pm test"
# export the main function
sed -i 's/(gen_server)\./(gen_server)\. -export(\[main\/1\])\./g' src/ibrowse.erl
# add the main function
cat >> src/ibrowse.erl <<EOF
main(_) ->
ssl:start(),
ibrowse:start(),
Response = ibrowse:send_req("https://hex.pm/api/packages/soap"
, [{"User-Agent", "hex2nix"}, {"Accept", "application/json"}]
, get
, []
, []),
case Response of
{error,{conn_failed,{error,{tls_alert,"internal error"}}}} ->
io:format("Bad version~n"), erlang:halt(1);
_ -> io:format("Good version~n"), erlang:halt(0)
end.
EOF
echo "Escriptizing ..."
rebar3 escriptize
echo "Running test ..."
_build/default/bin/ibrowse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment