From 2e6b3d02be0efa8b070b83e3f951b92fbb6bf61a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Tue, 6 Jan 2026 12:46:30 +0100 Subject: [PATCH 01/10] feat: improve formatting of error messages from C --- src/rinterface_extra.c | 23 ++- tests/testthat/_snaps/aaa-auto.md | 213 ++++++++++++++++++---------- tests/testthat/_snaps/centrality.md | 3 +- tests/testthat/_snaps/games.md | 6 +- tests/testthat/test-centrality.R | 10 +- 5 files changed, 174 insertions(+), 81 deletions(-) diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index ca1dc00f642..4ac8b903e47 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -2315,6 +2315,17 @@ static inline const char* maybe_add_punctuation(const char* msg, const char* pun return is_punctuated(msg) ? "" : punctuation; } +/* Strip vendor/cigraph/src/ prefix from file path */ +static inline const char* simplify_file_path(const char* file) { + const char* prefix = "vendor/cigraph/src/"; + size_t prefix_len = strlen(prefix); + + if (strncmp(file, prefix, prefix_len) == 0) { + return file + prefix_len; + } + return file; +} + void Rx_igraph_fatal_handler(const char *reason, const char *file, int line) { #ifdef IGRAPH_SANITIZER_AVAILABLE __sanitizer_print_stack_trace(); @@ -2336,10 +2347,12 @@ void Rx_igraph_error_handler(const char *reason, const char *file, * IGRAPH_FINALLY_FREE() can then clean it up. */ if (Rx_igraph_errors_count == 0 || !Rx_igraph_in_r_check) { + const char* simplified_path = simplify_file_path(file); snprintf(Rx_igraph_error_reason, sizeof(Rx_igraph_error_reason), - "At %s:%i : %s%s %s", file, line, reason, - maybe_add_punctuation(reason, ","), - igraph_strerror(igraph_errno)); + "%s%s %s\nSource: %s:%i", reason, + maybe_add_punctuation(reason, "."), + igraph_strerror(igraph_errno), + simplified_path, line); Rx_igraph_error_reason[sizeof(Rx_igraph_error_reason) - 1] = 0; // FIXME: This is a hack, we should replace all memory allocations in the @@ -2356,8 +2369,10 @@ void Rx_igraph_error_handler(const char *reason, const char *file, void Rx_igraph_warning_handler(const char *reason, const char *file, int line) { if (Rx_igraph_warnings_count == 0) { + const char* simplified_path = simplify_file_path(file); snprintf(Rx_igraph_warning_reason, sizeof(Rx_igraph_warning_reason), - "At %s:%i : %s%s", file, line, reason, maybe_add_punctuation(reason, ".")); + "%s%s\nSource: %s:%i", reason, maybe_add_punctuation(reason, "."), + simplified_path, line); Rx_igraph_warning_reason[sizeof(Rx_igraph_warning_reason) - 1] = 0; } Rx_igraph_warnings_count++; diff --git a/tests/testthat/_snaps/aaa-auto.md b/tests/testthat/_snaps/aaa-auto.md index 26e86730a08..7cf09c9412d 100644 --- a/tests/testthat/_snaps/aaa-auto.md +++ b/tests/testthat/_snaps/aaa-auto.md @@ -20,7 +20,8 @@ empty_impl(n = -1) Condition Error in `empty_impl()`: - ! At vendor/cigraph/src/graph/type_indexededgelist.c:xx : Number of vertices must not be negative. Invalid value + ! Number of vertices must not be negative. Invalid value + Source: graph/type_indexededgelist.c:xx # add_edges_impl basic @@ -155,7 +156,8 @@ wheel_impl(n = -1) Condition Error in `wheel_impl()`: - ! At vendor/cigraph/src/constructors/regular.c:xx : Invalid number of vertices. Invalid vertex ID + ! Invalid number of vertices. Invalid vertex ID + Source: constructors/regular.c:xx # hypercube_impl basic @@ -181,7 +183,8 @@ hypercube_impl(n = 10000) Condition Error in `hypercube_impl()`: - ! At vendor/cigraph/src/constructors/regular.c:xx : The requested hypercube graph dimension (10000) is too high. It must be no greater than 57. Invalid value + ! The requested hypercube graph dimension (10000) is too high. It must be no greater than 57. Invalid value + Source: constructors/regular.c:xx # square_lattice_impl basic @@ -208,7 +211,8 @@ square_lattice_impl(dimvector = -1) Condition Error in `square_lattice_impl()`: - ! At vendor/cigraph/src/constructors/regular.c:xx : Invalid dimension vector. Invalid value + ! Invalid dimension vector. Invalid value + Source: constructors/regular.c:xx # triangular_lattice_impl basic @@ -234,7 +238,8 @@ triangular_lattice_impl(dimvector = -1) Condition Error in `triangular_lattice_impl()`: - ! At vendor/cigraph/src/constructors/lattices.c:xx : Invalid dimension vector. Invalid value + ! Invalid dimension vector. Invalid value + Source: constructors/lattices.c:xx # path_graph_impl basic @@ -260,7 +265,8 @@ path_graph_impl(n = -1) Condition Error in `path_graph_impl()`: - ! At vendor/cigraph/src/constructors/regular.c:xx : The number of vertices must be non-negative, got -1. Invalid value + ! The number of vertices must be non-negative, got -1. Invalid value + Source: constructors/regular.c:xx # cycle_graph_impl basic @@ -286,7 +292,8 @@ cycle_graph_impl(n = -1) Condition Error in `cycle_graph_impl()`: - ! At vendor/cigraph/src/constructors/regular.c:xx : The number of vertices must be non-negative, got -1. Invalid value + ! The number of vertices must be non-negative, got -1. Invalid value + Source: constructors/regular.c:xx # symmetric_tree_impl basic @@ -312,7 +319,8 @@ symmetric_tree_impl(branches = -1) Condition Error in `symmetric_tree_impl()`: - ! At vendor/cigraph/src/constructors/regular.c:xx : The number of branches must be positive at each level. Invalid value + ! The number of branches must be positive at each level. Invalid value + Source: constructors/regular.c:xx # regular_tree_impl basic @@ -339,7 +347,8 @@ regular_tree_impl(h = -1) Condition Error in `regular_tree_impl()`: - ! At vendor/cigraph/src/constructors/regular.c:xx : Height of regular tree must be positive, got -1. Invalid value + ! Height of regular tree must be positive, got -1. Invalid value + Source: constructors/regular.c:xx # full_citation_impl basic @@ -365,7 +374,8 @@ full_citation_impl(n = -1) Condition Error in `full_citation_impl()`: - ! At vendor/cigraph/src/constructors/full.c:xx : Invalid number of vertices. Invalid value + ! Invalid number of vertices. Invalid value + Source: constructors/full.c:xx # atlas_impl basic @@ -390,7 +400,8 @@ atlas_impl(number = -1) Condition Error in `atlas_impl()`: - ! At vendor/cigraph/src/constructors/atlas.c:xx : No such graph in atlas. The graph index must be less than 1253. Invalid value + ! No such graph in atlas. The graph index must be less than 1253. Invalid value + Source: constructors/atlas.c:xx # extended_chordal_ring_impl basic @@ -416,7 +427,8 @@ extended_chordal_ring_impl(nodes = -1, W = matrix(c(1, 2))) Condition Error in `extended_chordal_ring_impl()`: - ! At vendor/cigraph/src/constructors/regular.c:xx : An extended chordal ring has at least 3 nodes. Invalid value + ! An extended chordal ring has at least 3 nodes. Invalid value + Source: constructors/regular.c:xx # graph_power_impl basic @@ -477,7 +489,8 @@ de_bruijn_impl(m = -1, n = 3) Condition Error in `de_bruijn_impl()`: - ! At vendor/cigraph/src/constructors/de_bruijn.c:xx : `m' and `n' should be non-negative in a de Bruijn graph, Invalid value + ! `m' and `n' should be non-negative in a de Bruijn graph. Invalid value + Source: constructors/de_bruijn.c:xx # kautz_impl basic @@ -498,7 +511,8 @@ kautz_impl(m = -1, n = 3) Condition Error in `kautz_impl()`: - ! At vendor/cigraph/src/constructors/kautz.c:xx : `m' and `n' should be non-negative in a Kautz graph, Invalid value + ! `m' and `n' should be non-negative in a Kautz graph. Invalid value + Source: constructors/kautz.c:xx # lcf_vector_impl basic @@ -517,7 +531,8 @@ lcf_vector_impl(n = -1, shifts = c(3, -3, 4), repeats = 2) Condition Error in `lcf_vector_impl()`: - ! At vendor/cigraph/src/graph/type_indexededgelist.c:xx : Number of vertices must not be negative. Invalid value + ! Number of vertices must not be negative. Invalid value + Source: graph/type_indexededgelist.c:xx # mycielski_graph_impl basic @@ -534,7 +549,8 @@ mycielski_graph_impl(k = -1) Condition Error in `mycielski_graph_impl()`: - ! At vendor/cigraph/src/constructors/mycielskian.c:xx : The Mycielski graph order must not be negative. Invalid value + ! The Mycielski graph order must not be negative. Invalid value + Source: constructors/mycielskian.c:xx # adjlist_impl basic @@ -551,7 +567,8 @@ adjlist_impl(adjlist = -1, mode = "out") Condition Error in `adjlist_impl()`: - ! At vendor/cigraph/src/constructors/basic_constructors.c:xx : Invalid (negative or too large) vertex ID. Invalid vertex ID + ! Invalid (negative or too large) vertex ID. Invalid vertex ID + Source: constructors/basic_constructors.c:xx # full_bipartite_impl basic @@ -587,7 +604,8 @@ full_bipartite_impl(n1 = -1, n2 = 3) Condition Error in `full_bipartite_impl()`: - ! At vendor/cigraph/src/misc/bipartite.c:xx : Invalid number of vertices for bipartite graph. Invalid value + ! Invalid number of vertices for bipartite graph. Invalid value + Source: misc/bipartite.c:xx # full_multipartite_impl basic @@ -643,7 +661,8 @@ full_multipartite_impl(n = -1) Condition Error in `full_multipartite_impl()`: - ! At vendor/cigraph/src/constructors/full.c:xx : Number of vertices must not be negative in any partition. Invalid value + ! Number of vertices must not be negative in any partition. Invalid value + Source: constructors/full.c:xx # realize_degree_sequence_impl basic @@ -674,7 +693,8 @@ realize_degree_sequence_impl(out_deg = -1) Condition Error in `realize_degree_sequence_impl()`: - ! At vendor/cigraph/src/misc/degree_sequence.cpp:xx : The sum of degrees must be even for an undirected graph. Invalid value + ! The sum of degrees must be even for an undirected graph. Invalid value + Source: misc/degree_sequence.cpp:xx # realize_bipartite_degree_sequence_impl basic @@ -705,7 +725,8 @@ realize_bipartite_degree_sequence_impl(degrees1 = -1, degrees2 = c(2, 2)) Condition Error in `realize_bipartite_degree_sequence_impl()`: - ! At vendor/cigraph/src/misc/degree_sequence.cpp:xx : The given bidegree sequence cannot be realized as a bipartite simple graph. Invalid value + ! The given bidegree sequence cannot be realized as a bipartite simple graph. Invalid value + Source: misc/degree_sequence.cpp:xx # circulant_impl basic @@ -733,7 +754,8 @@ circulant_impl(n = -1, shifts = c(1, 2)) Condition Error in `circulant_impl()`: - ! At vendor/cigraph/src/constructors/circulant.c:xx : Number of nodes = -1 must be non-negative. Invalid value + ! Number of nodes = -1 must be non-negative. Invalid value + Source: constructors/circulant.c:xx # generalized_petersen_impl basic @@ -751,7 +773,8 @@ generalized_petersen_impl(n = -1, k = 2) Condition Error in `generalized_petersen_impl()`: - ! At vendor/cigraph/src/constructors/generalized_petersen.c:xx : n = -1 must be at least 3. Invalid value + ! n = -1 must be at least 3. Invalid value + Source: constructors/generalized_petersen.c:xx # turan_impl basic @@ -782,7 +805,8 @@ turan_impl(n = -1, r = 2) Condition Error in `turan_impl()`: - ! At vendor/cigraph/src/constructors/full.c:xx : Number of vertices must not be negative, got -1. Invalid value + ! Number of vertices must not be negative, got -1. Invalid value + Source: constructors/full.c:xx # erdos_renyi_game_gnp_impl basic @@ -808,7 +832,8 @@ erdos_renyi_game_gnp_impl(n = -1, p = 0.5) Condition Error in `erdos_renyi_game_gnp_impl()`: - ! At vendor/cigraph/src/games/erdos_renyi.c:xx : Invalid number of vertices. Invalid value + ! Invalid number of vertices. Invalid value + Source: games/erdos_renyi.c:xx # erdos_renyi_game_gnm_impl basic @@ -834,7 +859,8 @@ erdos_renyi_game_gnm_impl(n = -1, m = 3) Condition Error in `erdos_renyi_game_gnm_impl()`: - ! At vendor/cigraph/src/games/erdos_renyi.c:xx : Invalid number of vertices. Invalid value + ! Invalid number of vertices. Invalid value + Source: games/erdos_renyi.c:xx # growing_random_game_impl basic @@ -862,7 +888,8 @@ growing_random_game_impl(n = -1, m = 2) Condition Error in `growing_random_game_impl()`: - ! At vendor/cigraph/src/games/growing_random.c:xx : Invalid number of vertices. Invalid value + ! Invalid number of vertices. Invalid value + Source: games/growing_random.c:xx # preference_game_impl basic @@ -886,7 +913,8 @@ fixed_sizes = FALSE, pref_matrix = matrix(c(0.5, 0.5, 0.5, 0.5), 2, 2)) Condition Error in `preference_game_impl()`: - ! At vendor/cigraph/src/games/preference.c:xx : The number of vertices must be non-negative. Invalid value + ! The number of vertices must be non-negative. Invalid value + Source: games/preference.c:xx # asymmetric_preference_game_impl basic @@ -915,7 +943,8 @@ c(0.5, 0.5, 0.5, 0.5), 2, 2)) Condition Error in `asymmetric_preference_game_impl()`: - ! At vendor/cigraph/src/games/preference.c:xx : The number of vertices must not be negative. Invalid value + ! The number of vertices must not be negative. Invalid value + Source: games/preference.c:xx # rewire_edges_impl basic @@ -978,7 +1007,8 @@ forest_fire_game_impl(nodes = -1, fw_prob = 0.5) Condition Error in `forest_fire_game_impl()`: - ! At vendor/cigraph/src/games/forestfire.c:xx : Insufficient memory for forest fire model. Out of memory + ! Insufficient memory for forest fire model. Out of memory + Source: games/forestfire.c:xx # simple_interconnected_islands_game_impl basic @@ -999,7 +1029,8 @@ islands_pin = 0.5, n_inter = 1) Condition Error in `simple_interconnected_islands_game_impl()`: - ! At vendor/cigraph/src/games/islands.c:xx : Number of islands cannot be negative, got -1. Invalid value + ! Number of islands cannot be negative, got -1. Invalid value + Source: games/islands.c:xx # chung_lu_game_impl basic @@ -1028,7 +1059,8 @@ chung_lu_game_impl(out_weights = -1) Condition Error in `chung_lu_game_impl()`: - ! At vendor/cigraph/src/games/chung_lu.c:xx : Vertex weights must not be negative in Chung-Lu model, got -1. Invalid value + ! Vertex weights must not be negative in Chung-Lu model, got -1. Invalid value + Source: games/chung_lu.c:xx # static_fitness_game_impl basic @@ -1057,7 +1089,8 @@ static_fitness_game_impl(no_of_edges = -1, fitness_out = c(1, 2, 3)) Condition Error in `static_fitness_game_impl()`: - ! At vendor/cigraph/src/games/static_fitness.c:xx : Number of edges cannot be negative, got -1. Invalid value + ! Number of edges cannot be negative, got -1. Invalid value + Source: games/static_fitness.c:xx # static_power_law_game_impl basic @@ -1088,7 +1121,8 @@ static_power_law_game_impl(no_of_nodes = -1, no_of_edges = 4, exponent_out = 2.5) Condition Error in `static_power_law_game_impl()`: - ! At vendor/cigraph/src/games/static_fitness.c:xx : Number of nodes cannot be negative, got -1. Invalid value + ! Number of nodes cannot be negative, got -1. Invalid value + Source: games/static_fitness.c:xx # k_regular_game_impl basic @@ -1116,7 +1150,8 @@ k_regular_game_impl(no_of_nodes = -1, k = 2) Condition Error in `k_regular_game_impl()`: - ! At vendor/cigraph/src/games/k_regular.c:xx : Number of nodes must be non-negative. Invalid value + ! Number of nodes must be non-negative. Invalid value + Source: games/k_regular.c:xx # sbm_game_impl basic @@ -1145,7 +1180,8 @@ sbm_game_impl(n = -1, pref_matrix = matrix(0.5, 2, 2), block_sizes = c(2, 3)) Condition Error in `sbm_game_impl()`: - ! At vendor/cigraph/src/games/sbm.c:xx : Sum of the block sizes (5) must equal the number of vertices (-1). Invalid value + ! Sum of the block sizes (5) must equal the number of vertices (-1). Invalid value + Source: games/sbm.c:xx # hsbm_game_impl basic @@ -1163,7 +1199,8 @@ hsbm_game_impl(n = -1, m = 2, rho = 0.5, C = matrix(1, 2, 2), p = 0.5) Condition Error in `hsbm_game_impl()`: - ! At vendor/cigraph/src/games/sbm.c:xx : `n' must be positive for HSBM, Invalid value + ! `n' must be positive for HSBM. Invalid value + Source: games/sbm.c:xx # hsbm_list_game_impl basic @@ -1191,7 +1228,8 @@ matrix(1, 2, 2), matrix(1, 2, 2)), p = 0.5) Condition Error in `hsbm_list_game_impl()`: - ! At vendor/cigraph/src/games/sbm.c:xx : `n' must be positive for HSBM. Invalid value + ! `n' must be positive for HSBM. Invalid value + Source: games/sbm.c:xx # correlated_game_impl basic @@ -1249,7 +1287,8 @@ correlated_pair_game_impl(n = -1, corr = 0.5, p = 0.5) Condition Error in `correlated_pair_game_impl()`: - ! At vendor/cigraph/src/games/erdos_renyi.c:xx : Invalid number of vertices. Invalid value + ! Invalid number of vertices. Invalid value + Source: games/erdos_renyi.c:xx # dot_product_game_impl basic @@ -1257,7 +1296,8 @@ dot_product_game_impl(vecs = matrix(0.5, 5, 2)) Condition Warning in `dot_product_game_impl()`: - At vendor/cigraph/src/games/dotproduct.c:90 : Greater than 1 connection probability in dot-product graph. + Greater than 1 connection probability in dot-product graph. + Source: games/dotproduct.c:90 Output IGRAPH U--- 2 1 -- + edge: @@ -1269,7 +1309,8 @@ dot_product_game_impl(vecs = matrix(0.5, 5, 2), directed = TRUE) Condition Warning in `dot_product_game_impl()`: - At vendor/cigraph/src/games/dotproduct.c:90 : Greater than 1 connection probability in dot-product graph. + Greater than 1 connection probability in dot-product graph. + Source: games/dotproduct.c:90 Output IGRAPH D--- 2 2 -- + edges: @@ -1309,7 +1350,8 @@ sample_sphere_surface_impl(dim = -1, n = 5) Condition Error in `sample_sphere_surface_impl()`: - ! At vendor/cigraph/src/games/dotproduct.c:xx : Sphere must be at least two dimensional to sample from surface. Invalid value + ! Sphere must be at least two dimensional to sample from surface. Invalid value + Source: games/dotproduct.c:xx # sample_sphere_volume_impl basic @@ -1337,7 +1379,8 @@ sample_sphere_volume_impl(dim = -1, n = 5) Condition Error in `sample_sphere_volume_impl()`: - ! At vendor/cigraph/src/games/dotproduct.c:xx : Sphere must be at least two dimensional to sample from surface. Invalid value + ! Sphere must be at least two dimensional to sample from surface. Invalid value + Source: games/dotproduct.c:xx # sample_dirichlet_impl basic @@ -1355,7 +1398,8 @@ sample_dirichlet_impl(n = -1, alpha = c(1, 1, 1)) Condition Error in `sample_dirichlet_impl()`: - ! At vendor/cigraph/src/games/dotproduct.c:xx : Number of samples should be non-negative, got -1. Invalid value + ! Number of samples should be non-negative, got -1. Invalid value + Source: games/dotproduct.c:xx # are_adjacent_impl basic @@ -2174,7 +2218,8 @@ transitivity_barrat_impl(graph = g) Condition Warning in `transitivity_barrat_impl()`: - At vendor/cigraph/src/properties/triangles.c:913 : No weights given for Barrat's transitivity, unweighted version is used. + No weights given for Barrat's transitivity, unweighted version is used. + Source: properties/triangles.c:913 Output [1] NaN 0 NaN @@ -2184,7 +2229,8 @@ transitivity_barrat_impl(graph = g, mode = "zero") Condition Warning in `transitivity_barrat_impl()`: - At vendor/cigraph/src/properties/triangles.c:913 : No weights given for Barrat's transitivity, unweighted version is used. + No weights given for Barrat's transitivity, unweighted version is used. + Source: properties/triangles.c:913 Output [1] 0 0 0 @@ -3092,7 +3138,8 @@ centralization_degree_tmax_impl(nodes = -1, loops = TRUE) Condition Error in `centralization_degree_tmax_impl()`: - ! At vendor/cigraph/src/centrality/centralization.c:xx : Number of vertices must not be negative. Invalid value + ! Number of vertices must not be negative. Invalid value + Source: centrality/centralization.c:xx # centralization_betweenness_impl basic @@ -3152,7 +3199,8 @@ centralization_betweenness_tmax_impl(nodes = -1, directed = TRUE) Condition Error in `centralization_betweenness_tmax_impl()`: - ! At vendor/cigraph/src/centrality/centralization.c:xx : Number of vertices must not be negative. Invalid value + ! Number of vertices must not be negative. Invalid value + Source: centrality/centralization.c:xx # centralization_closeness_impl basic @@ -3212,7 +3260,8 @@ centralization_closeness_tmax_impl(nodes = -1) Condition Error in `centralization_closeness_tmax_impl()`: - ! At vendor/cigraph/src/centrality/centralization.c:xx : Number of vertices must not be negative. Invalid value + ! Number of vertices must not be negative. Invalid value + Source: centrality/centralization.c:xx # centralization_eigenvector_centrality_impl basic @@ -3403,7 +3452,8 @@ centralization_eigenvector_centrality_tmax_impl(nodes = -1) Condition Error in `centralization_eigenvector_centrality_tmax_impl()`: - ! At vendor/cigraph/src/centrality/centralization.c:xx : Number of vertices must not be negative. Invalid value + ! Number of vertices must not be negative. Invalid value + Source: centrality/centralization.c:xx # assortativity_nominal_impl basic @@ -3907,7 +3957,8 @@ Warning in `is_graphical_impl()`: NAs introduced by coercion Error in `is_graphical_impl()`: - ! At rinterface_extra.c:xx : The value nan is not representable as an integer. Invalid value + ! The value nan is not representable as an integer. Invalid value + Source: rinterface_extra.c:xx # bfs_simple_impl basic @@ -4091,7 +4142,8 @@ bipartite_game_gnp_impl(n1 = -1, n2 = 2, p = 0.5) Condition Error in `bipartite_game_gnp_impl()`: - ! At vendor/cigraph/src/misc/bipartite.c:xx : Invalid number of vertices for bipartite graph. Invalid value + ! Invalid number of vertices for bipartite graph. Invalid value + Source: misc/bipartite.c:xx # bipartite_game_gnm_impl basic @@ -4127,7 +4179,8 @@ bipartite_game_gnm_impl(n1 = -1, n2 = 2, m = 1) Condition Error in `bipartite_game_gnm_impl()`: - ! At vendor/cigraph/src/misc/bipartite.c:xx : Invalid number of vertices for bipartite graph. Invalid value + ! Invalid number of vertices for bipartite graph. Invalid value + Source: misc/bipartite.c:xx # get_laplacian_impl basic @@ -5342,7 +5395,8 @@ Warning in `compare_communities_impl()`: NAs introduced by coercion Error in `compare_communities_impl()`: - ! At rinterface_extra.c:xx : The value nan is not representable as an integer. Invalid value + ! The value nan is not representable as an integer. Invalid value + Source: rinterface_extra.c:xx # modularity_impl basic @@ -5550,7 +5604,8 @@ Warning in `split_join_distance_impl()`: NAs introduced by coercion Error in `split_join_distance_impl()`: - ! At rinterface_extra.c:xx : The value nan is not representable as an integer. Invalid value + ! The value nan is not representable as an integer. Invalid value + Source: rinterface_extra.c:xx # community_infomap_impl basic @@ -5765,7 +5820,8 @@ hrg_create_impl(graph = g, prob = 0.5) Condition Error in `hrg_create_impl()`: - ! At vendor/cigraph/src/hrg/hrg.cc:xx : HRG probability vector size (1) should be equal to the number of internal nodes (2). Invalid value + ! HRG probability vector size (1) should be equal to the number of internal nodes (2). Invalid value + Source: hrg/hrg.cc:xx # hrg_resize_impl basic @@ -5794,7 +5850,8 @@ hrg_resize_impl(hrg = -1, newsize = 2) Condition Error in `hrg_resize_impl()`: - ! At rinterface_extra.c:xx : The value nan is not representable as an integer. Invalid value + ! The value nan is not representable as an integer. Invalid value + Source: rinterface_extra.c:xx # hrg_size_impl basic @@ -5809,7 +5866,8 @@ hrg_size_impl(hrg = -1) Condition Error in `hrg_size_impl()`: - ! At rinterface_extra.c:xx : The value nan is not representable as an integer. Invalid value + ! The value nan is not representable as an integer. Invalid value + Source: rinterface_extra.c:xx # from_hrg_dendrogram_impl basic @@ -5832,7 +5890,8 @@ from_hrg_dendrogram_impl(hrg = -1) Condition Error in `from_hrg_dendrogram_impl()`: - ! At rinterface_extra.c:xx : The value nan is not representable as an integer. Invalid value + ! The value nan is not representable as an integer. Invalid value + Source: rinterface_extra.c:xx # get_adjacency_sparse_impl basic @@ -6087,7 +6146,8 @@ motifs_randesu_no_impl(graph = g, size = 3, cut_prob = c(0.1)) Condition Error in `motifs_randesu_no_impl()`: - ! At vendor/cigraph/src/misc/motifs.c:xx : Cut probability vector size (1) must agree with motif size (3). Invalid value + ! Cut probability vector size (1) must agree with motif size (3). Invalid value + Source: misc/motifs.c:xx # dyad_census_impl basic @@ -6118,7 +6178,8 @@ triad_census_impl(graph = g) Condition Warning in `triad_census_impl()`: - At vendor/cigraph/src/misc/motifs.c:1157 : Triad census called on an undirected graph. All connections will be treated as mutual. + Triad census called on an undirected graph. All connections will be treated as mutual. + Source: misc/motifs.c:1157 Output [1] 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 @@ -7000,7 +7061,8 @@ Warning in `isoclass_create_impl()`: NAs introduced by coercion Error in `isoclass_create_impl()`: - ! At rinterface_extra.c:xx : The value nan is not representable as an integer. Invalid value + ! The value nan is not representable as an integer. Invalid value + Source: rinterface_extra.c:xx # isomorphic_vf2_impl basic @@ -7553,7 +7615,8 @@ Warning in `graph_count_impl()`: NAs introduced by coercion Error in `graph_count_impl()`: - ! At rinterface_extra.c:xx : The value nan is not representable as an integer. Invalid value + ! The value nan is not representable as an integer. Invalid value + Source: rinterface_extra.c:xx # is_matching_impl basic @@ -7986,7 +8049,8 @@ options = list(maxiter = 10)) Condition Error in `eigen_adjacency_impl()`: - ! At vendor/cigraph/src/linalg/eigen.c:xx : 'LAPACK' algorithm not implemented yet, Unimplemented function call + ! 'LAPACK' algorithm not implemented yet. Unimplemented function call + Source: linalg/eigen.c:xx # eigen_adjacency_impl errors @@ -8046,7 +8110,8 @@ Warning in `power_law_fit_impl()`: NAs introduced by coercion Error in `power_law_fit_impl()`: - ! At vendor/cigraph/src/misc/power_law_fit.c:xx : xmin must be greater than zero, Invalid value + ! xmin must be greater than zero. Invalid value + Source: misc/power_law_fit.c:xx # sir_impl basic @@ -9537,7 +9602,8 @@ dim_select_impl(sv = NULL) Condition Error in `dim_select_impl()`: - ! At vendor/cigraph/src/misc/embedding.c:xx : Need at least one singular value for dimensionality selection, Invalid value + ! Need at least one singular value for dimensionality selection. Invalid value + Source: misc/embedding.c:xx # solve_lsap_impl basic @@ -9669,7 +9735,8 @@ eulerian_cycle_impl(graph = g1) Condition Error in `eulerian_cycle_impl()`: - ! At vendor/cigraph/src/paths/eulerian.c:xx : The graph does not have an Eulerian cycle. Input problem has no solution + ! The graph does not have an Eulerian cycle. Input problem has no solution + Source: paths/eulerian.c:xx --- @@ -9812,7 +9879,8 @@ Warning in `from_prufer_impl()`: NAs introduced by coercion Error in `from_prufer_impl()`: - ! At rinterface_extra.c:xx : The value nan is not representable as an integer. Invalid value + ! The value nan is not representable as an integer. Invalid value + Source: rinterface_extra.c:xx # to_prufer_impl basic @@ -9855,7 +9923,8 @@ Warning in `tree_from_parent_vector_impl()`: NAs introduced by coercion Error in `tree_from_parent_vector_impl()`: - ! At rinterface_extra.c:xx : The value nan is not representable as an integer. Invalid value + ! The value nan is not representable as an integer. Invalid value + Source: rinterface_extra.c:xx # is_complete_impl basic @@ -9914,7 +9983,8 @@ Warning in `tree_game_impl()`: NAs introduced by coercion Error in `tree_game_impl()`: - ! At rinterface_extra.c:xx : The value nan is not representable as an integer. Invalid value + ! The value nan is not representable as an integer. Invalid value + Source: rinterface_extra.c:xx # vertex_coloring_greedy_impl basic @@ -10310,7 +10380,8 @@ famous_impl(name = "NonexistentGraph") Condition Error in `famous_impl()`: - ! At vendor/cigraph/src/constructors/famous.c:xx : NonexistentGraph is not a known graph. See the documentation for valid graph names. Invalid value + ! NonexistentGraph is not a known graph. See the documentation for valid graph names. Invalid value + Source: constructors/famous.c:xx # constraint_impl errors diff --git a/tests/testthat/_snaps/centrality.md b/tests/testthat/_snaps/centrality.md index 62a6c46264f..a676e0e14ef 100644 --- a/tests/testthat/_snaps/centrality.md +++ b/tests/testthat/_snaps/centrality.md @@ -48,7 +48,8 @@ arpack(f, options = list(nev = 2, ncv = 4), sym = TRUE) Condition Error in `arpack()`: - ! At vendor/cigraph/src/linalg/arpack.c:1102 : ARPACK error, N must be positive + ! ARPACK error. N must be positive + Source: linalg/arpack.c: --- diff --git a/tests/testthat/_snaps/games.md b/tests/testthat/_snaps/games.md index 922ef9a505f..15522aa0df9 100644 --- a/tests/testthat/_snaps/games.md +++ b/tests/testthat/_snaps/games.md @@ -4,7 +4,8 @@ sample_degseq(exponential_degrees, method = "vl") Condition Error in `sample_degseq()`: - ! At vendor/cigraph/src/games/degree_sequence_vl/gengraph_mr-connected.cpp: : Cannot make a connected graph from the given degree sequence. Invalid value + ! Cannot make a connected graph from the given degree sequence. Invalid value + Source: games/degree_sequence_vl/gengraph_mr-connected.cpp: # sample_degseq() works -- Power-law degree error @@ -12,5 +13,6 @@ sample_degseq(powerlaw_degrees, method = "vl") Condition Error in `sample_degseq()`: - ! At vendor/cigraph/src/games/degree_sequence_vl/gengraph_mr-connected.cpp: : Cannot realize the given degree sequence as an undirected, simple graph. Invalid value + ! Cannot realize the given degree sequence as an undirected, simple graph. Invalid value + Source: games/degree_sequence_vl/gengraph_mr-connected.cpp: diff --git a/tests/testthat/test-centrality.R b/tests/testthat/test-centrality.R index 41653455073..2f983e74f8c 100644 --- a/tests/testthat/test-centrality.R +++ b/tests/testthat/test-centrality.R @@ -845,9 +845,13 @@ test_that("eigen_centrality() deprecated scale argument", { test_that("arpack() errors well", { f <- function(x, extra = NULL) x - expect_snapshot(error = TRUE, { - arpack(f, options = list(nev = 2, ncv = 4), sym = TRUE) - }) + expect_snapshot( + error = TRUE, + { + arpack(f, options = list(nev = 2, ncv = 4), sym = TRUE) + }, + transform = function(x) sub("\\:[0-9]+", ":", x) + ) expect_snapshot(error = TRUE, { arpack( f, From 9f268d8f934d24db0d9780a136fd710c8de32282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Tue, 13 Jan 2026 09:45:32 +0100 Subject: [PATCH 02/10] Update src/rinterface_extra.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Szabolcs Horvát --- src/rinterface_extra.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 4ac8b903e47..379ea83d61b 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -2315,10 +2315,11 @@ static inline const char* maybe_add_punctuation(const char* msg, const char* pun return is_punctuated(msg) ? "" : punctuation; } -/* Strip vendor/cigraph/src/ prefix from file path */ -static inline const char* simplify_file_path(const char* file) { - const char* prefix = "vendor/cigraph/src/"; - size_t prefix_len = strlen(prefix); +/* Strip vendor/cigraph/src/ prefix from file path. This prefix depends on the + * build procedure, namely on the directory that the compiler is invoked from. */ +static inline const char* simplify_file_path(const char *file) { + const char prefix[] = "vendor/cigraph/src/"; + const size_t prefix_len = sizeof(prefix) / sizeof(prefix[0]); if (strncmp(file, prefix, prefix_len) == 0) { return file + prefix_len; From 63986e8021b960664fbdcd45763e4ef578a17b92 Mon Sep 17 00:00:00 2001 From: maelle Date: Tue, 13 Jan 2026 08:56:08 +0000 Subject: [PATCH 03/10] chore: Auto-update from GitHub Actions Run: https://github.com/igraph/rigraph/actions/runs/20950334632 --- tests/testthat/_snaps/aaa-auto.md | 120 ++++++++++++++-------------- tests/testthat/_snaps/centrality.md | 2 +- tests/testthat/_snaps/games.md | 4 +- 3 files changed, 63 insertions(+), 63 deletions(-) diff --git a/tests/testthat/_snaps/aaa-auto.md b/tests/testthat/_snaps/aaa-auto.md index 7cf09c9412d..01a5f15a6d7 100644 --- a/tests/testthat/_snaps/aaa-auto.md +++ b/tests/testthat/_snaps/aaa-auto.md @@ -21,7 +21,7 @@ Condition Error in `empty_impl()`: ! Number of vertices must not be negative. Invalid value - Source: graph/type_indexededgelist.c:xx + Source: vendor/cigraph/src/graph/type_indexededgelist.c:xx # add_edges_impl basic @@ -157,7 +157,7 @@ Condition Error in `wheel_impl()`: ! Invalid number of vertices. Invalid vertex ID - Source: constructors/regular.c:xx + Source: vendor/cigraph/src/constructors/regular.c:xx # hypercube_impl basic @@ -184,7 +184,7 @@ Condition Error in `hypercube_impl()`: ! The requested hypercube graph dimension (10000) is too high. It must be no greater than 57. Invalid value - Source: constructors/regular.c:xx + Source: vendor/cigraph/src/constructors/regular.c:xx # square_lattice_impl basic @@ -212,7 +212,7 @@ Condition Error in `square_lattice_impl()`: ! Invalid dimension vector. Invalid value - Source: constructors/regular.c:xx + Source: vendor/cigraph/src/constructors/regular.c:xx # triangular_lattice_impl basic @@ -239,7 +239,7 @@ Condition Error in `triangular_lattice_impl()`: ! Invalid dimension vector. Invalid value - Source: constructors/lattices.c:xx + Source: vendor/cigraph/src/constructors/lattices.c:xx # path_graph_impl basic @@ -266,7 +266,7 @@ Condition Error in `path_graph_impl()`: ! The number of vertices must be non-negative, got -1. Invalid value - Source: constructors/regular.c:xx + Source: vendor/cigraph/src/constructors/regular.c:xx # cycle_graph_impl basic @@ -293,7 +293,7 @@ Condition Error in `cycle_graph_impl()`: ! The number of vertices must be non-negative, got -1. Invalid value - Source: constructors/regular.c:xx + Source: vendor/cigraph/src/constructors/regular.c:xx # symmetric_tree_impl basic @@ -320,7 +320,7 @@ Condition Error in `symmetric_tree_impl()`: ! The number of branches must be positive at each level. Invalid value - Source: constructors/regular.c:xx + Source: vendor/cigraph/src/constructors/regular.c:xx # regular_tree_impl basic @@ -348,7 +348,7 @@ Condition Error in `regular_tree_impl()`: ! Height of regular tree must be positive, got -1. Invalid value - Source: constructors/regular.c:xx + Source: vendor/cigraph/src/constructors/regular.c:xx # full_citation_impl basic @@ -375,7 +375,7 @@ Condition Error in `full_citation_impl()`: ! Invalid number of vertices. Invalid value - Source: constructors/full.c:xx + Source: vendor/cigraph/src/constructors/full.c:xx # atlas_impl basic @@ -401,7 +401,7 @@ Condition Error in `atlas_impl()`: ! No such graph in atlas. The graph index must be less than 1253. Invalid value - Source: constructors/atlas.c:xx + Source: vendor/cigraph/src/constructors/atlas.c:xx # extended_chordal_ring_impl basic @@ -428,7 +428,7 @@ Condition Error in `extended_chordal_ring_impl()`: ! An extended chordal ring has at least 3 nodes. Invalid value - Source: constructors/regular.c:xx + Source: vendor/cigraph/src/constructors/regular.c:xx # graph_power_impl basic @@ -490,7 +490,7 @@ Condition Error in `de_bruijn_impl()`: ! `m' and `n' should be non-negative in a de Bruijn graph. Invalid value - Source: constructors/de_bruijn.c:xx + Source: vendor/cigraph/src/constructors/de_bruijn.c:xx # kautz_impl basic @@ -512,7 +512,7 @@ Condition Error in `kautz_impl()`: ! `m' and `n' should be non-negative in a Kautz graph. Invalid value - Source: constructors/kautz.c:xx + Source: vendor/cigraph/src/constructors/kautz.c:xx # lcf_vector_impl basic @@ -532,7 +532,7 @@ Condition Error in `lcf_vector_impl()`: ! Number of vertices must not be negative. Invalid value - Source: graph/type_indexededgelist.c:xx + Source: vendor/cigraph/src/graph/type_indexededgelist.c:xx # mycielski_graph_impl basic @@ -550,7 +550,7 @@ Condition Error in `mycielski_graph_impl()`: ! The Mycielski graph order must not be negative. Invalid value - Source: constructors/mycielskian.c:xx + Source: vendor/cigraph/src/constructors/mycielskian.c:xx # adjlist_impl basic @@ -568,7 +568,7 @@ Condition Error in `adjlist_impl()`: ! Invalid (negative or too large) vertex ID. Invalid vertex ID - Source: constructors/basic_constructors.c:xx + Source: vendor/cigraph/src/constructors/basic_constructors.c:xx # full_bipartite_impl basic @@ -605,7 +605,7 @@ Condition Error in `full_bipartite_impl()`: ! Invalid number of vertices for bipartite graph. Invalid value - Source: misc/bipartite.c:xx + Source: vendor/cigraph/src/misc/bipartite.c:xx # full_multipartite_impl basic @@ -662,7 +662,7 @@ Condition Error in `full_multipartite_impl()`: ! Number of vertices must not be negative in any partition. Invalid value - Source: constructors/full.c:xx + Source: vendor/cigraph/src/constructors/full.c:xx # realize_degree_sequence_impl basic @@ -694,7 +694,7 @@ Condition Error in `realize_degree_sequence_impl()`: ! The sum of degrees must be even for an undirected graph. Invalid value - Source: misc/degree_sequence.cpp:xx + Source: vendor/cigraph/src/misc/degree_sequence.cpp:xx # realize_bipartite_degree_sequence_impl basic @@ -726,7 +726,7 @@ Condition Error in `realize_bipartite_degree_sequence_impl()`: ! The given bidegree sequence cannot be realized as a bipartite simple graph. Invalid value - Source: misc/degree_sequence.cpp:xx + Source: vendor/cigraph/src/misc/degree_sequence.cpp:xx # circulant_impl basic @@ -755,7 +755,7 @@ Condition Error in `circulant_impl()`: ! Number of nodes = -1 must be non-negative. Invalid value - Source: constructors/circulant.c:xx + Source: vendor/cigraph/src/constructors/circulant.c:xx # generalized_petersen_impl basic @@ -774,7 +774,7 @@ Condition Error in `generalized_petersen_impl()`: ! n = -1 must be at least 3. Invalid value - Source: constructors/generalized_petersen.c:xx + Source: vendor/cigraph/src/constructors/generalized_petersen.c:xx # turan_impl basic @@ -806,7 +806,7 @@ Condition Error in `turan_impl()`: ! Number of vertices must not be negative, got -1. Invalid value - Source: constructors/full.c:xx + Source: vendor/cigraph/src/constructors/full.c:xx # erdos_renyi_game_gnp_impl basic @@ -833,7 +833,7 @@ Condition Error in `erdos_renyi_game_gnp_impl()`: ! Invalid number of vertices. Invalid value - Source: games/erdos_renyi.c:xx + Source: vendor/cigraph/src/games/erdos_renyi.c:xx # erdos_renyi_game_gnm_impl basic @@ -860,7 +860,7 @@ Condition Error in `erdos_renyi_game_gnm_impl()`: ! Invalid number of vertices. Invalid value - Source: games/erdos_renyi.c:xx + Source: vendor/cigraph/src/games/erdos_renyi.c:xx # growing_random_game_impl basic @@ -889,7 +889,7 @@ Condition Error in `growing_random_game_impl()`: ! Invalid number of vertices. Invalid value - Source: games/growing_random.c:xx + Source: vendor/cigraph/src/games/growing_random.c:xx # preference_game_impl basic @@ -914,7 +914,7 @@ Condition Error in `preference_game_impl()`: ! The number of vertices must be non-negative. Invalid value - Source: games/preference.c:xx + Source: vendor/cigraph/src/games/preference.c:xx # asymmetric_preference_game_impl basic @@ -944,7 +944,7 @@ Condition Error in `asymmetric_preference_game_impl()`: ! The number of vertices must not be negative. Invalid value - Source: games/preference.c:xx + Source: vendor/cigraph/src/games/preference.c:xx # rewire_edges_impl basic @@ -1008,7 +1008,7 @@ Condition Error in `forest_fire_game_impl()`: ! Insufficient memory for forest fire model. Out of memory - Source: games/forestfire.c:xx + Source: vendor/cigraph/src/games/forestfire.c:xx # simple_interconnected_islands_game_impl basic @@ -1030,7 +1030,7 @@ Condition Error in `simple_interconnected_islands_game_impl()`: ! Number of islands cannot be negative, got -1. Invalid value - Source: games/islands.c:xx + Source: vendor/cigraph/src/games/islands.c:xx # chung_lu_game_impl basic @@ -1060,7 +1060,7 @@ Condition Error in `chung_lu_game_impl()`: ! Vertex weights must not be negative in Chung-Lu model, got -1. Invalid value - Source: games/chung_lu.c:xx + Source: vendor/cigraph/src/games/chung_lu.c:xx # static_fitness_game_impl basic @@ -1090,7 +1090,7 @@ Condition Error in `static_fitness_game_impl()`: ! Number of edges cannot be negative, got -1. Invalid value - Source: games/static_fitness.c:xx + Source: vendor/cigraph/src/games/static_fitness.c:xx # static_power_law_game_impl basic @@ -1122,7 +1122,7 @@ Condition Error in `static_power_law_game_impl()`: ! Number of nodes cannot be negative, got -1. Invalid value - Source: games/static_fitness.c:xx + Source: vendor/cigraph/src/games/static_fitness.c:xx # k_regular_game_impl basic @@ -1151,7 +1151,7 @@ Condition Error in `k_regular_game_impl()`: ! Number of nodes must be non-negative. Invalid value - Source: games/k_regular.c:xx + Source: vendor/cigraph/src/games/k_regular.c:xx # sbm_game_impl basic @@ -1181,7 +1181,7 @@ Condition Error in `sbm_game_impl()`: ! Sum of the block sizes (5) must equal the number of vertices (-1). Invalid value - Source: games/sbm.c:xx + Source: vendor/cigraph/src/games/sbm.c:xx # hsbm_game_impl basic @@ -1200,7 +1200,7 @@ Condition Error in `hsbm_game_impl()`: ! `n' must be positive for HSBM. Invalid value - Source: games/sbm.c:xx + Source: vendor/cigraph/src/games/sbm.c:xx # hsbm_list_game_impl basic @@ -1229,7 +1229,7 @@ Condition Error in `hsbm_list_game_impl()`: ! `n' must be positive for HSBM. Invalid value - Source: games/sbm.c:xx + Source: vendor/cigraph/src/games/sbm.c:xx # correlated_game_impl basic @@ -1288,7 +1288,7 @@ Condition Error in `correlated_pair_game_impl()`: ! Invalid number of vertices. Invalid value - Source: games/erdos_renyi.c:xx + Source: vendor/cigraph/src/games/erdos_renyi.c:xx # dot_product_game_impl basic @@ -1297,7 +1297,7 @@ Condition Warning in `dot_product_game_impl()`: Greater than 1 connection probability in dot-product graph. - Source: games/dotproduct.c:90 + Source: vendor/cigraph/src/games/dotproduct.c:90 Output IGRAPH U--- 2 1 -- + edge: @@ -1310,7 +1310,7 @@ Condition Warning in `dot_product_game_impl()`: Greater than 1 connection probability in dot-product graph. - Source: games/dotproduct.c:90 + Source: vendor/cigraph/src/games/dotproduct.c:90 Output IGRAPH D--- 2 2 -- + edges: @@ -1351,7 +1351,7 @@ Condition Error in `sample_sphere_surface_impl()`: ! Sphere must be at least two dimensional to sample from surface. Invalid value - Source: games/dotproduct.c:xx + Source: vendor/cigraph/src/games/dotproduct.c:xx # sample_sphere_volume_impl basic @@ -1380,7 +1380,7 @@ Condition Error in `sample_sphere_volume_impl()`: ! Sphere must be at least two dimensional to sample from surface. Invalid value - Source: games/dotproduct.c:xx + Source: vendor/cigraph/src/games/dotproduct.c:xx # sample_dirichlet_impl basic @@ -1399,7 +1399,7 @@ Condition Error in `sample_dirichlet_impl()`: ! Number of samples should be non-negative, got -1. Invalid value - Source: games/dotproduct.c:xx + Source: vendor/cigraph/src/games/dotproduct.c:xx # are_adjacent_impl basic @@ -2219,7 +2219,7 @@ Condition Warning in `transitivity_barrat_impl()`: No weights given for Barrat's transitivity, unweighted version is used. - Source: properties/triangles.c:913 + Source: vendor/cigraph/src/properties/triangles.c:913 Output [1] NaN 0 NaN @@ -2230,7 +2230,7 @@ Condition Warning in `transitivity_barrat_impl()`: No weights given for Barrat's transitivity, unweighted version is used. - Source: properties/triangles.c:913 + Source: vendor/cigraph/src/properties/triangles.c:913 Output [1] 0 0 0 @@ -3139,7 +3139,7 @@ Condition Error in `centralization_degree_tmax_impl()`: ! Number of vertices must not be negative. Invalid value - Source: centrality/centralization.c:xx + Source: vendor/cigraph/src/centrality/centralization.c:xx # centralization_betweenness_impl basic @@ -3200,7 +3200,7 @@ Condition Error in `centralization_betweenness_tmax_impl()`: ! Number of vertices must not be negative. Invalid value - Source: centrality/centralization.c:xx + Source: vendor/cigraph/src/centrality/centralization.c:xx # centralization_closeness_impl basic @@ -3261,7 +3261,7 @@ Condition Error in `centralization_closeness_tmax_impl()`: ! Number of vertices must not be negative. Invalid value - Source: centrality/centralization.c:xx + Source: vendor/cigraph/src/centrality/centralization.c:xx # centralization_eigenvector_centrality_impl basic @@ -3453,7 +3453,7 @@ Condition Error in `centralization_eigenvector_centrality_tmax_impl()`: ! Number of vertices must not be negative. Invalid value - Source: centrality/centralization.c:xx + Source: vendor/cigraph/src/centrality/centralization.c:xx # assortativity_nominal_impl basic @@ -4143,7 +4143,7 @@ Condition Error in `bipartite_game_gnp_impl()`: ! Invalid number of vertices for bipartite graph. Invalid value - Source: misc/bipartite.c:xx + Source: vendor/cigraph/src/misc/bipartite.c:xx # bipartite_game_gnm_impl basic @@ -4180,7 +4180,7 @@ Condition Error in `bipartite_game_gnm_impl()`: ! Invalid number of vertices for bipartite graph. Invalid value - Source: misc/bipartite.c:xx + Source: vendor/cigraph/src/misc/bipartite.c:xx # get_laplacian_impl basic @@ -5821,7 +5821,7 @@ Condition Error in `hrg_create_impl()`: ! HRG probability vector size (1) should be equal to the number of internal nodes (2). Invalid value - Source: hrg/hrg.cc:xx + Source: vendor/cigraph/src/hrg/hrg.cc:xx # hrg_resize_impl basic @@ -6147,7 +6147,7 @@ Condition Error in `motifs_randesu_no_impl()`: ! Cut probability vector size (1) must agree with motif size (3). Invalid value - Source: misc/motifs.c:xx + Source: vendor/cigraph/src/misc/motifs.c:xx # dyad_census_impl basic @@ -6179,7 +6179,7 @@ Condition Warning in `triad_census_impl()`: Triad census called on an undirected graph. All connections will be treated as mutual. - Source: misc/motifs.c:1157 + Source: vendor/cigraph/src/misc/motifs.c:1157 Output [1] 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 @@ -8050,7 +8050,7 @@ Condition Error in `eigen_adjacency_impl()`: ! 'LAPACK' algorithm not implemented yet. Unimplemented function call - Source: linalg/eigen.c:xx + Source: vendor/cigraph/src/linalg/eigen.c:xx # eigen_adjacency_impl errors @@ -8111,7 +8111,7 @@ NAs introduced by coercion Error in `power_law_fit_impl()`: ! xmin must be greater than zero. Invalid value - Source: misc/power_law_fit.c:xx + Source: vendor/cigraph/src/misc/power_law_fit.c:xx # sir_impl basic @@ -9603,7 +9603,7 @@ Condition Error in `dim_select_impl()`: ! Need at least one singular value for dimensionality selection. Invalid value - Source: misc/embedding.c:xx + Source: vendor/cigraph/src/misc/embedding.c:xx # solve_lsap_impl basic @@ -9736,7 +9736,7 @@ Condition Error in `eulerian_cycle_impl()`: ! The graph does not have an Eulerian cycle. Input problem has no solution - Source: paths/eulerian.c:xx + Source: vendor/cigraph/src/paths/eulerian.c:xx --- @@ -10381,7 +10381,7 @@ Condition Error in `famous_impl()`: ! NonexistentGraph is not a known graph. See the documentation for valid graph names. Invalid value - Source: constructors/famous.c:xx + Source: vendor/cigraph/src/constructors/famous.c:xx # constraint_impl errors diff --git a/tests/testthat/_snaps/centrality.md b/tests/testthat/_snaps/centrality.md index a676e0e14ef..09d3e0b7bd9 100644 --- a/tests/testthat/_snaps/centrality.md +++ b/tests/testthat/_snaps/centrality.md @@ -49,7 +49,7 @@ Condition Error in `arpack()`: ! ARPACK error. N must be positive - Source: linalg/arpack.c: + Source: vendor/cigraph/src/linalg/arpack.c: --- diff --git a/tests/testthat/_snaps/games.md b/tests/testthat/_snaps/games.md index 15522aa0df9..b60b1f3e863 100644 --- a/tests/testthat/_snaps/games.md +++ b/tests/testthat/_snaps/games.md @@ -5,7 +5,7 @@ Condition Error in `sample_degseq()`: ! Cannot make a connected graph from the given degree sequence. Invalid value - Source: games/degree_sequence_vl/gengraph_mr-connected.cpp: + Source: vendor/cigraph/src/games/degree_sequence_vl/gengraph_mr-connected.cpp: # sample_degseq() works -- Power-law degree error @@ -14,5 +14,5 @@ Condition Error in `sample_degseq()`: ! Cannot realize the given degree sequence as an undirected, simple graph. Invalid value - Source: games/degree_sequence_vl/gengraph_mr-connected.cpp: + Source: vendor/cigraph/src/games/degree_sequence_vl/gengraph_mr-connected.cpp: From 73b4119a8d21f2b4124715eac3b77289055acced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Tue, 13 Jan 2026 10:21:39 +0100 Subject: [PATCH 04/10] fix @szhorvat --- src/rinterface_extra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 379ea83d61b..9e8c68c9332 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -2319,7 +2319,7 @@ static inline const char* maybe_add_punctuation(const char* msg, const char* pun * build procedure, namely on the directory that the compiler is invoked from. */ static inline const char* simplify_file_path(const char *file) { const char prefix[] = "vendor/cigraph/src/"; - const size_t prefix_len = sizeof(prefix) / sizeof(prefix[0]); + const size_t prefix_len = sizeof(prefix) - 1; if (strncmp(file, prefix, prefix_len) == 0) { return file + prefix_len; From d273bfe3f5788941905269887b605a8301beb99d Mon Sep 17 00:00:00 2001 From: maelle Date: Tue, 13 Jan 2026 11:01:38 +0000 Subject: [PATCH 05/10] chore: Auto-update from GitHub Actions Run: https://github.com/igraph/rigraph/actions/runs/20954085215 --- tests/testthat/_snaps/aaa-auto.md | 120 ++++++++++++++-------------- tests/testthat/_snaps/centrality.md | 2 +- tests/testthat/_snaps/games.md | 4 +- 3 files changed, 63 insertions(+), 63 deletions(-) diff --git a/tests/testthat/_snaps/aaa-auto.md b/tests/testthat/_snaps/aaa-auto.md index 01a5f15a6d7..7cf09c9412d 100644 --- a/tests/testthat/_snaps/aaa-auto.md +++ b/tests/testthat/_snaps/aaa-auto.md @@ -21,7 +21,7 @@ Condition Error in `empty_impl()`: ! Number of vertices must not be negative. Invalid value - Source: vendor/cigraph/src/graph/type_indexededgelist.c:xx + Source: graph/type_indexededgelist.c:xx # add_edges_impl basic @@ -157,7 +157,7 @@ Condition Error in `wheel_impl()`: ! Invalid number of vertices. Invalid vertex ID - Source: vendor/cigraph/src/constructors/regular.c:xx + Source: constructors/regular.c:xx # hypercube_impl basic @@ -184,7 +184,7 @@ Condition Error in `hypercube_impl()`: ! The requested hypercube graph dimension (10000) is too high. It must be no greater than 57. Invalid value - Source: vendor/cigraph/src/constructors/regular.c:xx + Source: constructors/regular.c:xx # square_lattice_impl basic @@ -212,7 +212,7 @@ Condition Error in `square_lattice_impl()`: ! Invalid dimension vector. Invalid value - Source: vendor/cigraph/src/constructors/regular.c:xx + Source: constructors/regular.c:xx # triangular_lattice_impl basic @@ -239,7 +239,7 @@ Condition Error in `triangular_lattice_impl()`: ! Invalid dimension vector. Invalid value - Source: vendor/cigraph/src/constructors/lattices.c:xx + Source: constructors/lattices.c:xx # path_graph_impl basic @@ -266,7 +266,7 @@ Condition Error in `path_graph_impl()`: ! The number of vertices must be non-negative, got -1. Invalid value - Source: vendor/cigraph/src/constructors/regular.c:xx + Source: constructors/regular.c:xx # cycle_graph_impl basic @@ -293,7 +293,7 @@ Condition Error in `cycle_graph_impl()`: ! The number of vertices must be non-negative, got -1. Invalid value - Source: vendor/cigraph/src/constructors/regular.c:xx + Source: constructors/regular.c:xx # symmetric_tree_impl basic @@ -320,7 +320,7 @@ Condition Error in `symmetric_tree_impl()`: ! The number of branches must be positive at each level. Invalid value - Source: vendor/cigraph/src/constructors/regular.c:xx + Source: constructors/regular.c:xx # regular_tree_impl basic @@ -348,7 +348,7 @@ Condition Error in `regular_tree_impl()`: ! Height of regular tree must be positive, got -1. Invalid value - Source: vendor/cigraph/src/constructors/regular.c:xx + Source: constructors/regular.c:xx # full_citation_impl basic @@ -375,7 +375,7 @@ Condition Error in `full_citation_impl()`: ! Invalid number of vertices. Invalid value - Source: vendor/cigraph/src/constructors/full.c:xx + Source: constructors/full.c:xx # atlas_impl basic @@ -401,7 +401,7 @@ Condition Error in `atlas_impl()`: ! No such graph in atlas. The graph index must be less than 1253. Invalid value - Source: vendor/cigraph/src/constructors/atlas.c:xx + Source: constructors/atlas.c:xx # extended_chordal_ring_impl basic @@ -428,7 +428,7 @@ Condition Error in `extended_chordal_ring_impl()`: ! An extended chordal ring has at least 3 nodes. Invalid value - Source: vendor/cigraph/src/constructors/regular.c:xx + Source: constructors/regular.c:xx # graph_power_impl basic @@ -490,7 +490,7 @@ Condition Error in `de_bruijn_impl()`: ! `m' and `n' should be non-negative in a de Bruijn graph. Invalid value - Source: vendor/cigraph/src/constructors/de_bruijn.c:xx + Source: constructors/de_bruijn.c:xx # kautz_impl basic @@ -512,7 +512,7 @@ Condition Error in `kautz_impl()`: ! `m' and `n' should be non-negative in a Kautz graph. Invalid value - Source: vendor/cigraph/src/constructors/kautz.c:xx + Source: constructors/kautz.c:xx # lcf_vector_impl basic @@ -532,7 +532,7 @@ Condition Error in `lcf_vector_impl()`: ! Number of vertices must not be negative. Invalid value - Source: vendor/cigraph/src/graph/type_indexededgelist.c:xx + Source: graph/type_indexededgelist.c:xx # mycielski_graph_impl basic @@ -550,7 +550,7 @@ Condition Error in `mycielski_graph_impl()`: ! The Mycielski graph order must not be negative. Invalid value - Source: vendor/cigraph/src/constructors/mycielskian.c:xx + Source: constructors/mycielskian.c:xx # adjlist_impl basic @@ -568,7 +568,7 @@ Condition Error in `adjlist_impl()`: ! Invalid (negative or too large) vertex ID. Invalid vertex ID - Source: vendor/cigraph/src/constructors/basic_constructors.c:xx + Source: constructors/basic_constructors.c:xx # full_bipartite_impl basic @@ -605,7 +605,7 @@ Condition Error in `full_bipartite_impl()`: ! Invalid number of vertices for bipartite graph. Invalid value - Source: vendor/cigraph/src/misc/bipartite.c:xx + Source: misc/bipartite.c:xx # full_multipartite_impl basic @@ -662,7 +662,7 @@ Condition Error in `full_multipartite_impl()`: ! Number of vertices must not be negative in any partition. Invalid value - Source: vendor/cigraph/src/constructors/full.c:xx + Source: constructors/full.c:xx # realize_degree_sequence_impl basic @@ -694,7 +694,7 @@ Condition Error in `realize_degree_sequence_impl()`: ! The sum of degrees must be even for an undirected graph. Invalid value - Source: vendor/cigraph/src/misc/degree_sequence.cpp:xx + Source: misc/degree_sequence.cpp:xx # realize_bipartite_degree_sequence_impl basic @@ -726,7 +726,7 @@ Condition Error in `realize_bipartite_degree_sequence_impl()`: ! The given bidegree sequence cannot be realized as a bipartite simple graph. Invalid value - Source: vendor/cigraph/src/misc/degree_sequence.cpp:xx + Source: misc/degree_sequence.cpp:xx # circulant_impl basic @@ -755,7 +755,7 @@ Condition Error in `circulant_impl()`: ! Number of nodes = -1 must be non-negative. Invalid value - Source: vendor/cigraph/src/constructors/circulant.c:xx + Source: constructors/circulant.c:xx # generalized_petersen_impl basic @@ -774,7 +774,7 @@ Condition Error in `generalized_petersen_impl()`: ! n = -1 must be at least 3. Invalid value - Source: vendor/cigraph/src/constructors/generalized_petersen.c:xx + Source: constructors/generalized_petersen.c:xx # turan_impl basic @@ -806,7 +806,7 @@ Condition Error in `turan_impl()`: ! Number of vertices must not be negative, got -1. Invalid value - Source: vendor/cigraph/src/constructors/full.c:xx + Source: constructors/full.c:xx # erdos_renyi_game_gnp_impl basic @@ -833,7 +833,7 @@ Condition Error in `erdos_renyi_game_gnp_impl()`: ! Invalid number of vertices. Invalid value - Source: vendor/cigraph/src/games/erdos_renyi.c:xx + Source: games/erdos_renyi.c:xx # erdos_renyi_game_gnm_impl basic @@ -860,7 +860,7 @@ Condition Error in `erdos_renyi_game_gnm_impl()`: ! Invalid number of vertices. Invalid value - Source: vendor/cigraph/src/games/erdos_renyi.c:xx + Source: games/erdos_renyi.c:xx # growing_random_game_impl basic @@ -889,7 +889,7 @@ Condition Error in `growing_random_game_impl()`: ! Invalid number of vertices. Invalid value - Source: vendor/cigraph/src/games/growing_random.c:xx + Source: games/growing_random.c:xx # preference_game_impl basic @@ -914,7 +914,7 @@ Condition Error in `preference_game_impl()`: ! The number of vertices must be non-negative. Invalid value - Source: vendor/cigraph/src/games/preference.c:xx + Source: games/preference.c:xx # asymmetric_preference_game_impl basic @@ -944,7 +944,7 @@ Condition Error in `asymmetric_preference_game_impl()`: ! The number of vertices must not be negative. Invalid value - Source: vendor/cigraph/src/games/preference.c:xx + Source: games/preference.c:xx # rewire_edges_impl basic @@ -1008,7 +1008,7 @@ Condition Error in `forest_fire_game_impl()`: ! Insufficient memory for forest fire model. Out of memory - Source: vendor/cigraph/src/games/forestfire.c:xx + Source: games/forestfire.c:xx # simple_interconnected_islands_game_impl basic @@ -1030,7 +1030,7 @@ Condition Error in `simple_interconnected_islands_game_impl()`: ! Number of islands cannot be negative, got -1. Invalid value - Source: vendor/cigraph/src/games/islands.c:xx + Source: games/islands.c:xx # chung_lu_game_impl basic @@ -1060,7 +1060,7 @@ Condition Error in `chung_lu_game_impl()`: ! Vertex weights must not be negative in Chung-Lu model, got -1. Invalid value - Source: vendor/cigraph/src/games/chung_lu.c:xx + Source: games/chung_lu.c:xx # static_fitness_game_impl basic @@ -1090,7 +1090,7 @@ Condition Error in `static_fitness_game_impl()`: ! Number of edges cannot be negative, got -1. Invalid value - Source: vendor/cigraph/src/games/static_fitness.c:xx + Source: games/static_fitness.c:xx # static_power_law_game_impl basic @@ -1122,7 +1122,7 @@ Condition Error in `static_power_law_game_impl()`: ! Number of nodes cannot be negative, got -1. Invalid value - Source: vendor/cigraph/src/games/static_fitness.c:xx + Source: games/static_fitness.c:xx # k_regular_game_impl basic @@ -1151,7 +1151,7 @@ Condition Error in `k_regular_game_impl()`: ! Number of nodes must be non-negative. Invalid value - Source: vendor/cigraph/src/games/k_regular.c:xx + Source: games/k_regular.c:xx # sbm_game_impl basic @@ -1181,7 +1181,7 @@ Condition Error in `sbm_game_impl()`: ! Sum of the block sizes (5) must equal the number of vertices (-1). Invalid value - Source: vendor/cigraph/src/games/sbm.c:xx + Source: games/sbm.c:xx # hsbm_game_impl basic @@ -1200,7 +1200,7 @@ Condition Error in `hsbm_game_impl()`: ! `n' must be positive for HSBM. Invalid value - Source: vendor/cigraph/src/games/sbm.c:xx + Source: games/sbm.c:xx # hsbm_list_game_impl basic @@ -1229,7 +1229,7 @@ Condition Error in `hsbm_list_game_impl()`: ! `n' must be positive for HSBM. Invalid value - Source: vendor/cigraph/src/games/sbm.c:xx + Source: games/sbm.c:xx # correlated_game_impl basic @@ -1288,7 +1288,7 @@ Condition Error in `correlated_pair_game_impl()`: ! Invalid number of vertices. Invalid value - Source: vendor/cigraph/src/games/erdos_renyi.c:xx + Source: games/erdos_renyi.c:xx # dot_product_game_impl basic @@ -1297,7 +1297,7 @@ Condition Warning in `dot_product_game_impl()`: Greater than 1 connection probability in dot-product graph. - Source: vendor/cigraph/src/games/dotproduct.c:90 + Source: games/dotproduct.c:90 Output IGRAPH U--- 2 1 -- + edge: @@ -1310,7 +1310,7 @@ Condition Warning in `dot_product_game_impl()`: Greater than 1 connection probability in dot-product graph. - Source: vendor/cigraph/src/games/dotproduct.c:90 + Source: games/dotproduct.c:90 Output IGRAPH D--- 2 2 -- + edges: @@ -1351,7 +1351,7 @@ Condition Error in `sample_sphere_surface_impl()`: ! Sphere must be at least two dimensional to sample from surface. Invalid value - Source: vendor/cigraph/src/games/dotproduct.c:xx + Source: games/dotproduct.c:xx # sample_sphere_volume_impl basic @@ -1380,7 +1380,7 @@ Condition Error in `sample_sphere_volume_impl()`: ! Sphere must be at least two dimensional to sample from surface. Invalid value - Source: vendor/cigraph/src/games/dotproduct.c:xx + Source: games/dotproduct.c:xx # sample_dirichlet_impl basic @@ -1399,7 +1399,7 @@ Condition Error in `sample_dirichlet_impl()`: ! Number of samples should be non-negative, got -1. Invalid value - Source: vendor/cigraph/src/games/dotproduct.c:xx + Source: games/dotproduct.c:xx # are_adjacent_impl basic @@ -2219,7 +2219,7 @@ Condition Warning in `transitivity_barrat_impl()`: No weights given for Barrat's transitivity, unweighted version is used. - Source: vendor/cigraph/src/properties/triangles.c:913 + Source: properties/triangles.c:913 Output [1] NaN 0 NaN @@ -2230,7 +2230,7 @@ Condition Warning in `transitivity_barrat_impl()`: No weights given for Barrat's transitivity, unweighted version is used. - Source: vendor/cigraph/src/properties/triangles.c:913 + Source: properties/triangles.c:913 Output [1] 0 0 0 @@ -3139,7 +3139,7 @@ Condition Error in `centralization_degree_tmax_impl()`: ! Number of vertices must not be negative. Invalid value - Source: vendor/cigraph/src/centrality/centralization.c:xx + Source: centrality/centralization.c:xx # centralization_betweenness_impl basic @@ -3200,7 +3200,7 @@ Condition Error in `centralization_betweenness_tmax_impl()`: ! Number of vertices must not be negative. Invalid value - Source: vendor/cigraph/src/centrality/centralization.c:xx + Source: centrality/centralization.c:xx # centralization_closeness_impl basic @@ -3261,7 +3261,7 @@ Condition Error in `centralization_closeness_tmax_impl()`: ! Number of vertices must not be negative. Invalid value - Source: vendor/cigraph/src/centrality/centralization.c:xx + Source: centrality/centralization.c:xx # centralization_eigenvector_centrality_impl basic @@ -3453,7 +3453,7 @@ Condition Error in `centralization_eigenvector_centrality_tmax_impl()`: ! Number of vertices must not be negative. Invalid value - Source: vendor/cigraph/src/centrality/centralization.c:xx + Source: centrality/centralization.c:xx # assortativity_nominal_impl basic @@ -4143,7 +4143,7 @@ Condition Error in `bipartite_game_gnp_impl()`: ! Invalid number of vertices for bipartite graph. Invalid value - Source: vendor/cigraph/src/misc/bipartite.c:xx + Source: misc/bipartite.c:xx # bipartite_game_gnm_impl basic @@ -4180,7 +4180,7 @@ Condition Error in `bipartite_game_gnm_impl()`: ! Invalid number of vertices for bipartite graph. Invalid value - Source: vendor/cigraph/src/misc/bipartite.c:xx + Source: misc/bipartite.c:xx # get_laplacian_impl basic @@ -5821,7 +5821,7 @@ Condition Error in `hrg_create_impl()`: ! HRG probability vector size (1) should be equal to the number of internal nodes (2). Invalid value - Source: vendor/cigraph/src/hrg/hrg.cc:xx + Source: hrg/hrg.cc:xx # hrg_resize_impl basic @@ -6147,7 +6147,7 @@ Condition Error in `motifs_randesu_no_impl()`: ! Cut probability vector size (1) must agree with motif size (3). Invalid value - Source: vendor/cigraph/src/misc/motifs.c:xx + Source: misc/motifs.c:xx # dyad_census_impl basic @@ -6179,7 +6179,7 @@ Condition Warning in `triad_census_impl()`: Triad census called on an undirected graph. All connections will be treated as mutual. - Source: vendor/cigraph/src/misc/motifs.c:1157 + Source: misc/motifs.c:1157 Output [1] 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 @@ -8050,7 +8050,7 @@ Condition Error in `eigen_adjacency_impl()`: ! 'LAPACK' algorithm not implemented yet. Unimplemented function call - Source: vendor/cigraph/src/linalg/eigen.c:xx + Source: linalg/eigen.c:xx # eigen_adjacency_impl errors @@ -8111,7 +8111,7 @@ NAs introduced by coercion Error in `power_law_fit_impl()`: ! xmin must be greater than zero. Invalid value - Source: vendor/cigraph/src/misc/power_law_fit.c:xx + Source: misc/power_law_fit.c:xx # sir_impl basic @@ -9603,7 +9603,7 @@ Condition Error in `dim_select_impl()`: ! Need at least one singular value for dimensionality selection. Invalid value - Source: vendor/cigraph/src/misc/embedding.c:xx + Source: misc/embedding.c:xx # solve_lsap_impl basic @@ -9736,7 +9736,7 @@ Condition Error in `eulerian_cycle_impl()`: ! The graph does not have an Eulerian cycle. Input problem has no solution - Source: vendor/cigraph/src/paths/eulerian.c:xx + Source: paths/eulerian.c:xx --- @@ -10381,7 +10381,7 @@ Condition Error in `famous_impl()`: ! NonexistentGraph is not a known graph. See the documentation for valid graph names. Invalid value - Source: vendor/cigraph/src/constructors/famous.c:xx + Source: constructors/famous.c:xx # constraint_impl errors diff --git a/tests/testthat/_snaps/centrality.md b/tests/testthat/_snaps/centrality.md index 09d3e0b7bd9..a676e0e14ef 100644 --- a/tests/testthat/_snaps/centrality.md +++ b/tests/testthat/_snaps/centrality.md @@ -49,7 +49,7 @@ Condition Error in `arpack()`: ! ARPACK error. N must be positive - Source: vendor/cigraph/src/linalg/arpack.c: + Source: linalg/arpack.c: --- diff --git a/tests/testthat/_snaps/games.md b/tests/testthat/_snaps/games.md index b60b1f3e863..15522aa0df9 100644 --- a/tests/testthat/_snaps/games.md +++ b/tests/testthat/_snaps/games.md @@ -5,7 +5,7 @@ Condition Error in `sample_degseq()`: ! Cannot make a connected graph from the given degree sequence. Invalid value - Source: vendor/cigraph/src/games/degree_sequence_vl/gengraph_mr-connected.cpp: + Source: games/degree_sequence_vl/gengraph_mr-connected.cpp: # sample_degseq() works -- Power-law degree error @@ -14,5 +14,5 @@ Condition Error in `sample_degseq()`: ! Cannot realize the given degree sequence as an undirected, simple graph. Invalid value - Source: vendor/cigraph/src/games/degree_sequence_vl/gengraph_mr-connected.cpp: + Source: games/degree_sequence_vl/gengraph_mr-connected.cpp: From 4068aee06b0dfe4526a4d4a40ed52b6df0989698 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 Jan 2026 10:37:40 +0100 Subject: [PATCH 06/10] Address review feedback: use helper for error snapshots and add test function (#2522) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com> Co-authored-by: Kirill Müller --- R/utils.R | 20 ++++++++++++++++++++ src/cpp11.cpp | 2 ++ src/rinterface_extra.c | 7 +++++++ tests/testthat/_snaps/centrality.md | 2 +- tests/testthat/_snaps/error-formatting.md | 9 +++++++++ tests/testthat/test-centrality.R | 10 +++------- tests/testthat/test-error-formatting.R | 8 ++++++++ 7 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 tests/testthat/_snaps/error-formatting.md create mode 100644 tests/testthat/test-error-formatting.R diff --git a/R/utils.R b/R/utils.R index b9c51b8bbbc..d172590cc0d 100644 --- a/R/utils.R +++ b/R/utils.R @@ -94,3 +94,23 @@ modify_list <- function(x, y) { utils::modifyList(x, y) } + +#' Test function to verify error formatting with file and line information +#' +#' @description +#' This is a test function that throws an error from C code with file and line +#' information. +#' The error message should include the source file and line number where the +#' error occurred. +#' +#' @return This function never returns; it always throws an error. +#' @keywords internal +#' @noRd +#' @examples +#' \dontrun{ +#' # This will throw an error with source location information +#' test_error_with_source() +#' } +test_error_with_source <- function() { + .Call(Rx_igraph_test_error_with_source) +} diff --git a/src/cpp11.cpp b/src/cpp11.cpp index 60908db7edb..31b32abbe32 100644 --- a/src/cpp11.cpp +++ b/src/cpp11.cpp @@ -492,6 +492,7 @@ extern SEXP Rx_igraph_st_vertex_connectivity(SEXP, SEXP, SEXP); extern SEXP Rx_igraph_star(SEXP, SEXP, SEXP); extern SEXP Rx_igraph_subcomponent(SEXP, SEXP, SEXP); extern SEXP Rx_igraph_subisomorphic_lad(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_test_error_with_source(void); extern SEXP Rx_igraph_transitivity_local_undirected_all(SEXP, SEXP); extern SEXP Rx_igraph_union(SEXP, SEXP); extern SEXP Rx_igraph_vcount(SEXP); @@ -980,6 +981,7 @@ static const R_CallMethodDef CallEntries[] = { {"Rx_igraph_star", (DL_FUNC) &Rx_igraph_star, 3}, {"Rx_igraph_subcomponent", (DL_FUNC) &Rx_igraph_subcomponent, 3}, {"Rx_igraph_subisomorphic_lad", (DL_FUNC) &Rx_igraph_subisomorphic_lad, 7}, + {"Rx_igraph_test_error_with_source", (DL_FUNC) &Rx_igraph_test_error_with_source, 0}, {"Rx_igraph_transitivity_local_undirected_all", (DL_FUNC) &Rx_igraph_transitivity_local_undirected_all, 2}, {"Rx_igraph_union", (DL_FUNC) &Rx_igraph_union, 2}, {"Rx_igraph_vcount", (DL_FUNC) &Rx_igraph_vcount, 1}, diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 9e8c68c9332..d88ba20810e 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -7760,6 +7760,13 @@ SEXP Rx_igraph_create_bipartite(SEXP types, SEXP edges, SEXP directed) { return R_igraph_create_bipartite(types, edges, directed); } +/* Test function to verify error formatting with file and line information */ +attribute_visible SEXP Rx_igraph_test_error_with_source(void) { + igraph_errorf("Test error message for verifying source location formatting", + __FILE__, __LINE__, IGRAPH_EINVAL); + return R_NilValue; +} + SEXP Rx_igraph_finalizer(void) { return R_igraph_finalizer(); } diff --git a/tests/testthat/_snaps/centrality.md b/tests/testthat/_snaps/centrality.md index a676e0e14ef..7a8ebc83914 100644 --- a/tests/testthat/_snaps/centrality.md +++ b/tests/testthat/_snaps/centrality.md @@ -49,7 +49,7 @@ Condition Error in `arpack()`: ! ARPACK error. N must be positive - Source: linalg/arpack.c: + Source: linalg/arpack.c:xx --- diff --git a/tests/testthat/_snaps/error-formatting.md b/tests/testthat/_snaps/error-formatting.md new file mode 100644 index 00000000000..eb6013ebd61 --- /dev/null +++ b/tests/testthat/_snaps/error-formatting.md @@ -0,0 +1,9 @@ +# error messages include source file and line information + + Code + test_error_with_source() + Condition + Error in `test_error_with_source()`: + ! Test error message for verifying source location formatting. Invalid value + Source: rinterface_extra.c: + diff --git a/tests/testthat/test-centrality.R b/tests/testthat/test-centrality.R index 2f983e74f8c..65e0a407c0c 100644 --- a/tests/testthat/test-centrality.R +++ b/tests/testthat/test-centrality.R @@ -845,13 +845,9 @@ test_that("eigen_centrality() deprecated scale argument", { test_that("arpack() errors well", { f <- function(x, extra = NULL) x - expect_snapshot( - error = TRUE, - { - arpack(f, options = list(nev = 2, ncv = 4), sym = TRUE) - }, - transform = function(x) sub("\\:[0-9]+", ":", x) - ) + expect_snapshot_igraph_error({ + arpack(f, options = list(nev = 2, ncv = 4), sym = TRUE) + }) expect_snapshot(error = TRUE, { arpack( f, diff --git a/tests/testthat/test-error-formatting.R b/tests/testthat/test-error-formatting.R new file mode 100644 index 00000000000..5e19acb2a66 --- /dev/null +++ b/tests/testthat/test-error-formatting.R @@ -0,0 +1,8 @@ +test_that("error messages include source file and line information", { + expect_snapshot( + error = TRUE, + { + test_error_with_source() + } + ) +}) From 9e4fb9ef1446e44a40ef37ad493e2a43c984af74 Mon Sep 17 00:00:00 2001 From: krlmlr Date: Sat, 24 Jan 2026 09:45:00 +0000 Subject: [PATCH 07/10] chore: Auto-update from GitHub Actions Run: https://github.com/igraph/rigraph/actions/runs/21313063875 --- tests/testthat/_snaps/aaa-auto.md | 3 ++- tests/testthat/_snaps/error-formatting.md | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/testthat/_snaps/aaa-auto.md b/tests/testthat/_snaps/aaa-auto.md index 8dcdd13adb0..ec6cb64b8e2 100644 --- a/tests/testthat/_snaps/aaa-auto.md +++ b/tests/testthat/_snaps/aaa-auto.md @@ -11197,7 +11197,8 @@ connect_neighborhood_impl(graph = g, order = 1, mode = c("all", "out", "in")) Condition Warning in `connect_neighborhood_impl()`: - At vendor/cigraph/src/operators/connect_neighborhood.c:85 : Order smaller than two, graph will be unchanged. + Order smaller than two, graph will be unchanged. + Source: operators/connect_neighborhood.c:85 Output IGRAPH U--- 5 5 -- Ring graph + attr: name (g/c), mutual (g/l), circular (g/l) diff --git a/tests/testthat/_snaps/error-formatting.md b/tests/testthat/_snaps/error-formatting.md index eb6013ebd61..fca0e7ab3a1 100644 --- a/tests/testthat/_snaps/error-formatting.md +++ b/tests/testthat/_snaps/error-formatting.md @@ -5,5 +5,5 @@ Condition Error in `test_error_with_source()`: ! Test error message for verifying source location formatting. Invalid value - Source: rinterface_extra.c: + Source: rinterface_extra.c:7766 From 5a93c984f77fa88d61c03c561eca58485a88b5cc Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 Jan 2026 11:23:57 +0100 Subject: [PATCH 08/10] refactor: standardize error snapshot testing with `expect_snapshot_igraph_error()` (#2528) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com> --- src/rinterface_extra.c | 7 ---- src/sources-glue-c.mk | 2 +- src/test_error_with_source.c | 33 +++++++++++++++++++ src/test_error_with_source.dd | 4 +++ tests/testthat/_snaps/error-formatting.md | 2 +- tests/testthat/test-adjacency.R | 2 +- tests/testthat/test-attributes.R | 18 +++++------ tests/testthat/test-centrality.R | 2 +- tests/testthat/test-conversion.R | 16 ++++----- tests/testthat/test-error-formatting.R | 4 +++ tests/testthat/test-fit.R | 2 +- tests/testthat/test-flow.R | 36 +++++++++------------ tests/testthat/test-foreign.R | 18 +++++------ tests/testthat/test-hrg.R | 4 +-- tests/testthat/test-incidence.R | 8 ++--- tests/testthat/test-interface.R | 6 ++-- tests/testthat/test-iterators.R | 4 +-- tests/testthat/test-layout.R | 6 ++-- tests/testthat/test-make.R | 11 +++---- tests/testthat/test-minimum.spanning.tree.R | 5 ++- tests/testthat/test-other.R | 7 ++-- tests/testthat/test-plot.R | 2 +- tests/testthat/test-structural-properties.R | 4 +-- tests/testthat/test-utils-assert-args.R | 5 ++- tests/testthat/test-versions.R | 18 +++++------ 25 files changed, 124 insertions(+), 102 deletions(-) create mode 100644 src/test_error_with_source.c create mode 100644 src/test_error_with_source.dd diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index d88ba20810e..9e8c68c9332 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -7760,13 +7760,6 @@ SEXP Rx_igraph_create_bipartite(SEXP types, SEXP edges, SEXP directed) { return R_igraph_create_bipartite(types, edges, directed); } -/* Test function to verify error formatting with file and line information */ -attribute_visible SEXP Rx_igraph_test_error_with_source(void) { - igraph_errorf("Test error message for verifying source location formatting", - __FILE__, __LINE__, IGRAPH_EINVAL); - return R_NilValue; -} - SEXP Rx_igraph_finalizer(void) { return R_igraph_finalizer(); } diff --git a/src/sources-glue-c.mk b/src/sources-glue-c.mk index a0ca36b78c0..3508954fced 100644 --- a/src/sources-glue-c.mk +++ b/src/sources-glue-c.mk @@ -1 +1 @@ -GLUE_C_SOURCES=rcallback.o rinterface.o rinterface_extra.o rrandom.o uuid.o +GLUE_C_SOURCES=rcallback.o rinterface.o rinterface_extra.o rrandom.o test_error_with_source.o uuid.o diff --git a/src/test_error_with_source.c b/src/test_error_with_source.c new file mode 100644 index 00000000000..3a66e48ba34 --- /dev/null +++ b/src/test_error_with_source.c @@ -0,0 +1,33 @@ +/* -*- mode: C -*- */ +/* + IGraph library R interface. + Copyright (C) 2013 Gabor Csardi + 334 Harvard street, Cambridge, MA 02139 USA + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA + +*/ + +#include "rinterface.h" + +#include + +/* Test function to verify error formatting with file and line information */ +attribute_visible SEXP Rx_igraph_test_error_with_source(void) { + igraph_errorf("Test error message for verifying source location formatting", + __FILE__, __LINE__, IGRAPH_EINVAL); + return R_NilValue; +} diff --git a/src/test_error_with_source.dd b/src/test_error_with_source.dd new file mode 100644 index 00000000000..3eea9c3527c --- /dev/null +++ b/src/test_error_with_source.dd @@ -0,0 +1,4 @@ +# Generated by deps.mk, do not edit by hand and do not add dependencies to system headers +test_error_with_source.o: \ + rinterface.h \ + test_error_with_source.c \ diff --git a/tests/testthat/_snaps/error-formatting.md b/tests/testthat/_snaps/error-formatting.md index fca0e7ab3a1..66512692f0e 100644 --- a/tests/testthat/_snaps/error-formatting.md +++ b/tests/testthat/_snaps/error-formatting.md @@ -5,5 +5,5 @@ Condition Error in `test_error_with_source()`: ! Test error message for verifying source location formatting. Invalid value - Source: rinterface_extra.c:7766 + Source: test_error_with_source.c:31 diff --git a/tests/testthat/test-adjacency.R b/tests/testthat/test-adjacency.R index b488ca4302d..cd8c838e468 100644 --- a/tests/testthat/test-adjacency.R +++ b/tests/testthat/test-adjacency.R @@ -787,7 +787,7 @@ test_that("sparse/dense matrices min/max/plus", { test_that("graph_from_adjacency_matrix errors for NAs", { A <- matrix(c(1, 1, NA, 1), 2, 2) - expect_snapshot(graph_from_adjacency_matrix(A), error = TRUE) + expect_snapshot_igraph_error(graph_from_adjacency_matrix(A)) }) test_that("graph_from_adjacency_matrix handles add.colnames and add.rownames = FALSE correctly", { diff --git a/tests/testthat/test-attributes.R b/tests/testthat/test-attributes.R index 71d70df15f8..bf54e2ae311 100644 --- a/tests/testthat/test-attributes.R +++ b/tests/testthat/test-attributes.R @@ -436,13 +436,13 @@ test_that("adding and removing attributes", { test_that("error messages work", { g <- make_full_graph(5) - expect_snapshot(set_vertex_attr(g, "test", value = c(1, 2)), error = TRUE) - expect_snapshot(set_edge_attr(g, "test", value = c(1, 2)), error = TRUE) - expect_snapshot(delete_graph_attr(g, "a"), error = TRUE) - expect_snapshot(delete_vertex_attr(g, "a"), error = TRUE) - expect_snapshot(delete_edge_attr(g, "a"), error = TRUE) - expect_snapshot(assert_named_list("a"), error = TRUE) - expect_snapshot(assert_named_list(list("a", "b")), error = TRUE) + expect_snapshot_igraph_error(set_vertex_attr(g, "test", value = c(1, 2))) + expect_snapshot_igraph_error(set_edge_attr(g, "test", value = c(1, 2))) + expect_snapshot_igraph_error(delete_graph_attr(g, "a")) + expect_snapshot_igraph_error(delete_vertex_attr(g, "a")) + expect_snapshot_igraph_error(delete_edge_attr(g, "a")) + expect_snapshot_igraph_error(assert_named_list("a")) + expect_snapshot_igraph_error(assert_named_list(list("a", "b"))) }) test_that("empty returns work", { @@ -465,7 +465,7 @@ test_that("assign data.frame attributes works", { test_that("good error message when not using character", { ring <- graph_from_literal(A - B - C - D - E - F - G - A) - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ set_graph_attr(ring, 1, 1) }) }) @@ -476,7 +476,7 @@ test_that("set_vertex_attrs() works", { expect_equal(V(g)$color, rep("blue", vcount(g))) expect_equal(V(g)$size, rep(10, vcount(g))) expect_equal(V(g)$name, LETTERS[1:10]) - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ set_vertex_attrs(g) }) diff --git a/tests/testthat/test-centrality.R b/tests/testthat/test-centrality.R index 65e0a407c0c..71bd753a7e6 100644 --- a/tests/testthat/test-centrality.R +++ b/tests/testthat/test-centrality.R @@ -848,7 +848,7 @@ test_that("arpack() errors well", { expect_snapshot_igraph_error({ arpack(f, options = list(nev = 2, ncv = 4), sym = TRUE) }) - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ arpack( f, options = list(unknown_thing1 = 2, unknown_thing2 = 4), diff --git a/tests/testthat/test-conversion.R b/tests/testthat/test-conversion.R index 5fddb5f12fb..65a2858fc67 100644 --- a/tests/testthat/test-conversion.R +++ b/tests/testthat/test-conversion.R @@ -142,10 +142,10 @@ test_that("as_adjacency_matrix() works -- sparse + not both", { test_that("as_adjacency_matrix() errors well -- sparse", { g <- make_graph(c(1, 2, 2, 1, 2, 2, 3, 3, 3, 3, 3, 4, 4, 2, 4, 2, 4, 2), directed = TRUE) - expect_snapshot(as_adjacency_matrix(g, attr = "bla"), error = TRUE) + expect_snapshot_igraph_error(as_adjacency_matrix(g, attr = "bla")) E(g)$bla <- letters[1:ecount(g)] - expect_snapshot(as_adjacency_matrix(g, attr = "bla"), error = TRUE) + expect_snapshot_igraph_error(as_adjacency_matrix(g, attr = "bla")) }) test_that("as_adjacency_matrix() works -- sparse undirected", { @@ -197,15 +197,13 @@ test_that("as_adjacency_matrix() works -- dense", { test_that("as_adjacency_matrix() errors well -- dense", { g <- make_graph(c(1, 2, 2, 1, 2, 2, 3, 3, 3, 3, 3, 4, 4, 2, 4, 2, 4, 2), directed = TRUE) - expect_snapshot( - as_adjacency_matrix(g, attr = "bla", sparse = FALSE), - error = TRUE + expect_snapshot_igraph_error( + as_adjacency_matrix(g, attr = "bla", sparse = FALSE) ) E(g)$bla <- letters[1:ecount(g)] - expect_snapshot( - as_adjacency_matrix(g, attr = "bla", sparse = FALSE), - error = TRUE + expect_snapshot_igraph_error( + as_adjacency_matrix(g, attr = "bla", sparse = FALSE) ) }) @@ -679,7 +677,7 @@ test_that("edge names work", { test_that("graph_from_edgelist errors for NAs", { A <- matrix(c(1, 2, NA, 1), 2, 2) - expect_snapshot(graph_from_edgelist(A), error = TRUE) + expect_snapshot_igraph_error(graph_from_edgelist(A)) }) test_that("graph_from_data_frame works with factors", { diff --git a/tests/testthat/test-error-formatting.R b/tests/testthat/test-error-formatting.R index 5e19acb2a66..a29e5d59c7e 100644 --- a/tests/testthat/test-error-formatting.R +++ b/tests/testthat/test-error-formatting.R @@ -1,4 +1,8 @@ test_that("error messages include source file and line information", { + # Note: We use expect_snapshot(error = TRUE) here instead of + # expect_snapshot_igraph_error() because we need to test the actual + # line numbers in the error message, which expect_snapshot_igraph_error() + # would transform to "xx". expect_snapshot( error = TRUE, { diff --git a/tests/testthat/test-fit.R b/tests/testthat/test-fit.R index 0b6019461e0..67cb5288880 100644 --- a/tests/testthat/test-fit.R +++ b/tests/testthat/test-fit.R @@ -28,7 +28,7 @@ test_that("fit_power_law() works", { }) test_that("fit_power_law() errors well", { - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ fit_power_law(1, implementation = "R.mle") }) }) diff --git a/tests/testthat/test-flow.R b/tests/testthat/test-flow.R index 3083a8bbf72..d9b9eec71d5 100644 --- a/tests/testthat/test-flow.R +++ b/tests/testthat/test-flow.R @@ -98,15 +98,13 @@ test_that("st_cuts() works", { test_that("st_cuts errors work", { g_path <- graph_from_literal(a -+ b -+ c -+ d -+ e) - expect_snapshot(st_cuts(g_path, source = "a", target = NULL), error = TRUE) - expect_snapshot(st_cuts(g_path, source = NULL, target = "a"), error = TRUE) - expect_snapshot( - st_min_cuts(g_path, source = "a", target = NULL), - error = TRUE + expect_snapshot_igraph_error(st_cuts(g_path, source = "a", target = NULL)) + expect_snapshot_igraph_error(st_cuts(g_path, source = NULL, target = "a")) + expect_snapshot_igraph_error( + st_min_cuts(g_path, source = "a", target = NULL) ) - expect_snapshot( - st_min_cuts(g_path, source = NULL, target = "a"), - error = TRUE + expect_snapshot_igraph_error( + st_min_cuts(g_path, source = NULL, target = "a") ) }) @@ -142,7 +140,7 @@ test_that("vertex_connectivity() works", { test_that("vertex_connectivity error works", { g_path <- make_ring(5, circular = FALSE) - expect_snapshot(vertex_connectivity(g_path, source = 1), error = TRUE) + expect_snapshot_igraph_error(vertex_connectivity(g_path, source = 1)) }) test_that("edge_connectivity works", { @@ -179,7 +177,7 @@ test_that("edge_connectivity works -- names", { test_that("edge_connectivity error works", { g_path <- make_ring(5, circular = FALSE) - expect_snapshot(edge_connectivity(g_path, source = 1), error = TRUE) + expect_snapshot_igraph_error(edge_connectivity(g_path, source = 1)) }) test_that("edge_disjoint_paths works", { @@ -192,13 +190,11 @@ test_that("edge_disjoint_paths works", { test_that("edge_disjoint_paths error works", { g_path <- make_ring(5, circular = FALSE) - expect_snapshot( - edge_disjoint_paths(g_path, source = 1, target = NULL), - error = TRUE + expect_snapshot_igraph_error( + edge_disjoint_paths(g_path, source = 1, target = NULL) ) - expect_snapshot( - edge_disjoint_paths(g_path, source = NULL, target = 1), - error = TRUE + expect_snapshot_igraph_error( + edge_disjoint_paths(g_path, source = NULL, target = 1) ) }) @@ -212,7 +208,7 @@ test_that("vertex_disjoint_paths works", { test_that("vertex_disjoint_paths error works", { g_path <- make_ring(5, circular = FALSE) - expect_snapshot(vertex_disjoint_paths(g_path, source = 1), error = TRUE) + expect_snapshot_igraph_error(vertex_disjoint_paths(g_path, source = 1)) }) test_that("adhesion works", { @@ -225,7 +221,7 @@ test_that("adhesion works", { test_that("vertex_disjoint_paths error works", { g_path <- make_ring(5, circular = FALSE) - expect_snapshot(vertex_disjoint_paths(g_path, source = 1), error = TRUE) + expect_snapshot_igraph_error(vertex_disjoint_paths(g_path, source = 1)) }) @@ -252,8 +248,8 @@ test_that("dominator_tree errors work", { matrix(c(1, 2, 2, 3, 3, 4, 2, 5, 5, 6), byrow = TRUE, ncol = 2), directed = TRUE ) - expect_snapshot(dominator_tree(g_tree), error = TRUE) - expect_snapshot(dominator_tree(g_tree, root = NULL), error = TRUE) + expect_snapshot_igraph_error(dominator_tree(g_tree)) + expect_snapshot_igraph_error(dominator_tree(g_tree, root = NULL)) }) test_that("dominator_tree works -- legacy", { diff --git a/tests/testthat/test-foreign.R b/tests/testthat/test-foreign.R index 75f2c7a53f3..3a26f55e8b7 100644 --- a/tests/testthat/test-foreign.R +++ b/tests/testthat/test-foreign.R @@ -49,17 +49,17 @@ test_that("reading graph, unused argument", { lgl_path <- withr::local_tempfile(pattern = "testfile", fileext = ".lgl") g <- make_graph(c(1, 2, 2, 3)) write_graph(g, lgl_path, "lgl") - expect_snapshot(error = TRUE, read_graph(lgl_path, "lgl", useless = 1)) + expect_snapshot_igraph_error(read_graph(lgl_path, "lgl", useless = 1)) }) test_that("reading graph in unsupported format", { - expect_snapshot(error = TRUE, read_graph("bla", format = "blop")) + expect_snapshot_igraph_error(read_graph("bla", format = "blop")) }) test_that("writing graph in unsupported format", { g <- make_graph(c(1, 2, 2, 3)) file <- withr::local_tempfile() - expect_snapshot(error = TRUE, write_graph(g, file, format = "blop")) + expect_snapshot_igraph_error(write_graph(g, file, format = "blop")) }) test_that("graph_from_graphdb works", { @@ -72,13 +72,11 @@ test_that("graph_from_graphdb works", { skip_if(Sys.getenv("R_SANITIZER") == "true") expect_snapshot(g <- graph_from_graphdb(nodes = 1000)) - expect_snapshot(g <- graph_from_graphdb(), error = TRUE) - expect_snapshot( - g <- graph_from_graphdb(nodes = 10, prefix = "not_existing"), - error = TRUE + expect_snapshot_igraph_error(g <- graph_from_graphdb()) + expect_snapshot_igraph_error( + g <- graph_from_graphdb(nodes = 10, prefix = "not_existing") ) - expect_snapshot( - g <- graph_from_graphdb(nodes = 10, type = "not_existing"), - error = TRUE + expect_snapshot_igraph_error( + g <- graph_from_graphdb(nodes = 10, type = "not_existing") ) }) diff --git a/tests/testthat/test-hrg.R b/tests/testthat/test-hrg.R index 381d9669ab1..cbb22bc7c27 100644 --- a/tests/testthat/test-hrg.R +++ b/tests/testthat/test-hrg.R @@ -18,14 +18,14 @@ test_that("as.hclust.igraphHRG() works", { }) test_that("sample_hrg() checks its argument", { - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ sample_hrg(make_ring(10)) }) }) test_that("hrg_tree() checks its argument", { - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ hrg_tree(make_ring(10)) }) }) diff --git a/tests/testthat/test-incidence.R b/tests/testthat/test-incidence.R index 3f4b1ba7c43..68b5fb34d03 100644 --- a/tests/testthat/test-incidence.R +++ b/tests/testthat/test-incidence.R @@ -216,18 +216,18 @@ test_that("graph_from_biadjacency_matrix() errors well", { colnames(inc) <- letters[1:5] rownames(inc) <- LETTERS[1:3] - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ (g <- graph_from_biadjacency_matrix(inc, weight = FALSE)) }) - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ (g <- graph_from_biadjacency_matrix(inc, weight = 42)) }) - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ (g <- graph_from_biadjacency_matrix(inc, multiple = TRUE, weighted = TRUE)) }) }) test_that("graph_from_biadjacency_matrix errors for NAs", { A <- matrix(c(1, 1, NA, 1), 2, 2) - expect_snapshot(graph_from_biadjacency_matrix(A), error = TRUE) + expect_snapshot_igraph_error(graph_from_biadjacency_matrix(A)) }) diff --git a/tests/testthat/test-interface.R b/tests/testthat/test-interface.R index 0d331bda8fc..ff287fbb0a3 100644 --- a/tests/testthat/test-interface.R +++ b/tests/testthat/test-interface.R @@ -181,7 +181,7 @@ test_that("ends works", { test_that("get.edge.ids() deprecation", { g <- make_empty_graph(10) expect_snapshot(get.edge.ids(g, 1:2)) - expect_snapshot(get.edge.ids(g, 1:2, multi = TRUE), error = TRUE) + expect_snapshot_igraph_error(get.edge.ids(g, 1:2, multi = TRUE)) }) test_that("get_edge_id() works with data frame", { @@ -202,7 +202,7 @@ test_that("get_edge_id() works with matrices", { test_that("get_edge_id() errors correctly for wrong vp", { g <- make_full_graph(3, directed = FALSE) el_g <- make_empty_graph() - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ get_edge_ids(g, el_g) }) expect_error(get_edge_ids(g, NULL)) @@ -210,7 +210,7 @@ test_that("get_edge_id() errors correctly for wrong vp", { V(g)$name <- letters[1:3] df <- data.frame(from = c("a", "b"), to = c(1, 2)) - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ get_edge_ids(g, df) }) }) diff --git a/tests/testthat/test-iterators.R b/tests/testthat/test-iterators.R index 50790e1623a..a4acfe64974 100644 --- a/tests/testthat/test-iterators.R +++ b/tests/testthat/test-iterators.R @@ -444,6 +444,6 @@ test_that("edge indexes are stored as raw numbers", { test_that("logical indices are not recycled", { # https://github.com/igraph/rigraph/issues/848 g <- make_ring(5) - expect_snapshot(V(g)[c(TRUE, FALSE)], error = TRUE) - expect_snapshot(E(g)[c(TRUE, FALSE)], error = TRUE) + expect_snapshot_igraph_error(V(g)[c(TRUE, FALSE)]) + expect_snapshot_igraph_error(E(g)[c(TRUE, FALSE)]) }) diff --git a/tests/testthat/test-layout.R b/tests/testthat/test-layout.R index e1c6b22727b..725c966c0fc 100644 --- a/tests/testthat/test-layout.R +++ b/tests/testthat/test-layout.R @@ -17,7 +17,7 @@ test_that("layout_with_fr() works", { test_that("layout_with_fr() deprecated argument", { rlang::local_options(lifecycle_verbosity = "warning") g <- make_ring(10) - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ l <- layout_with_fr( g, niter = 50, @@ -212,7 +212,7 @@ test_that("Kamada-Kawai layout generator works", { test_that("layout_with_kk() deprecated arguments", { g <- make_ring(10) - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ l <- layout_with_kk( g, maxiter = 50, @@ -334,7 +334,7 @@ test_that("add_layout_ works", { test_that("layout_randomly() errors well", { g <- make_empty_graph(1) - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ layout_randomly(g, dim = 4) }) }) diff --git a/tests/testthat/test-make.R b/tests/testthat/test-make.R index c925cb88529..ca8b9c658c8 100644 --- a/tests/testthat/test-make.R +++ b/tests/testthat/test-make.R @@ -42,7 +42,7 @@ test_that("sample_, graph_ also work", { test_that("error messages are proper", { rlang::local_options(lifecycle_verbosity = "quiet") - expect_snapshot( + expect_snapshot_igraph_error( { make_() make_(1:10) @@ -54,8 +54,7 @@ test_that("error messages are proper", { sample_() sample_(1:10) sample_(directed_graph(), directed_graph()) - }, - error = TRUE + } ) }) @@ -292,9 +291,9 @@ test_that("compatibility when arguments are not named", { }) test_that("make_empty_graph gives an error for invalid arguments", { - expect_snapshot(make_empty_graph(NULL), error = TRUE) - expect_snapshot(make_empty_graph("spam"), error = TRUE) - expect_snapshot(make_empty_graph(10, "spam"), error = TRUE) + expect_snapshot_igraph_error(make_empty_graph(NULL)) + expect_snapshot_igraph_error(make_empty_graph("spam")) + expect_snapshot_igraph_error(make_empty_graph(10, "spam")) }) test_that("make_graph_atlas works", { diff --git a/tests/testthat/test-minimum.spanning.tree.R b/tests/testthat/test-minimum.spanning.tree.R index c6422d7a385..3fddd46813b 100644 --- a/tests/testthat/test-minimum.spanning.tree.R +++ b/tests/testthat/test-minimum.spanning.tree.R @@ -34,8 +34,7 @@ test_that("mst works", { test_that("mst error works", { g <- sample_gnp(10, 0.4) - expect_snapshot( - mst(g, algorithm = "undefined"), - error = TRUE + expect_snapshot_igraph_error( + mst(g, algorithm = "undefined") ) }) diff --git a/tests/testthat/test-other.R b/tests/testthat/test-other.R index 6ccd5cf2c45..063ab5a13e9 100644 --- a/tests/testthat/test-other.R +++ b/tests/testthat/test-other.R @@ -29,9 +29,8 @@ test_that("can create graphs when igraph is not attached", { test_that("running_mean works", { expect_equal(running_mean(1:10, 2), 2:10 - 0.5) - expect_snapshot( - running_mean(1:3, 4), - error = TRUE + expect_snapshot_igraph_error( + running_mean(1:3, 4) ) }) @@ -159,7 +158,7 @@ karate <- structure( ) test_that("VS/ES require explicit conversion", { - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ V(karate) }) }) diff --git a/tests/testthat/test-plot.R b/tests/testthat/test-plot.R index 1467da59594..bbc29010ab8 100644 --- a/tests/testthat/test-plot.R +++ b/tests/testthat/test-plot.R @@ -142,7 +142,7 @@ test_that("Edges stop at outside of rectangle node", { test_that("layout as graph attribute error works", { g <- make_full_graph(10) g$layout <- layout_in_circle(g)[1:5, ] - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ plot(g) }) }) diff --git a/tests/testthat/test-structural-properties.R b/tests/testthat/test-structural-properties.R index 422e615f969..ac8f7936a8d 100644 --- a/tests/testthat/test-structural-properties.R +++ b/tests/testthat/test-structural-properties.R @@ -20,7 +20,7 @@ test_that("dfs() does not pad order", { test_that("dfs() deprecated arguments", { g <- make_star(3) - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ d <- dfs( g, root = 2, @@ -235,7 +235,7 @@ test_that("bfs() works", { test_that("bfs() deprecated arguments", { g <- graph_from_literal(a -+ b -+ c, z -+ a, d) - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ b <- bfs( g, root = 2, diff --git a/tests/testthat/test-utils-assert-args.R b/tests/testthat/test-utils-assert-args.R index a2984d3a94b..d2b2654a3b2 100644 --- a/tests/testthat/test-utils-assert-args.R +++ b/tests/testthat/test-utils-assert-args.R @@ -7,8 +7,7 @@ test_that("ensure_igraph() works", { }) test_that("igraph_match_arg() works", { - expect_snapshot( - cluster_leiden(make_graph("Zachary"), objective_function = "something"), - error = TRUE + expect_snapshot_igraph_error( + cluster_leiden(make_graph("Zachary"), objective_function = "something") ) }) diff --git a/tests/testthat/test-versions.R b/tests/testthat/test-versions.R index 2429e227c24..0af0633de57 100644 --- a/tests/testthat/test-versions.R +++ b/tests/testthat/test-versions.R @@ -6,7 +6,7 @@ test_that("we create graphs of the current version", { }) test_that("we can't upgrade from 0.1.1 to 1.5.0, on the fly", { - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ oldsample_0_1_1() }) }) @@ -16,13 +16,13 @@ test_that("we can't upgrade from 0.1.1 to 1.5.0, explicitly", { expect_equal(graph_version(g), ver_0_1_1) - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ upgrade_graph(g) }) }) test_that("we can't upgrade from 0.2 to 1.5.0, on the fly", { - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ oldsample_0_2() }) }) @@ -37,7 +37,7 @@ test_that("we can upgrade from 0.2 to 1.5.0, explicitly", { }) test_that("we can't upgrade from 0.5 to 1.5.0, on the fly", { - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ oldsample_0_5() }) }) @@ -52,7 +52,7 @@ test_that("we can upgrade from 0.5 to 1.5.0, explicitly", { }) test_that("we can't upgrade from 0.6 to 1.5.0, on the fly", { - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ oldsample_0_6() }) }) @@ -95,16 +95,16 @@ test_that("reading of old igraph formats", { local_igraph_options(print.id = FALSE) s <- oldsamples() - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ s[["0.1.1"]] }) - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ s[["0.2"]] }) - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ s[["0.5"]] }) - expect_snapshot(error = TRUE, { + expect_snapshot_igraph_error({ s[["0.6"]] }) expect_snapshot({ From 625e84128ceb70a298ad6d42ecf632158080011d Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 Jan 2026 11:58:27 +0100 Subject: [PATCH 09/10] refactor: scrub file names in expect_snapshot_igraph_error() (#2537) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com> --- .gitignore | 1 + tests/testthat/_snaps/aaa-auto.md | 138 ++++++++++++++-------------- tests/testthat/_snaps/centrality.md | 2 +- tests/testthat/helper.R | 6 +- 4 files changed, 76 insertions(+), 71 deletions(-) diff --git a/.gitignore b/.gitignore index 44bea8a20c8..9a958f64733 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ cran /.vscode/launch.json /Rplots.pdf /_codeql_detected_source_root +tests/testthat/_problems/ diff --git a/tests/testthat/_snaps/aaa-auto.md b/tests/testthat/_snaps/aaa-auto.md index ec6cb64b8e2..c37d623cd2b 100644 --- a/tests/testthat/_snaps/aaa-auto.md +++ b/tests/testthat/_snaps/aaa-auto.md @@ -21,7 +21,7 @@ Condition Error in `empty_impl()`: ! Number of vertices must not be negative. Invalid value - Source: graph/type_indexededgelist.c:xx + Source: : # add_edges_impl basic @@ -157,7 +157,7 @@ Condition Error in `wheel_impl()`: ! Invalid number of vertices. Invalid vertex ID - Source: constructors/regular.c:xx + Source: : # hypercube_impl basic @@ -184,7 +184,7 @@ Condition Error in `hypercube_impl()`: ! The requested hypercube graph dimension (10000) is too high. It must be no greater than 57. Invalid value - Source: constructors/regular.c:xx + Source: : # square_lattice_impl basic @@ -212,7 +212,7 @@ Condition Error in `square_lattice_impl()`: ! Invalid dimension vector. Invalid value - Source: constructors/regular.c:xx + Source: : # triangular_lattice_impl basic @@ -239,7 +239,7 @@ Condition Error in `triangular_lattice_impl()`: ! Invalid dimension vector. Invalid value - Source: constructors/lattices.c:xx + Source: : # path_graph_impl basic @@ -266,7 +266,7 @@ Condition Error in `path_graph_impl()`: ! The number of vertices must be non-negative, got -1. Invalid value - Source: constructors/regular.c:xx + Source: : # cycle_graph_impl basic @@ -293,7 +293,7 @@ Condition Error in `cycle_graph_impl()`: ! The number of vertices must be non-negative, got -1. Invalid value - Source: constructors/regular.c:xx + Source: : # symmetric_tree_impl basic @@ -320,7 +320,7 @@ Condition Error in `symmetric_tree_impl()`: ! The number of branches must be positive at each level. Invalid value - Source: constructors/regular.c:xx + Source: : # regular_tree_impl basic @@ -348,7 +348,7 @@ Condition Error in `regular_tree_impl()`: ! Height of regular tree must be positive, got -1. Invalid value - Source: constructors/regular.c:xx + Source: : # full_citation_impl basic @@ -375,7 +375,7 @@ Condition Error in `full_citation_impl()`: ! Invalid number of vertices. Invalid value - Source: constructors/full.c:xx + Source: : # atlas_impl basic @@ -401,7 +401,7 @@ Condition Error in `atlas_impl()`: ! No such graph in atlas. The graph index must be less than 1253. Invalid value - Source: constructors/atlas.c:xx + Source: : # extended_chordal_ring_impl basic @@ -428,7 +428,7 @@ Condition Error in `extended_chordal_ring_impl()`: ! An extended chordal ring has at least 3 nodes. Invalid value - Source: constructors/regular.c:xx + Source: : # graph_power_impl basic @@ -490,7 +490,7 @@ Condition Error in `de_bruijn_impl()`: ! `m' and `n' should be non-negative in a de Bruijn graph. Invalid value - Source: constructors/de_bruijn.c:xx + Source: : # kautz_impl basic @@ -512,7 +512,7 @@ Condition Error in `kautz_impl()`: ! `m' and `n' should be non-negative in a Kautz graph. Invalid value - Source: constructors/kautz.c:xx + Source: : # lcf_vector_impl basic @@ -532,7 +532,7 @@ Condition Error in `lcf_vector_impl()`: ! Number of vertices must not be negative. Invalid value - Source: graph/type_indexededgelist.c:xx + Source: : # mycielski_graph_impl basic @@ -550,7 +550,7 @@ Condition Error in `mycielski_graph_impl()`: ! The Mycielski graph order must not be negative. Invalid value - Source: constructors/mycielskian.c:xx + Source: : # adjlist_impl basic @@ -568,7 +568,7 @@ Condition Error in `adjlist_impl()`: ! Invalid (negative or too large) vertex ID. Invalid vertex ID - Source: constructors/basic_constructors.c:xx + Source: : # full_bipartite_impl basic @@ -605,7 +605,7 @@ Condition Error in `full_bipartite_impl()`: ! Invalid number of vertices for bipartite graph. Invalid value - Source: misc/bipartite.c:xx + Source: : # full_multipartite_impl basic @@ -662,7 +662,7 @@ Condition Error in `full_multipartite_impl()`: ! Number of vertices must not be negative in any partition. Invalid value - Source: constructors/full.c:xx + Source: : # realize_degree_sequence_impl basic @@ -694,7 +694,7 @@ Condition Error in `realize_degree_sequence_impl()`: ! The sum of degrees must be even for an undirected graph. Invalid value - Source: misc/degree_sequence.cpp:xx + Source: : # realize_bipartite_degree_sequence_impl basic @@ -726,7 +726,7 @@ Condition Error in `realize_bipartite_degree_sequence_impl()`: ! The given bidegree sequence cannot be realized as a bipartite simple graph. Invalid value - Source: misc/degree_sequence.cpp:xx + Source: : # circulant_impl basic @@ -755,7 +755,7 @@ Condition Error in `circulant_impl()`: ! Number of nodes = -1 must be non-negative. Invalid value - Source: constructors/circulant.c:xx + Source: : # generalized_petersen_impl basic @@ -774,7 +774,7 @@ Condition Error in `generalized_petersen_impl()`: ! n = -1 must be at least 3. Invalid value - Source: constructors/generalized_petersen.c:xx + Source: : # turan_impl basic @@ -806,7 +806,7 @@ Condition Error in `turan_impl()`: ! Number of vertices must not be negative, got -1. Invalid value - Source: constructors/full.c:xx + Source: : # erdos_renyi_game_gnp_impl basic @@ -833,7 +833,7 @@ Condition Error in `erdos_renyi_game_gnp_impl()`: ! Invalid number of vertices. Invalid value - Source: games/erdos_renyi.c:xx + Source: : # erdos_renyi_game_gnm_impl basic @@ -860,7 +860,7 @@ Condition Error in `erdos_renyi_game_gnm_impl()`: ! Invalid number of vertices. Invalid value - Source: games/erdos_renyi.c:xx + Source: : # growing_random_game_impl basic @@ -899,7 +899,7 @@ Condition Error in `growing_random_game_impl()`: ! Invalid number of vertices. Invalid value - Source: games/growing_random.c:xx + Source: : # preference_game_impl basic @@ -924,7 +924,7 @@ Condition Error in `preference_game_impl()`: ! The number of vertices must be non-negative. Invalid value - Source: games/preference.c:xx + Source: : # asymmetric_preference_game_impl basic @@ -954,7 +954,7 @@ Condition Error in `asymmetric_preference_game_impl()`: ! The number of vertices must not be negative. Invalid value - Source: games/preference.c:xx + Source: : # rewire_edges_impl basic @@ -1018,7 +1018,7 @@ Condition Error in `forest_fire_game_impl()`: ! Insufficient memory for forest fire model. Out of memory - Source: games/forestfire.c:xx + Source: : # simple_interconnected_islands_game_impl basic @@ -1040,7 +1040,7 @@ Condition Error in `simple_interconnected_islands_game_impl()`: ! Number of islands cannot be negative, got -1. Invalid value - Source: games/islands.c:xx + Source: : # chung_lu_game_impl basic @@ -1070,7 +1070,7 @@ Condition Error in `chung_lu_game_impl()`: ! Vertex weights must not be negative in Chung-Lu model, got -1. Invalid value - Source: games/chung_lu.c:xx + Source: : # static_fitness_game_impl basic @@ -1100,7 +1100,7 @@ Condition Error in `static_fitness_game_impl()`: ! Number of edges cannot be negative, got -1. Invalid value - Source: games/static_fitness.c:xx + Source: : # static_power_law_game_impl basic @@ -1132,7 +1132,7 @@ Condition Error in `static_power_law_game_impl()`: ! Number of nodes cannot be negative, got -1. Invalid value - Source: games/static_fitness.c:xx + Source: : # k_regular_game_impl basic @@ -1161,7 +1161,7 @@ Condition Error in `k_regular_game_impl()`: ! Number of nodes must be non-negative. Invalid value - Source: games/k_regular.c:xx + Source: : # sbm_game_impl basic @@ -1191,7 +1191,7 @@ Condition Error in `sbm_game_impl()`: ! Sum of the block sizes (5) must equal the number of vertices (-1). Invalid value - Source: games/sbm.c:xx + Source: : # hsbm_game_impl basic @@ -1210,7 +1210,7 @@ Condition Error in `hsbm_game_impl()`: ! `n' must be positive for HSBM. Invalid value - Source: games/sbm.c:xx + Source: : # hsbm_list_game_impl basic @@ -1239,7 +1239,7 @@ Condition Error in `hsbm_list_game_impl()`: ! `n' must be positive for HSBM. Invalid value - Source: games/sbm.c:xx + Source: : # correlated_game_impl basic @@ -1298,7 +1298,7 @@ Condition Error in `correlated_pair_game_impl()`: ! Invalid number of vertices. Invalid value - Source: games/erdos_renyi.c:xx + Source: : # dot_product_game_impl basic @@ -1361,7 +1361,7 @@ Condition Error in `sample_sphere_surface_impl()`: ! Sphere must be at least two dimensional to sample from surface. Invalid value - Source: games/dotproduct.c:xx + Source: : # sample_sphere_volume_impl basic @@ -1390,7 +1390,7 @@ Condition Error in `sample_sphere_volume_impl()`: ! Sphere must be at least two dimensional to sample from surface. Invalid value - Source: games/dotproduct.c:xx + Source: : # sample_dirichlet_impl basic @@ -1409,7 +1409,7 @@ Condition Error in `sample_dirichlet_impl()`: ! Number of samples should be non-negative, got -1. Invalid value - Source: games/dotproduct.c:xx + Source: : # are_adjacent_impl basic @@ -3191,7 +3191,7 @@ Condition Error in `centralization_degree_tmax_impl()`: ! Number of vertices must not be negative. Invalid value - Source: centrality/centralization.c:xx + Source: : # centralization_betweenness_impl basic @@ -3252,7 +3252,7 @@ Condition Error in `centralization_betweenness_tmax_impl()`: ! Number of vertices must not be negative. Invalid value - Source: centrality/centralization.c:xx + Source: : # centralization_closeness_impl basic @@ -3313,7 +3313,7 @@ Condition Error in `centralization_closeness_tmax_impl()`: ! Number of vertices must not be negative. Invalid value - Source: centrality/centralization.c:xx + Source: : # centralization_eigenvector_centrality_impl basic @@ -3505,7 +3505,7 @@ Condition Error in `centralization_eigenvector_centrality_tmax_impl()`: ! Number of vertices must not be negative. Invalid value - Source: centrality/centralization.c:xx + Source: : # assortativity_nominal_impl basic @@ -4010,7 +4010,7 @@ NAs introduced by coercion Error in `is_graphical_impl()`: ! The value nan is not representable as an integer. Invalid value - Source: rinterface_extra.c:xx + Source: : # bfs_simple_impl basic @@ -4195,7 +4195,7 @@ Condition Error in `bipartite_game_gnp_impl()`: ! Invalid number of vertices for bipartite graph. Invalid value - Source: misc/bipartite.c:xx + Source: : # bipartite_game_gnm_impl basic @@ -4232,7 +4232,7 @@ Condition Error in `bipartite_game_gnm_impl()`: ! Invalid number of vertices for bipartite graph. Invalid value - Source: misc/bipartite.c:xx + Source: : # get_laplacian_impl basic @@ -5467,7 +5467,7 @@ NAs introduced by coercion Error in `compare_communities_impl()`: ! The value nan is not representable as an integer. Invalid value - Source: rinterface_extra.c:xx + Source: : # modularity_impl basic @@ -5676,7 +5676,7 @@ NAs introduced by coercion Error in `split_join_distance_impl()`: ! The value nan is not representable as an integer. Invalid value - Source: rinterface_extra.c:xx + Source: : # community_infomap_impl basic @@ -5804,7 +5804,7 @@ hrg_sample_impl(hrg = NULL) Condition Error in `hrg_sample_impl()`: - ! At vendor/cigraph/src/hrg/hrg_types.cc:xx : Assertion failed: n >= 0. This is an unexpected igraph error; please report this as a bug, along with the steps to reproduce it. + ! At : : Assertion failed: n >= 0. This is an unexpected igraph error; please report this as a bug, along with the steps to reproduce it. Please restart your R session to avoid crashes or other surprising behavior. # hrg_sample_many_impl basic @@ -5835,7 +5835,7 @@ hrg_sample_many_impl(hrg = NULL, num_samples = 2) Condition Error in `hrg_sample_many_impl()`: - ! At vendor/cigraph/src/hrg/hrg_types.cc:xx : Assertion failed: n >= 0. This is an unexpected igraph error; please report this as a bug, along with the steps to reproduce it. + ! At : : Assertion failed: n >= 0. This is an unexpected igraph error; please report this as a bug, along with the steps to reproduce it. Please restart your R session to avoid crashes or other surprising behavior. # hrg_game_impl basic @@ -5857,7 +5857,7 @@ hrg_game_impl(hrg = NULL) Condition Error in `hrg_game_impl()`: - ! At vendor/cigraph/src/hrg/hrg_types.cc:xx : Assertion failed: n >= 0. This is an unexpected igraph error; please report this as a bug, along with the steps to reproduce it. + ! At : : Assertion failed: n >= 0. This is an unexpected igraph error; please report this as a bug, along with the steps to reproduce it. Please restart your R session to avoid crashes or other surprising behavior. # hrg_consensus_impl errors @@ -5892,7 +5892,7 @@ Condition Error in `hrg_create_impl()`: ! HRG probability vector size (1) should be equal to the number of internal nodes (2). Invalid value - Source: hrg/hrg.cc:xx + Source: : # hrg_resize_impl basic @@ -5922,7 +5922,7 @@ Condition Error in `hrg_resize_impl()`: ! The value nan is not representable as an integer. Invalid value - Source: rinterface_extra.c:xx + Source: : # hrg_size_impl basic @@ -5938,7 +5938,7 @@ Condition Error in `hrg_size_impl()`: ! The value nan is not representable as an integer. Invalid value - Source: rinterface_extra.c:xx + Source: : # from_hrg_dendrogram_impl basic @@ -5962,7 +5962,7 @@ Condition Error in `from_hrg_dendrogram_impl()`: ! The value nan is not representable as an integer. Invalid value - Source: rinterface_extra.c:xx + Source: : # get_adjacency_sparse_impl basic @@ -6218,7 +6218,7 @@ Condition Error in `motifs_randesu_no_impl()`: ! Cut probability vector size (1) must agree with motif size (3). Invalid value - Source: misc/motifs.c:xx + Source: : # dyad_census_impl basic @@ -7133,7 +7133,7 @@ NAs introduced by coercion Error in `isoclass_create_impl()`: ! The value nan is not representable as an integer. Invalid value - Source: rinterface_extra.c:xx + Source: : # isomorphic_vf2_impl basic @@ -7687,7 +7687,7 @@ NAs introduced by coercion Error in `graph_count_impl()`: ! The value nan is not representable as an integer. Invalid value - Source: rinterface_extra.c:xx + Source: : # is_matching_impl basic @@ -8130,7 +8130,7 @@ Condition Error in `eigen_adjacency_impl()`: ! 'LAPACK' algorithm not implemented yet. Unimplemented function call - Source: linalg/eigen.c:xx + Source: : # eigen_adjacency_impl errors @@ -8191,7 +8191,7 @@ NAs introduced by coercion Error in `power_law_fit_impl()`: ! xmin must be greater than zero. Invalid value - Source: misc/power_law_fit.c:xx + Source: : # sir_impl basic @@ -9683,7 +9683,7 @@ Condition Error in `dim_select_impl()`: ! Need at least one singular value for dimensionality selection. Invalid value - Source: misc/embedding.c:xx + Source: : # solve_lsap_impl basic @@ -9816,7 +9816,7 @@ Condition Error in `eulerian_cycle_impl()`: ! The graph does not have an Eulerian cycle. Input problem has no solution - Source: paths/eulerian.c:xx + Source: : --- @@ -9960,7 +9960,7 @@ NAs introduced by coercion Error in `from_prufer_impl()`: ! The value nan is not representable as an integer. Invalid value - Source: rinterface_extra.c:xx + Source: : # to_prufer_impl basic @@ -10004,7 +10004,7 @@ NAs introduced by coercion Error in `tree_from_parent_vector_impl()`: ! The value nan is not representable as an integer. Invalid value - Source: rinterface_extra.c:xx + Source: : # is_complete_impl basic @@ -10064,7 +10064,7 @@ NAs introduced by coercion Error in `tree_game_impl()`: ! The value nan is not representable as an integer. Invalid value - Source: rinterface_extra.c:xx + Source: : # vertex_coloring_greedy_impl basic @@ -10461,7 +10461,7 @@ Condition Error in `famous_impl()`: ! NonexistentGraph is not a known graph. See the documentation for valid graph names. Invalid value - Source: constructors/famous.c:xx + Source: : # constraint_impl errors diff --git a/tests/testthat/_snaps/centrality.md b/tests/testthat/_snaps/centrality.md index 7a8ebc83914..f6ffca6419b 100644 --- a/tests/testthat/_snaps/centrality.md +++ b/tests/testthat/_snaps/centrality.md @@ -49,7 +49,7 @@ Condition Error in `arpack()`: ! ARPACK error. N must be positive - Source: linalg/arpack.c:xx + Source: : --- diff --git a/tests/testthat/helper.R b/tests/testthat/helper.R index 644486107af..dff654b1967 100644 --- a/tests/testthat/helper.R +++ b/tests/testthat/helper.R @@ -49,7 +49,11 @@ expect_snapshot_igraph_error <- function(x, ...) { {{ x }}, error = TRUE, transform = function(y) { - gsub(":(\\d+)", ":xx", y) + # Scrub file name and line number from error/warning messages + # Handles "Source: filename:linenumber" and "At path/to/file:line :" patterns + y <- gsub("Source: [^:]+:(\\d+|xx|)", "Source: :", y) + y <- gsub("At [^:]+:(\\d+|xx) :", "At : :", y) + y }, ... )) From a9dfd3a26f0153b9838ea2d98b8fe37d5dd338f6 Mon Sep 17 00:00:00 2001 From: krlmlr Date: Sat, 24 Jan 2026 11:06:15 +0000 Subject: [PATCH 10/10] chore: Auto-update from GitHub Actions Run: https://github.com/igraph/rigraph/actions/runs/21314037440 --- tests/testthat/helper.R | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/testthat/helper.R b/tests/testthat/helper.R index dff654b1967..91c6660ea60 100644 --- a/tests/testthat/helper.R +++ b/tests/testthat/helper.R @@ -51,7 +51,11 @@ expect_snapshot_igraph_error <- function(x, ...) { transform = function(y) { # Scrub file name and line number from error/warning messages # Handles "Source: filename:linenumber" and "At path/to/file:line :" patterns - y <- gsub("Source: [^:]+:(\\d+|xx|)", "Source: :", y) + y <- gsub( + "Source: [^:]+:(\\d+|xx|)", + "Source: :", + y + ) y <- gsub("At [^:]+:(\\d+|xx) :", "At : :", y) y },