Commit 8e7fb99
committed
feat: Add
This implements a function for tests to safely read the current
process umask without the usual race condition of doing so, at the
expense of using subprocesses to do it. This just calls a shell and
runs `umask` from it (which is expected to be a builtin and, on
many systems, is available as a builtin but not an executable).
Even though this is safe, including thread-safe, it is unlikely to
be suitable for use outside of tests, because of its use of
`expect` and assertions when there are errors, combined with the
possibly slow speed of using subprocesses.
Given that this is effecitvely running a tiny shell script to do
the work, why is it not instead a fixture script that is named in
a `.gitignore` file so that it is not tracked? The reason is that
the outcomes of running such fixture scripts are still saved across
separate test runs, but it is useful to be able to run the tests
with differnt umasks, e.g. `(umask 077; cargo nextest run ...)`.
The immediate purpose is in forthcoming tests that, when checkout
sets +x on an existing file, it doesn't set excessive permissions.
The fix to pass such a test is not currently planned to use the
umask explicitly. But the tests will use it, at least to detect
when they cannot really verify the code under test on the grounds
that they are running with an excessively permissive umask that
doesn't allow behavior that only occurs with a generally reasonable
umask to be observed.gix_testtools::umask, safe but only meant for tests1 parent 7ec21bb commit 8e7fb99
3 files changed
+42
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
944 | 944 | | |
945 | 945 | | |
946 | 946 | | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
947 | 960 | | |
948 | 961 | | |
949 | 962 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
9 | 16 | | |
10 | 17 | | |
11 | 18 | | |
12 | 19 | | |
13 | 20 | | |
| 21 | + | |
| 22 | + | |
14 | 23 | | |
15 | 24 | | |
16 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
0 commit comments