13 Commits

Author SHA1 Message Date
Douglas Eichelberger
9075cbae62 brew style --fix 2023-04-21 09:58:50 -07:00
Douglas Eichelberger
ac1e6ded9a git grep -l '# typed: false' | xargs gsed -i 's|# typed: false||g' 2023-04-21 09:57:47 -07:00
Issy Long
3a83b5492c
rubocop: Clean up Style/BlockDelimiters excludes and autofix offenses
- The defaults of using "do ... end" for multi-line blocks everywhere is
  good, better than switching everything to braces everywhere.
2023-03-08 23:54:22 +00:00
Misty De Meo
847897fdac Popen spec: ensure Rubocop is happy
These were introduced in #10305 but only started going red
after that PR was merged.
2021-01-13 11:21:10 -08:00
Seeker
be6dd72c16
Merge pull request #10305 from SeekingMeaning/safe-popen-tests
utils/popen: add `safe` argument to `popen_read` and `popen_write`
2021-01-13 10:51:46 -08:00
Seeker
40d85ecb40 popen_spec: add tests for safe_popen_read and safe_popen_write 2021-01-12 09:56:05 -08:00
Seeker
022bcbb269 test/utils/*: use described_class or named subject 2021-01-11 12:31:39 -08:00
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