Skip to content

Commit

Permalink
Fixing github tests on macos.
Browse files Browse the repository at this point in the history
Using 'readlink -f' instead of 'realpath'.
Added pure shell function to get relative path between two dirs.
Set LC_ALL only for Linux.
Echo 'uname' on 'make test'
  • Loading branch information
spog committed Dec 1, 2024
1 parent 9d2d959 commit 2313865
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ INSTALL_BIN ?= $(PREFIX)/bin
INSTALL_LIB ?= $(PREFIX)/share/$(NAME)
INSTALL_EXT ?= $(INSTALL_LIB)/$(NAME).d
INSTALL_MAN1 ?= $(PREFIX)/share/man/man1
LINK_REL_DIR := $(shell realpath --relative-to=$(INSTALL_BIN) $(INSTALL_LIB))
LINK_REL_DIR := $(shell bash share/pnrelpath.sh $(INSTALL_BIN) $(INSTALL_LIB))

# Docker variables:
DOCKER_TAG ?= 0.0.6
Expand All @@ -49,6 +49,7 @@ help:

.PHONY: test
test:
@echo uname: '$(shell uname)'
prove $(prove) $(test)

test-all: test docker-tests
Expand Down
2 changes: 1 addition & 1 deletion lib/git-subrepo
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set -e
export FILTER_BRANCH_SQUELCH_WARNING=1

# Import Bash+ helper functions:
SUBREPO_EXT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")/git-subrepo.d" # replaced by `make install`
SUBREPO_EXT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/git-subrepo.d" # replaced by `make install`
source "${SUBREPO_EXT_DIR}/bash+.bash"
bash+:import :std can version-check

Expand Down
25 changes: 25 additions & 0 deletions share/pnrelpath.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
#
# from: https://unix.stackexchange.com/questions/573047/how-to-get-the-relative-path-between-two-directories
#
# Expects two parameters, source-dir and target-dir, both absolute canonicalized
# non-empty pathnames, either may be /-ended, neither need exist.
# Returns result in shell variable $REPLY as a relative path from source-dir
# to target-dir without trailing /, . if void.
#
# Algorithm is from a 2005 comp.unix.shell posting which has now ascended to
# archive.org.

pnrelpath() {
set -- "${1%/}/" "${2%/}/" '' ## '/'-end to avoid mismatch
while [ "$1" ] && [ "$2" = "${2#"$1"}" ] ## reduce $1 to shared path
do set -- "${1%/?*/}/" "$2" "../$3" ## source/.. target ../relpath
done
REPLY="${3}${2#"$1"}" ## build result
# unless root chomp trailing '/', replace '' with '.'
[ "${REPLY#/}" ] && REPLY="${REPLY%/}" || REPLY="${REPLY:-.}"
}

pnrelpath "$1" "$2"

echo $REPLY
4 changes: 3 additions & 1 deletion test/setup
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

set -e

export LC_ALL=C.UTF-8
if [ "$(uname)" == "Linux" ]; then
export LC_ALL=C.UTF-8
fi

# Get the location of this script
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
Expand Down

0 comments on commit 2313865

Please sign in to comment.