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

Improve temporary dir creation #12

Closed
aureliojargas opened this issue Mar 8, 2016 · 2 comments
Closed

Improve temporary dir creation #12

aureliojargas opened this issue Mar 8, 2016 · 2 comments
Labels

Comments

@aureliojargas
Copy link
Owner

Sometimes, the tests fail due to the temp dir creation routine:

#70 ./clitest --progress no test/ok-1.sh
--------------------------------------------------------------------------------
[FAILED #70, line 481] ./clitest --progress no test/ok-1.sh
@@ -1 +1,2 @@
-OK: 1 of 1 test passed
+mkdir: /var/folders/ns/p897hcp56wjgjt61yr7tbd980000gq/T//clitest.15322: File exists
+clitest: Error: cannot create temporary dir: /var/folders/ns/p897hcp56wjgjt61yr7tbd980000gq/T//clitest.15322
--------------------------------------------------------------------------------
#71 ./clitest -P dot test/ok-1.sh
#72 ./clitest -P no test/ok-1.sh
#73 ./clitest --progress . test/ok-1.sh
#74 ./clitest --progress . test/ok-2.sh

Is mktemp portable?

@vmmello
Copy link
Contributor

vmmello commented Mar 8, 2016

my experience is that mktemp works well on several different systems. I've written scripts relying on mktemp that worked on CentOS/RH, Debian, Ubuntu and MacOS X without any change.

Or use mkdir and some portable randomizing function like:

head -c 1000 /dev/urandom | tr -dc A-Za-z0-9 | cut -b 1-15

@aureliojargas aureliojargas added this to the v1.0.0 milestone Mar 9, 2016
@aureliojargas
Copy link
Owner Author

Unfortunately, mktemp is not portable: http://mywiki.wooledge.org/BashFAQ/062

Neither is /dev/random and /dev/urandom :(

aureliojargas added a commit that referenced this issue Mar 10, 2016
Use mktemp. If not available, create a random dir manually, using awk's
rand() and $$.

Not a pretty solution, but it's portable.

Fixes #12
pvital pushed a commit to pvital/clitest that referenced this issue Oct 1, 2018
Use mktemp. If not available, create a random dir manually, using awk's
rand() and $$.

Not a pretty solution, but it's portable.

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

No branches or pull requests

2 participants