shithub: rgbds

Download patch

ref: bdfce25db047b64e48d33a1beeb348478c06c84b
parent: 2b6d9cd1e08284b462b8eaecbbca154791b923f5
author: ISSOtm <eldredhabert0@gmail.com>
date: Thu Dec 10 08:43:22 EST 2020

Avoid running version test when `git describe` fails

Can happen when not enough history has been fetched, notably in our CI

--- a/test/asm/.gitignore
+++ b/test/asm/.gitignore
@@ -1,2 +1,3 @@
-quote\"file.*
-version.out
+/quote\"file.*
+/version.asm
+/version.out
--- a/test/asm/test.sh
+++ b/test/asm/test.sh
@@ -2,18 +2,19 @@
 
 export LC_ALL=C
 
-o=$(mktemp)
-gb=$(mktemp)
-input=$(mktemp)
-output=$(mktemp)
-errput=$(mktemp)
+o="$(mktemp)"
+gb="$(mktemp)"
+input="$(mktemp)"
+output="$(mktemp)"
+errput="$(mktemp)"
 rc=0
 
-bold=$(tput bold)
-resbold=$(tput sgr0)
-red=$(tput setaf 1)
-green=$(tput setaf 2)
-rescolors=$(tput op)
+bold="$(tput bold)"
+resbold="$(tput sgr0)"
+red="$(tput setaf 1)"
+green="$(tput setaf 2)"
+orange="$(tput setaf 3)"
+rescolors="$(tput op)"
 tryDiff () {
 	diff -u --strip-trailing-cr $1 $2 || (echo "${bold}${red}${i%.asm}${variant}.$3 mismatch!${rescolors}${resbold}"; false)
 }
@@ -23,7 +24,13 @@
 }
 
 # Add the version constants test, outputting the closest tag to the HEAD
-git describe --tags --abbrev=0 > version.out
+if git describe --tags --abbrev=0 > version.out; then
+	cat > version.asm <<EOF
+PRINTT "v{d:__RGBDS_MAJOR__}.{d:__RGBDS_MINOR__}.{d:__RGBDS_PATCH__}\n"
+EOF
+else
+	echo "${bold}${orange}Warning: cannot run version test!${rescolors}${resbold}"
+fi
 
 # Add the quote test, except on Windows
 if uname | grep -viq mingw; then
@@ -40,7 +47,7 @@
 
 for i in *.asm; do
 	for variant in '' '.pipe'; do
-		echo -e "${bold}${green}${i%.asm}${variant}...${rescolors}${resbold}"
+		echo "${bold}${green}${i%.asm}${variant}...${rescolors}${resbold}"
 		if [ -z "$variant" ]; then
 			../../rgbasm -Weverything -o $o $i > $output 2> $errput
 			desired_output=${i%.asm}.out
--- a/test/asm/version.asm
+++ /dev/null
@@ -1,1 +1,0 @@
-PRINTT "v{d:__RGBDS_MAJOR__}.{d:__RGBDS_MINOR__}.{d:__RGBDS_PATCH__}\n"