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

Errors in File.open #69

Open
MSP-Greg opened this issue Oct 4, 2019 · 2 comments
Open

Errors in File.open #69

MSP-Greg opened this issue Oct 4, 2019 · 2 comments

Comments

@MSP-Greg
Copy link

MSP-Greg commented Oct 4, 2019

When working on Puma tests to mimic systemd, ran into a rather odd error. The following code:
https://github.com/colszowka/simplecov-html/blob/9ec41504ab139fabfaddfc786dfdab5d6aca0bab/lib/simplecov-html.rb#L22-L24

threw errors as below:

Fabulous run in 2.374952s, 5.4738 runs/s, 29.4743 assertions/s.

13 runs, 70 assertions, 0 failures, 0 errors, 0 skips
SimpleCov.coverage_path puma/coverage
SimpleCov.coverage_path puma/coverage
Traceback (most recent call last):
        4: from simplecov-html-0.10.2/lib/simplecov-html.rb:22:in `format'
        3: from simplecov-html-0.10.2/lib/simplecov-html.rb:22:in `open'
        2: from simplecov-html-0.10.2/lib/simplecov-html.rb:23:in `block in format'
        1: from simplecov-html-0.10.2/lib/simplecov-html.rb:23:in `puts'
simplecov-html-0.10.2/lib/simplecov-html.rb:23:in `write': Bad file descriptor (Errno::EBADF)
        2: from simplecov-html-0.10.2/lib/simplecov-html.rb:22:in `format'
        1: from simplecov-html-0.10.2/lib/simplecov-html.rb:22:in `open'
simplecov-html-0.10.2/lib/simplecov-html.rb:22:in `close': Bad file descriptor @ fptr_finalize_flush - C:/Greg/GitHub/puma/coverage/index.html (Errno::EBADF)
rake aborted!
Command failed with status (1)

There's 'odd things' in the tests re fd's, etc, but the tests seem stable. When I changed the above code to the following, everything runs fine:

File.write(
  File.join(output_path, "index.html"),
  template("layout").result(binding),
  mode: "wb"
)

Why I'm getting the errors with File.open, but not File.write, I'm not sure, as I always considered them equivalent. Anyway, would this be accepted as a PR?

@PragTob
Copy link
Collaborator

PragTob commented Oct 5, 2019

That is.... more than strange. I'd probably accept it, however it seems like "programming by coincedence" to me a bit as I don't know or understand why that change fixes the bug which makes me rather uncomfortable 🤔

@PragTob
Copy link
Collaborator

PragTob commented Feb 8, 2020

@MSP-Greg 👋

Any updates from your side? A repo or something I can play around with this to see what's causing it?

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

No branches or pull requests

2 participants