mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-21 13:36:15 +02:00
Merge pull request #11816 from hercules-ci/fix-logger-ask-eof
`ProgressBar::ask`: accept EOF, as a no
This commit is contained in:
commit
1af94bf471
5 changed files with 25 additions and 10 deletions
|
@ -543,7 +543,7 @@ public:
|
||||||
auto state(state_.lock());
|
auto state(state_.lock());
|
||||||
if (!state->active) return {};
|
if (!state->active) return {};
|
||||||
std::cerr << fmt("\r\e[K%s ", msg);
|
std::cerr << fmt("\r\e[K%s ", msg);
|
||||||
auto s = trim(readLine(STDIN_FILENO));
|
auto s = trim(readLine(STDIN_FILENO, true));
|
||||||
if (s.size() != 1) return {};
|
if (s.size() != 1) return {};
|
||||||
draw(*state);
|
draw(*state);
|
||||||
return s[0];
|
return s[0];
|
||||||
|
|
|
@ -77,8 +77,13 @@ void writeFull(Descriptor fd, std::string_view s, bool allowInterrupts = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read a line from a file descriptor.
|
* Read a line from a file descriptor.
|
||||||
|
*
|
||||||
|
* @param fd The file descriptor to read from
|
||||||
|
* @param eofOk If true, return an unterminated line if EOF is reached. (e.g. the empty string)
|
||||||
|
*
|
||||||
|
* @return A line of text ending in `\n`, or a string without `\n` if `eofOk` is true and EOF is reached.
|
||||||
*/
|
*/
|
||||||
std::string readLine(Descriptor fd);
|
std::string readLine(Descriptor fd, bool eofOk = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write a line to a file descriptor.
|
* Write a line to a file descriptor.
|
||||||
|
|
|
@ -47,7 +47,7 @@ void writeFull(int fd, std::string_view s, bool allowInterrupts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string readLine(int fd)
|
std::string readLine(int fd, bool eofOk)
|
||||||
{
|
{
|
||||||
std::string s;
|
std::string s;
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -58,8 +58,12 @@ std::string readLine(int fd)
|
||||||
if (rd == -1) {
|
if (rd == -1) {
|
||||||
if (errno != EINTR)
|
if (errno != EINTR)
|
||||||
throw SysError("reading a line");
|
throw SysError("reading a line");
|
||||||
} else if (rd == 0)
|
} else if (rd == 0) {
|
||||||
throw EndOfFile("unexpected EOF reading a line");
|
if (eofOk)
|
||||||
|
return s;
|
||||||
|
else
|
||||||
|
throw EndOfFile("unexpected EOF reading a line");
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if (ch == '\n') return s;
|
if (ch == '\n') return s;
|
||||||
s += ch;
|
s += ch;
|
||||||
|
|
|
@ -27,7 +27,17 @@ cat <<EOF > flake.nix
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Without --accept-flake-config, the post hook should not run.
|
# Without --accept-flake-config, the post hook should not run.
|
||||||
|
# To test variations in stderr tty-ness, we run the command in different ways,
|
||||||
|
# none of which should block on stdin or accept the `nixConfig`s.
|
||||||
nix build < /dev/null
|
nix build < /dev/null
|
||||||
|
nix build < /dev/null 2>&1 | cat
|
||||||
|
# EOF counts as no, even when interactive (throw EOF error before)
|
||||||
|
if type -p script >/dev/null && script -q -c true /dev/null; then
|
||||||
|
echo "script is available and GNU-like, so we can ensure a tty"
|
||||||
|
script -q -c 'nix build < /dev/null' /dev/null
|
||||||
|
else
|
||||||
|
echo "script is not available or not GNU-like, so we skip testing with an added tty"
|
||||||
|
fi
|
||||||
(! [[ -f post-hook-ran ]])
|
(! [[ -f post-hook-ran ]])
|
||||||
TODO_NixOS
|
TODO_NixOS
|
||||||
clearStore
|
clearStore
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
{ lib
|
{ lib
|
||||||
, stdenv
|
, stdenv
|
||||||
, mkMesonDerivation
|
, mkMesonDerivation
|
||||||
, releaseTools
|
|
||||||
|
|
||||||
, meson
|
, meson
|
||||||
, ninja
|
, ninja
|
||||||
|
@ -16,10 +15,6 @@
|
||||||
, nix-expr
|
, nix-expr
|
||||||
, nix-cli
|
, nix-cli
|
||||||
|
|
||||||
, rapidcheck
|
|
||||||
, gtest
|
|
||||||
, runCommand
|
|
||||||
|
|
||||||
, busybox-sandbox-shell ? null
|
, busybox-sandbox-shell ? null
|
||||||
|
|
||||||
# Configuration Options
|
# Configuration Options
|
||||||
|
@ -60,6 +55,7 @@ mkMesonDerivation (finalAttrs: {
|
||||||
# etc.
|
# etc.
|
||||||
busybox-sandbox-shell
|
busybox-sandbox-shell
|
||||||
# For Overlay FS tests need `mount`, `umount`, and `unshare`.
|
# For Overlay FS tests need `mount`, `umount`, and `unshare`.
|
||||||
|
# For `script` command (ensuring a TTY)
|
||||||
# TODO use `unixtools` to be precise over which executables instead?
|
# TODO use `unixtools` to be precise over which executables instead?
|
||||||
util-linux
|
util-linux
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue