ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:110119] [Ruby master Bug#19026] Add `Coverage.supported?(x)` to detect support for `eval` coverage flag.
@ 2022-09-28 10:52 ioquatix (Samuel Williams)
  2022-09-28 11:01 ` [ruby-core:110120] " mame (Yusuke Endoh)
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: ioquatix (Samuel Williams) @ 2022-09-28 10:52 UTC (permalink / raw)
  To: ruby-core

Issue #19026 has been reported by ioquatix (Samuel Williams).

----------------------------------------
Bug #19026: Add `Coverage.supported?(x)` to detect support for `eval` coverage flag.
https://bugs.ruby-lang.org/issues/19026

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
Introduce the following interface:

```
Coverage.supported?(eval) -> true/false
```

We can also check `lines` `branches` and `methods`?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:110120] [Ruby master Bug#19026] Add `Coverage.supported?(x)` to detect support for `eval` coverage flag.
  2022-09-28 10:52 [ruby-core:110119] [Ruby master Bug#19026] Add `Coverage.supported?(x)` to detect support for `eval` coverage flag ioquatix (Samuel Williams)
@ 2022-09-28 11:01 ` mame (Yusuke Endoh)
  2022-09-28 11:09 ` [ruby-core:110121] " ioquatix (Samuel Williams)
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mame (Yusuke Endoh) @ 2022-09-28 11:01 UTC (permalink / raw)
  To: ruby-core

Issue #19026 has been updated by mame (Yusuke Endoh).


Note: This API does determine if the mode is *available*, not *enabled*. So `Coverage.supported?(:eval)` will always returns `true` in Ruby 3.2 regardless of whether `Coverage.start(eval: true)` is called.

In my first impression, it is okay, but I'd like to hear opinions. @jeremyevans0 Do you have any opinion?

----------------------------------------
Bug #19026: Add `Coverage.supported?(x)` to detect support for `eval` coverage flag.
https://bugs.ruby-lang.org/issues/19026#change-99377

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
Introduce the following interface:

```
Coverage.supported?(eval) -> true/false
```

We can also check `lines` `branches` and `methods`?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:110121] [Ruby master Bug#19026] Add `Coverage.supported?(x)` to detect support for `eval` coverage flag.
  2022-09-28 10:52 [ruby-core:110119] [Ruby master Bug#19026] Add `Coverage.supported?(x)` to detect support for `eval` coverage flag ioquatix (Samuel Williams)
  2022-09-28 11:01 ` [ruby-core:110120] " mame (Yusuke Endoh)
@ 2022-09-28 11:09 ` ioquatix (Samuel Williams)
  2022-09-28 14:18 ` [ruby-core:110124] " mame (Yusuke Endoh)
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ioquatix (Samuel Williams) @ 2022-09-28 11:09 UTC (permalink / raw)
  To: ruby-core

Issue #19026 has been updated by ioquatix (Samuel Williams).


Commit is currently part of https://github.com/ruby/ruby/pull/6462

----------------------------------------
Bug #19026: Add `Coverage.supported?(x)` to detect support for `eval` coverage flag.
https://bugs.ruby-lang.org/issues/19026#change-99378

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
Introduce the following interface:

```
Coverage.supported?(eval) -> true/false
```

We can also check `lines` `branches` and `methods`?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:110124] [Ruby master Bug#19026] Add `Coverage.supported?(x)` to detect support for `eval` coverage flag.
  2022-09-28 10:52 [ruby-core:110119] [Ruby master Bug#19026] Add `Coverage.supported?(x)` to detect support for `eval` coverage flag ioquatix (Samuel Williams)
  2022-09-28 11:01 ` [ruby-core:110120] " mame (Yusuke Endoh)
  2022-09-28 11:09 ` [ruby-core:110121] " ioquatix (Samuel Williams)
@ 2022-09-28 14:18 ` mame (Yusuke Endoh)
  2022-09-28 14:55 ` [ruby-core:110128] " Dan0042 (Daniel DeLorme)
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mame (Yusuke Endoh) @ 2022-09-28 14:18 UTC (permalink / raw)
  To: ruby-core

Issue #19026 has been updated by mame (Yusuke Endoh).


I think it is reasonable to have this feature to determine if `Coverage.start(eval: true)` is available. (Note that `Coverage.start(eval: true)` just ignores the keyword in Ruby 3.1 or before.)

@ioquatix I would like you to merge the PR to restore the continuous coverage measurement.

If there is anyone who has an opinion against this feature, feel free to add a comment.

----------------------------------------
Bug #19026: Add `Coverage.supported?(x)` to detect support for `eval` coverage flag.
https://bugs.ruby-lang.org/issues/19026#change-99380

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
Introduce the following interface:

```
Coverage.supported?(eval) -> true/false
```

We can also check `lines` `branches` and `methods`?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:110128] [Ruby master Bug#19026] Add `Coverage.supported?(x)` to detect support for `eval` coverage flag.
  2022-09-28 10:52 [ruby-core:110119] [Ruby master Bug#19026] Add `Coverage.supported?(x)` to detect support for `eval` coverage flag ioquatix (Samuel Williams)
                   ` (2 preceding siblings ...)
  2022-09-28 14:18 ` [ruby-core:110124] " mame (Yusuke Endoh)
@ 2022-09-28 14:55 ` Dan0042 (Daniel DeLorme)
  2022-09-28 15:03 ` [ruby-core:110129] " jeremyevans0 (Jeremy Evans)
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Dan0042 (Daniel DeLorme) @ 2022-09-28 14:55 UTC (permalink / raw)
  To: ruby-core

Issue #19026 has been updated by Dan0042 (Daniel DeLorme).


Isn't there a general mechanism for feature support? Like `RbConfig.support?(:eval_coverage)` or something?

----------------------------------------
Bug #19026: Add `Coverage.supported?(x)` to detect support for `eval` coverage flag.
https://bugs.ruby-lang.org/issues/19026#change-99386

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
Introduce the following interface:

```
Coverage.supported?(eval) -> true/false
```

We can also check `lines` `branches` and `methods`?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:110129] [Ruby master Bug#19026] Add `Coverage.supported?(x)` to detect support for `eval` coverage flag.
  2022-09-28 10:52 [ruby-core:110119] [Ruby master Bug#19026] Add `Coverage.supported?(x)` to detect support for `eval` coverage flag ioquatix (Samuel Williams)
                   ` (3 preceding siblings ...)
  2022-09-28 14:55 ` [ruby-core:110128] " Dan0042 (Daniel DeLorme)
@ 2022-09-28 15:03 ` jeremyevans0 (Jeremy Evans)
  2022-09-28 18:06 ` [ruby-core:110135] " mame (Yusuke Endoh)
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jeremyevans0 (Jeremy Evans) @ 2022-09-28 15:03 UTC (permalink / raw)
  To: ruby-core

Issue #19026 has been updated by jeremyevans0 (Jeremy Evans).


mame (Yusuke Endoh) wrote in #note-1:
> Note: This API does determine if the mode is *available*, not *enabled*. So `Coverage.supported?(:eval)` will always returns `true` in Ruby 3.2 regardless of whether `Coverage.start(eval: true)` is called.
> 
> In my first impression, it is okay, but I'd like to hear opinions. @jeremyevans0 Do you have any opinion?

I think having `Coverage.supported?` return true when it is supported is fine.  However, it would be useful to have an API such as `Coverage.activated?` that only returns true when the specific coverage feature is currently enabled.

----------------------------------------
Bug #19026: Add `Coverage.supported?(x)` to detect support for `eval` coverage flag.
https://bugs.ruby-lang.org/issues/19026#change-99387

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
Introduce the following interface:

```
Coverage.supported?(eval) -> true/false
```

We can also check `lines` `branches` and `methods`?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:110135] [Ruby master Bug#19026] Add `Coverage.supported?(x)` to detect support for `eval` coverage flag.
  2022-09-28 10:52 [ruby-core:110119] [Ruby master Bug#19026] Add `Coverage.supported?(x)` to detect support for `eval` coverage flag ioquatix (Samuel Williams)
                   ` (4 preceding siblings ...)
  2022-09-28 15:03 ` [ruby-core:110129] " jeremyevans0 (Jeremy Evans)
@ 2022-09-28 18:06 ` mame (Yusuke Endoh)
  2022-09-28 19:22 ` [ruby-core:110139] " Eregon (Benoit Daloze)
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mame (Yusuke Endoh) @ 2022-09-28 18:06 UTC (permalink / raw)
  To: ruby-core

Issue #19026 has been updated by mame (Yusuke Endoh).


Dan0042 (Daniel DeLorme) wrote in #note-4:
> Isn't there a general mechanism for feature support? Like `RbConfig.support?(:eval_coverage)` or something?

I don't think it makes sense because this doesn't change depending on the ruby config.


jeremyevans0 (Jeremy Evans) wrote in #note-5:
> I think having `Coverage.supported?` return true when it is supported is fine.  However, it would be useful to have an API such as `Coverage.activated?` that only returns true when the specific coverage feature is currently enabled.

Thank you for your comment.

@ioquatix didn't write the use case. He wants to use his own coverage measurement based on TracePoint if "coverage for eval" feature is not supported (i.e., in Ruby 3.1 or before). TBH I am not sure if this is a common use case. @ioquatix isn't `RUBY_VERSION > "3.1"` enough for your case?

I am not so positive to have `Coverage.activated?(:eval or something)` because I don't allow users to write code that changes behavior depending on whether/which coverage is enabled or not. But we already have `Coverage.running?`, so I am okay if there is a common use case for `Coverage.activated?`.

----------------------------------------
Bug #19026: Add `Coverage.supported?(x)` to detect support for `eval` coverage flag.
https://bugs.ruby-lang.org/issues/19026#change-99394

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
Introduce the following interface:

```
Coverage.supported?(eval) -> true/false
```

We can also check `lines` `branches` and `methods`?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:110139] [Ruby master Bug#19026] Add `Coverage.supported?(x)` to detect support for `eval` coverage flag.
  2022-09-28 10:52 [ruby-core:110119] [Ruby master Bug#19026] Add `Coverage.supported?(x)` to detect support for `eval` coverage flag ioquatix (Samuel Williams)
                   ` (5 preceding siblings ...)
  2022-09-28 18:06 ` [ruby-core:110135] " mame (Yusuke Endoh)
@ 2022-09-28 19:22 ` Eregon (Benoit Daloze)
  2022-09-28 19:43 ` [ruby-core:110140] " Dan0042 (Daniel DeLorme)
  2022-09-28 20:46 ` [ruby-core:110141] " ioquatix (Samuel Williams)
  8 siblings, 0 replies; 10+ messages in thread
From: Eregon (Benoit Daloze) @ 2022-09-28 19:22 UTC (permalink / raw)
  To: ruby-core

Issue #19026 has been updated by Eregon (Benoit Daloze).


mame (Yusuke Endoh) wrote in #note-6:
> @ioquatix isn't `RUBY_VERSION > "3.1"` enough for your case?

Please no. For instance other Ruby implementations might already support eval Coverage trivially or can't support it easily, it should be a feature detection, not a hardcoded version check.
+1 for `Coverage.supported?(:eval)`.

----------------------------------------
Bug #19026: Add `Coverage.supported?(x)` to detect support for `eval` coverage flag.
https://bugs.ruby-lang.org/issues/19026#change-99397

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
Introduce the following interface:

```
Coverage.supported?(eval) -> true/false
```

We can also check `lines` `branches` and `methods`?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:110140] [Ruby master Bug#19026] Add `Coverage.supported?(x)` to detect support for `eval` coverage flag.
  2022-09-28 10:52 [ruby-core:110119] [Ruby master Bug#19026] Add `Coverage.supported?(x)` to detect support for `eval` coverage flag ioquatix (Samuel Williams)
                   ` (6 preceding siblings ...)
  2022-09-28 19:22 ` [ruby-core:110139] " Eregon (Benoit Daloze)
@ 2022-09-28 19:43 ` Dan0042 (Daniel DeLorme)
  2022-09-28 20:46 ` [ruby-core:110141] " ioquatix (Samuel Williams)
  8 siblings, 0 replies; 10+ messages in thread
From: Dan0042 (Daniel DeLorme) @ 2022-09-28 19:43 UTC (permalink / raw)
  To: ruby-core

Issue #19026 has been updated by Dan0042 (Daniel DeLorme).


> > Isn't there a general mechanism for feature support? Like `RbConfig.support?(:eval_coverage)` or something?
>
> I don't think it makes sense because this doesn't change depending on the ruby config.

I didn't mean RbConfig per se, just any kind of general mechanism. It seems there isn't.
 

Eregon (Benoit Daloze) wrote in #note-7:
> +1 for `Coverage.supported?(:eval)`.

But then to use this API you need to do
`Coverage.respond_to?(:supported?) && Coverage.supported?(:eval)`
or shorten it to just
`Coverage.respond_to?(:supported?)`

----------------------------------------
Bug #19026: Add `Coverage.supported?(x)` to detect support for `eval` coverage flag.
https://bugs.ruby-lang.org/issues/19026#change-99398

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
Introduce the following interface:

```
Coverage.supported?(eval) -> true/false
```

We can also check `lines` `branches` and `methods`?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:110141] [Ruby master Bug#19026] Add `Coverage.supported?(x)` to detect support for `eval` coverage flag.
  2022-09-28 10:52 [ruby-core:110119] [Ruby master Bug#19026] Add `Coverage.supported?(x)` to detect support for `eval` coverage flag ioquatix (Samuel Williams)
                   ` (7 preceding siblings ...)
  2022-09-28 19:43 ` [ruby-core:110140] " Dan0042 (Daniel DeLorme)
@ 2022-09-28 20:46 ` ioquatix (Samuel Williams)
  8 siblings, 0 replies; 10+ messages in thread
From: ioquatix (Samuel Williams) @ 2022-09-28 20:46 UTC (permalink / raw)
  To: ruby-core

Issue #19026 has been updated by ioquatix (Samuel Williams).

Status changed from Open to Closed

I agree, for the existing Ruby implementations, it's a little clumsy but easily worked around using `respond_to?`. Going forward, this is a simple and good interface.

Merged PR.

----------------------------------------
Bug #19026: Add `Coverage.supported?(x)` to detect support for `eval` coverage flag.
https://bugs.ruby-lang.org/issues/19026#change-99399

* Author: ioquatix (Samuel Williams)
* Status: Closed
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
Introduce the following interface:

```
Coverage.supported?(eval) -> true/false
```

We can also check `lines` `branches` and `methods`?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-09-28 20:47 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-28 10:52 [ruby-core:110119] [Ruby master Bug#19026] Add `Coverage.supported?(x)` to detect support for `eval` coverage flag ioquatix (Samuel Williams)
2022-09-28 11:01 ` [ruby-core:110120] " mame (Yusuke Endoh)
2022-09-28 11:09 ` [ruby-core:110121] " ioquatix (Samuel Williams)
2022-09-28 14:18 ` [ruby-core:110124] " mame (Yusuke Endoh)
2022-09-28 14:55 ` [ruby-core:110128] " Dan0042 (Daniel DeLorme)
2022-09-28 15:03 ` [ruby-core:110129] " jeremyevans0 (Jeremy Evans)
2022-09-28 18:06 ` [ruby-core:110135] " mame (Yusuke Endoh)
2022-09-28 19:22 ` [ruby-core:110139] " Eregon (Benoit Daloze)
2022-09-28 19:43 ` [ruby-core:110140] " Dan0042 (Daniel DeLorme)
2022-09-28 20:46 ` [ruby-core:110141] " ioquatix (Samuel Williams)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).