From 0e140a4666fe6fe91230e363ead9b02b5da5a2f1 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Sun, 27 Jul 2014 11:58:29 +0100 Subject: [PATCH] Correctly getting the build signature properties into the MANIFEST.MF on build, now testing I'm clearing them down again before commit. --- buildall.sh | 39 ++++++++++++++++-------------- project.clj | 6 ++--- resources/heightmaps/test9x9.png | Bin 0 -> 315 bytes test/mw_engine/heightmap_test.clj | 23 ++++++++++++++++++ 4 files changed, 47 insertions(+), 21 deletions(-) create mode 100644 resources/heightmaps/test9x9.png create mode 100644 test/mw_engine/heightmap_test.clj diff --git a/buildall.sh b/buildall.sh index 928c40d..2e443f6 100755 --- a/buildall.sh +++ b/buildall.sh @@ -13,6 +13,7 @@ fullname=`grep ${USER} /etc/passwd | awk -F\: '{print $5}' | awk -F\, '{print $1 webappsdir="/var/lib/tomcat7/webapps" release="" trial="FALSE" +tmp=buildall.tmp.$$ # Builds the build signature properties in the manifest map file # expected arguments: old version tag, version tag, full name of user, @@ -52,12 +53,12 @@ function setup-build-sig { t=`date --rfc-3339 seconds` fi -cat <<-EOF > buildall.tmp/manifest.sed +cat <<-EOF > ${tmp}/manifest.sed s/${o}/${v}/g -s/^ *"build-signature-version" ".*" *\$/\t\t"build-signature-version" "${v}"/ s/^ *"build-signature-user" ".*" *\$/\t\t"build-signature-user" "${u}"/ s/^ *"build-signature-email" ".*" *\$/\t\t"build-signature-email" "${e}"/ s/^ *"build-signature-timestamp" ".*" *\$/\t\t"build-signature-timestamp" "${t}"/ +s/^ *"build-signature-version" ".*" *\$/\t\t"build-signature-version" "${v}"/ EOF } @@ -125,13 +126,13 @@ for dir in mw-* do pushd ${dir} - if [ ! -d "buildall.tmp" ] + if [ ! -d "${tmp}" ] then - rm -f "buildall.tmp" - mkdir "buildall.tmp" + rm -f "${tmp}" + mkdir "${tmp}" fi - cat project.clj > buildall.tmp/project.bak.1 + cat project.clj > ${tmp}/project.bak.1 old=`cat project.clj | grep 'defproject mw' | sed 's/.*defproject mw-[a-z]* "\([A-Za-z0-9_.-]*\)".*/\1/'` if [ "${release}" != "" ] @@ -153,13 +154,13 @@ do message="Upversioned from ${old} to ${interim} for release" old=${interim} else - setup-build-sig "${old}" "${old}" "${fullname}" "${email}" + setup-build-sig "unset" "${old}" "${fullname}" "${email}" fi else - setup-build-sig "${old}" "${old}" "${fullname}" "${email}" + setup-build-sig "unset" "${old}" "${fullname}" "${email}" fi - sed -f buildall.tmp/manifest.sed buildall.tmp/project.bak.1 > project.clj + sed -f ${tmp}/manifest.sed ${tmp}/project.bak.1 > project.clj echo $message @@ -181,9 +182,9 @@ do lein marg lein install - cat project.clj > buildall.tmp/project.bak.2 - setup-build-sig "${old}" - sed -f buildall.tmp/manifest.sed buildall.tmp/project.bak.2 > project.clj + cat project.clj > ${tmp}/project.bak.2 + setup-build-sig + sed -f ${tmp}/manifest.sed ${tmp}/project.bak.2 > project.clj if [ "${trial}" = "FALSE" ] then @@ -205,9 +206,9 @@ do git push origin "${branch}" fi - cat project.clj > buildall.tmp/project.bak.3 + cat project.clj > ${tmp}/project.bak.3 setup-build-sig "${old}" "${release}-SNAPSHOT" "${fullname}" "${email}" - sed -f buildall.tmp/manifest.sed buildall.tmp/project.bak.3 > project.clj + sed -f ${tmp}/manifest.sed ${tmp}/project.bak.3 > project.clj message="Upversioned from ${interim} to ${release}-SNAPSHOT" echo $message @@ -222,9 +223,9 @@ do lein marg lein install - cat project.clj > buildall.tmp/project.bak.4 - setup-build-sig "${release}-SNAPSHOT" - sed -f buildall.tmp/manifest.sed buildall.tmp/project.bak.4 > project.clj + cat project.clj > ${tmp}/project.bak.4 + setup-build-sig + sed -f ${tmp}/manifest.sed ${tmp}/project.bak.4 > project.clj if [ "${trial}" = "FALSE" ] then @@ -239,9 +240,11 @@ do if [ "${dir}" = "mw-ui" ] then lein ring uberwar - sudo cp buildall.tmp/microworld.war /var/lib/tomcat7/webapps + sudo cp target/microworld.war /var/lib/tomcat7/webapps echo "Deployed new WAR file to local Tomcat" fi + + # rm -rf "${tmp}" popd done diff --git a/project.clj b/project.clj index 6b96967..11bb71d 100644 --- a/project.clj +++ b/project.clj @@ -1,13 +1,13 @@ -(defproject mw-engine "unset" +(defproject mw-engine "0.1.2-SNAPSHOT" :description "Cellular automaton world builder." :url "http://www.journeyman.cc/microworld/" :manifest { ;; do not reformat this! It is important for the buildall script ;; that each of these properties is on a line with nothing else. - "build-signature-version" "unset" + "build-signature-version" "0.1.2-SNAPSHOT" "build-signature-user" "Simon Brooke" "build-signature-email" "simon@journeyman.cc" - "build-signature-timestamp" "2014-07-27 11:19:57+01:00" + "build-signature-timestamp" "2014-07-27 11:54:52+01:00" } :license {:name "GNU General Public License v2" diff --git a/resources/heightmaps/test9x9.png b/resources/heightmaps/test9x9.png new file mode 100644 index 0000000000000000000000000000000000000000..5bd813126eb6fca2570bbe71ab4fd0f090e56e07 GIT binary patch literal 315 zcmeAS@N?(olHy`uVBq!ia0vp^oFL4>1SIo6Pjm-y3Opi<85p>QL70(Y)*K0-AbW|Y zuPggKc1cba$r5(gjX)vE64!_l=ltB<)VvY~=c3falGGH1^30M91$R&1fbd2>aiF5D zo-U3d9M^SES~s;Aa4-azK5=I{=yu_EeBrhmhKaLl-`<}8yz;q?>$=xLp`pg1rhDH@ z+u6^5|9-pTzW3J8W3u()-|eeu(kC}}p2D>@ADd$@T-KT&VawXKvt1(l+*~W;)0)jQ zJO1%AJ((o9v0Uh3;i&{RjFbC@?YjAA^LgNoc;A(*vLf7(8A5T-G@y GGywplNpe2` literal 0 HcmV?d00001 diff --git a/test/mw_engine/heightmap_test.clj b/test/mw_engine/heightmap_test.clj new file mode 100644 index 0000000..2925b5f --- /dev/null +++ b/test/mw_engine/heightmap_test.clj @@ -0,0 +1,23 @@ +(ns mw-engine.heightmap-test + (:require [clojure.test :refer :all] + [mw-engine.heightmap :refer :all] + [clojure.math.combinatorics :as combo])) + +(deftest apply-heightmap-test + (testing "Heightmap functionality" + (let [world (apply-heightmap "heightmaps/test9x9.png") + altitudes (map #(:altitude %) (flatten world)) + gradients (map #(:gradient %) (flatten world))] + (is (= (count world) 9) "World should be 9x9") + (is (= (count (first world)) 9) "World should be 9x9") + (is (= (count (remove nil? altitudes)) 81) + "All cells should have altitude") + (is (= (count (remove nil? gradients)) 81) + "All cells should have gradient") + (is (> (apply max altitudes) + (apply min altitudes)) + "There should be a range of altitudes") + (is (> (apply + gradients) 0) + "At least some gradients must be positive, none should be negative") + ))) +