Skip to content

igraph test failures with withr 3.0.3 #2701

Description

@lionel-

What happens, and what did you expect instead?

Hello, with the 3.0.3 version of withr that I'm about to send to CRAN (to fix CRAN checks), I see:

  ══ Failed tests ════════════════════════════════════════════════════════════════
  ── Failure ('test-games.R:398:3'): sample_bipartite works -- directed gnp ──────
  Expected `ecount(graph)` to equal `expected`.
  Differences:
    `actual`: 5.0
  `expected`: 6.0
  
  Backtrace:
      ▆
   1. └─igraph:::expect_ecount(g_rand_bip_dir, 6) at test-games.R:398:3
   2.   └─testthat::expect_equal(...) at ./helper.R:36:3
  ── Failure ('test-games.R:401:3'): sample_bipartite works -- directed gnp ──────
  Expected output from `print_all(g_rand_bip_dir)` to match regexp "5->11".
  Actual output:
  x | IGRAPH 3a135e9 D--B 15 5 -- Bipartite Gnp random graph
    | + attr: name (g/c), p (g/n), type (v/l)
    | + edges from 3a135e9:
    | [1]  9->11  8->13 10->14  6->15  7->15
  ── Failure ('test-games.R:410:3'): sample_bipartite works -- directed gnp ──────
  Expected output from `print_all(g_rand_bip_in)` to match regexp "11->3".
  Actual output:
  x | IGRAPH 6d56768 D--B 15 5 -- Bipartite Gnp random graph
    | + attr: name (g/c), p (g/n), type (v/l)
    | + edges from 6d56768:
    | [1] 11->8 12->8 12->9 13->4 14->9
  ── Failure ('test-games.R:426:3'): sample_bipartite works -- directed gnm ──────
  Expected output from `print_all(g_rand_bip_gnm_dir)` to match regexp "5->12".
  Actual output:
  x | IGRAPH de1cd9f D--B 15 8 -- Bipartite Gnm random graph
    | + attr: name (g/c), m (g/n), type (v/l)
    | + edges from de1cd9f:
    | [1]  9->11 10->11  6->13  8->13 10->13  2->14  6->14 10->14
  ── Failure ('test-games.R:439:3'): sample_bipartite works -- directed gnm ──────
  Expected output from `print_all(g_rand_bip_gnm_in)` to match regexp "12->10".
  Actual output:
  x | IGRAPH 1134862 D--B 15 8 -- Bipartite Gnm random graph
    | + attr: name (g/c), m (g/n), type (v/l)
    | + edges from 1134862:
    | [1] 12-> 4 12-> 5 12-> 8 13-> 5 14-> 1 14-> 3 15-> 9 15->10
  
  [ FAIL 5 | WARN 0 | SKIP 119 | PASS 6234 ]
  Error:
  ! Test failures.
  Execution halted
* checking for unstated dependencies in vignettes ... OK
* checking package vignettes ... OK
* checking re-building of vignette outputs ... OK
* DONE
Status: 1 ERROR, 2 NOTEs

I believe this is due to this change (from NEWS):

* Fixed issue that prevented `local_seed()` from preserving the seed (#286, @BjarkeHautop).

  Note: If you had before:

  ```r
  test_that("A", {
    withr::local_seed(1)   # Seeds locally
    runif(...)
  })

  test_that("B", {
    runif(...)             # NO seed of its own
  })
  ```

  Before the fix, the test "B" was accidentally seeded by "A". Now it needs to be seeded on its own.

I see in test-games.R that some tests set a seed with withr::local_seed() (

withr::local_seed(42)
) but others don't (
test_that("sample_bipartite works -- directed gnp", {
).

The tests should now all set their own seed.

To reproduce

System information

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions