6 Commits

Author SHA1 Message Date
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Claudia
772032f18a
Add failing tests for popen_write
When using `popen_write`, the expectation is to return the
standard output of the child process.

This expectation is evident in how `safe_popen_write` is written:

```
  def self.safe_popen_write(*args, **options, &block)
    output = popen_write(*args, **options, &block)
    return output if $CHILD_STATUS.success?

    raise ErrorDuringExecution.new(args, status: $CHILD_STATUS, output: [[:stdout, output]])
  end
```

However, no code has been written to actually *obtain* that output
from the child process. The side effects of that are described in
issue #8244. [1]

[1]: https://github.com/Homebrew/brew/issues/8244

The newly-added tests reveal that `popen_write` only returns the
number 4 instead of the expected standard output.

For example, given a file `foo` with the content `Foo\n`, one test
calls `popen_write` with `cat foo -` and an input of `Bar`.
The expected output would be `Foo\nBar\n` but the actual output is
the number 4 (which is what Ruby’s `IO#write` method returns).
2020-08-30 22:29:46 +02:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Shaun Jackman
7adee6d62f Utils.popen_read: Nonexistent program should fail
Ensure that $CHILD_STATUS.success? is false when the command does not exist.
2017-12-02 15:52:01 -08:00
Mike McQuaid
021cef4b2b Autocorrect Rubocop Style/SpecialGlobalVars. 2017-06-12 09:11:42 +01:00
Markus Reiter
05a98f24c4 Convert Utils test to spec. 2017-02-19 18:41:53 +01:00