aboutsummaryrefslogtreecommitdiffstats
path: root/test/Makefile
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2015-09-26 14:41:56 +0200
committerLoïc Hoguin <[email protected]>2015-09-26 14:41:56 +0200
commit0f78319fd528236a0fd7d152870e77248cfc5891 (patch)
tree05452461c84f7acd477525ea759570b1a7a6ed08 /test/Makefile
parentc1131f4f7420d009c8a05e5de9dd0888127aa0aa (diff)
downloaderlang.mk-0f78319fd528236a0fd7d152870e77248cfc5891.tar.gz
erlang.mk-0f78319fd528236a0fd7d152870e77248cfc5891.tar.bz2
erlang.mk-0f78319fd528236a0fd7d152870e77248cfc5891.zip
Make tests work on more systems
Some systems do not have subsecond file modification detection capabilities. This is the case in OSX because the HFS+ file system has 1 second resolution. This is also the case in other OSes with particular file systems or even shells. For example, the "test" command in Bash does not support subsecond file times, while the ZSH one and the /usr/bin/test on my machine does. On those systems, with Bash, find -newer will work, but not test -nt. Tests were updated to reflect this. The test Makefile runs a series of commands to determine if subsecond resolution is available. When it is not, a sleep command will be executed before relevant operations in the tests. Because the Bash shell is often the default shell for Make, and because users of ZSH may want to avoid sleeping for no reasons, a new variable was introduced: ZSH=1. When provided when running tests, the shell will be switched to ZSH, and subsecond resolution will work as expected. Tests have been fixed to work with ZSH as well. All this only applies to tests, Erlang.mk itself is so far not affected by this issue.
Diffstat (limited to 'test/Makefile')
-rw-r--r--test/Makefile30
1 files changed, 28 insertions, 2 deletions
diff --git a/test/Makefile b/test/Makefile
index ba612fa..fffc171 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -2,6 +2,14 @@
# Copyright (c) 2014, Viktor Söderqvist <[email protected]>
# This file is part of erlang.mk and subject to the terms of the ISC License.
+# ZSH users have a more modern shell which doesn't need to
+# have the same safeguards as other shells. To use ZSH instead
+# of the default shell, set ZSH=1.
+
+ifdef ZSH
+SHELL := $(shell which zsh)
+endif
+
# Temporary application name, taken from rule name.
APP = $(subst -,_,$@)
@@ -19,6 +27,24 @@ else
PLATFORM = unix
endif
+# Some systems do not have sub-second file times resolution.
+# This is the case for older systems like OSX that uses the HFS+
+# file system. HFS+ has a 1 second time resolution. This is a
+# problem because the Erlang.mk tests rely on file modification
+# times to ensure files were rebuilt. To fix this issue, we
+# detect here whether the system supports sub-second resolution,
+# and maybe sleep during test execution.
+#
+# Also see:
+# * http://arstechnica.com/apple/2011/07/mac-os-x-10-7/12/#hfs-problems
+# * https://apple.stackexchange.com/questions/51650/linus-torvalds-and-the-os-x-filesystem
+
+ifeq ($(shell touch a; sleep 0.01; touch b; sleep 0.01; touch c; test c -nt b -a b -nt a; echo $$?; rm a b c),1)
+SLEEP = sleep 1
+else
+SLEEP =
+endif
+
# OTP master, for downloading files for testing.
OTP_MASTER = https://raw.githubusercontent.com/erlang/otp/master
@@ -47,11 +73,11 @@ else ifeq ($V,1)
else ifeq ($V,2)
t = @echo " TEST " $@;
v = V=0
- i = @echo == $@:
+ i = @echo "== $@:"
else
t =
v = V=1
- i = @echo == $@:
+ i = @echo "== $@:"
endif
# Main targets.