Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

temp_make fails with "unrecognized option: directory" #7

Closed
znerd opened this issue Jan 22, 2019 · 2 comments · Fixed by #9
Closed

temp_make fails with "unrecognized option: directory" #7

znerd opened this issue Jan 22, 2019 · 2 comments · Fixed by #9

Comments

@znerd
Copy link

znerd commented Jan 22, 2019

Calling temp_make in a BATS file inside the container results in an error, like this:

not ok 48 my-test
# (from function `setup' in test file //tests/my-test.bats, line 14)
#   `TEST_TMP_DIR="$(temp_make)"' failed
# 
# -- ERROR: temp_make --
# mktemp: unrecognized option: directory
# BusyBox v1.27.2 (2018-06-06 09:08:44 UTC) multi-call binary.
# 
# Usage: mktemp [-dt] [-p DIR] [TEMPLATE]
# 
# Create a temporary file with name based on TEMPLATE and print its name.
# TEMPLATE must end with XXXXXX (e.g. [/dir/]nameXXXXXX).
# Without TEMPLATE, -t tmp.XXXXXX is assumed.
# 
# 	-d	Make directory, not file
# 	-q	Fail silently on errors
# 	-t	Prepend base directory name to TEMPLATE
# 	-p DIR	Use DIR as a base directory (implies -t)
# 	-u	Do not create anything; print a name
# 
# Base directory is: -p DIR, else $TMPDIR, else /tmp
# --
# 
# 
# -- ERROR: temp_del --
# rm: can't remove '': No such file or directory
# --
# 

On the face of it, it seems the OS inside the container (Alpine Linux?) is using the BSD-like mktemp instead of the GNU mktemp, while only the latter is currently supported by bats.

The related issue on the bats-file GitHub project is:

@znerd
Copy link
Author

znerd commented Jan 22, 2019

Here's a quick fix: install the coreutils package in Alpine Linux.

docker run -it --entrypoint /bin/sh dduportal/bats:1.0.0 
/tests # mktemp
/tmp/tmp.BHNPFj
/tests # mktemp --version
mktemp: unrecognized option: version
BusyBox v1.27.2 (2018-06-06 09:08:44 UTC) multi-call binary.

Usage: mktemp [-dt] [-p DIR] [TEMPLATE]

Create a temporary file with name based on TEMPLATE and print its name.
TEMPLATE must end with XXXXXX (e.g. [/dir/]nameXXXXXX).
Without TEMPLATE, -t tmp.XXXXXX is assumed.

        -d      Make directory, not file
        -q      Fail silently on errors
        -t      Prepend base directory name to TEMPLATE
        -p DIR  Use DIR as a base directory (implies -t)
        -u      Do not create anything; print a name

Base directory is: -p DIR, else $TMPDIR, else /tmp
/tests # apk add coreutils
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
(1/3) Installing libattr (2.4.47-r6)
(2/3) Installing libacl (2.2.52-r3)
(3/3) Installing coreutils (8.28-r0)
Executing busybox-1.27.2-r11.trigger
OK: 19 MiB in 22 packages
/tests # mktemp --version
mktemp (GNU coreutils) 8.28
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Jim Meyering and Eric Blake.
/tests # 

@dduportal
Copy link
Contributor

Thanks a lot @znerd ! I've opened a PR for this (#9 ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants