From: Scott Worley Date: Sun, 16 Sep 2012 23:25:19 +0000 (-0700) Subject: A simple whole-run testing methodology X-Git-Url: http://git.scottworley.com/planeteer/commitdiff_plain/49cc7edb54405f2870bd0d82a8b3aaa7bee9f231?hp=091c628026edc6f81d851bd1d070edd34af20b67 A simple whole-run testing methodology Add test.sh for comparing against historical recorded runs. I have not done any extra analysis on cases recorded here. Rather, I just want to know when/if any of this output changes. I couldn't figure out a good way to include these tests within the "go test" framework. The tricky bit was figuring out how to set unmentioned flags back to their default values between runs. I deemed adding an 'option' object of some kind built from command line flags but also buildable by tests to not be worth the complexity at this time. --- diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..c242e3c --- /dev/null +++ b/test.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +exit_status=0 + +function t() { + expected=$1 + shift + diff -u --label Expected <( echo -n "$expected" ) \ + --label Actual <( ./planeteer "$@" ) || exit_status=1 +} + +t ' 850,000 Buy 300 Medical Units + 850,000 Jump from Earth to Sickonia (2 hyper jump units) + 3,220,600 Sell 300 Medical Units + 2,770,600 Buy 300 Heating Units + 2,770,600 Jump from Sickonia to Hothor (2 hyper jump units) + 5,200,600 Sell 300 Heating Units + 4,999,600 Buy 300 Medical Units + 4,999,600 Jump from Hothor to Sickonia (2 hyper jump units) + 7,370,200 Sell 300 Medical Units + 6,920,200 Buy 300 Heating Units + 6,920,200 Jump from Sickonia to Hothor (2 hyper jump units) + 9,350,200 Sell 300 Heating Units + 9,149,200 Buy 300 Medical Units + 9,149,200 Jump from Hothor to Sickonia (2 hyper jump units) + 11,519,800 Sell 300 Medical Units + 11,069,800 Buy 300 Heating Units + 11,069,800 Jump from Sickonia to Hothor (2 hyper jump units) + 13,499,800 Sell 300 Heating Units + 13,298,800 Buy 300 Medical Units + 13,298,800 Jump from Hothor to Sickonia (2 hyper jump units) + 15,669,400 Sell 300 Medical Units + 15,219,400 Buy 300 Heating Units + 15,219,400 Jump from Sickonia to Hothor (2 hyper jump units) + 17,649,400 Sell 300 Heating Units +' --funds 1000000 --start Earth + +t '' --funds 1000000 --start Earth --fuel 0 + +t ' 850,000 Buy 300 Medical Units + 850,000 Jump from Earth to HomeWorld (2 hyper jump units) + 3,256,900 Sell 300 Medical Units +' --funds 1000000 --start Earth --fuel 2 + +t ' 850,000 Buy 300 Medical Units + 850,000 Jump from Earth to Sickonia (2 hyper jump units) + 3,220,600 Sell 300 Medical Units + 2,770,600 Buy 300 Heating Units + 2,770,600 Jump from Sickonia to Hothor (2 hyper jump units) + 5,200,600 Sell 300 Heating Units +' --funds 1000000 --start Earth --fuel 4 + +t ' 850,000 Buy 300 Medical Units + 850,000 Jump from Earth to Sickonia (2 hyper jump units) + 3,220,600 Sell 300 Medical Units + 2,770,600 Buy 300 Heating Units + 2,770,600 Jump from Sickonia to Hothor (2 hyper jump units) + 5,200,600 Sell 300 Heating Units + 4,999,600 Buy 300 Medical Units + 4,999,600 Jump from Hothor to HomeWorld (2 hyper jump units) + 7,406,500 Sell 300 Medical Units +' --funds 1000000 --start Earth --fuel 6 + +exit "$exit_status"