Skip to content

Set expectation when no code is used with qenv - #274

Merged
llrs-roche merged 5 commits into
mainfrom
empty_qenv@main
Dec 11, 2025
Merged

Set expectation when no code is used with qenv#274
llrs-roche merged 5 commits into
mainfrom
empty_qenv@main

Conversation

@llrs-roche

Copy link
Copy Markdown
Contributor

Pull Request

Document expectation of what should return qenv with no code.
Discovered while working on insightsengineering/teal#1630 where some code assumed it would return NULL.

Previously it was only tested that testthat::expect_identical(get_code(qenv(), names = "a"), "").
It makes sense that it also return "" when there is no code.

@github-actions

github-actions Bot commented Oct 17, 2025

Copy link
Copy Markdown
Contributor

badge

Code Coverage Summary

Filename                         Stmts    Miss  Cover    Missing
-----------------------------  -------  ------  -------  -------------
R/qenv-c.R                          55       0  100.00%
R/qenv-class.R                      13       0  100.00%
R/qenv-concat.R                      7       0  100.00%
R/qenv-constructor.R                 1       0  100.00%
R/qenv-errors.R                      4       4  0.00%    6-9
R/qenv-eval_code.R                  60       1  98.33%   40
R/qenv-extract.R                    30       0  100.00%
R/qenv-get_code.R                   24       0  100.00%
R/qenv-get_env.R                     3       1  66.67%   27
R/qenv-get_messages.r                5       0  100.00%
R/qenv-get_outputs.R                 6       0  100.00%
R/qenv-get_var.R                    13       1  92.31%   13
R/qenv-get_warnings.R                5       0  100.00%
R/qenv-join.R                        1       1  0.00%    13
R/qenv-length.R                      2       1  50.00%   2
R/qenv-show.R                       29      29  0.00%    19-50
R/qenv-within.R                      8       0  100.00%
R/utils-get_code_dependency.R      265       3  98.87%   160, 258, 341
R/utils.R                           42       0  100.00%
TOTAL                              573      41  92.84%

Diff against main

Filename      Stmts    Miss  Cover
----------  -------  ------  --------
TOTAL             0       0  +100.00%

Results for commit: 71570f2

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@github-actions

github-actions Bot commented Oct 17, 2025

Copy link
Copy Markdown
Contributor

Unit Tests Summary

  1 files   14 suites   6s ⏱️
186 tests 182 ✅ 4 💤 0 ❌
269 runs  265 ✅ 4 💤 0 ❌

Results for commit 71570f2.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Oct 17, 2025

Copy link
Copy Markdown
Contributor

Unit Test Performance Difference

Additional test case details
Test Suite $Status$ Time on main $±Time$ Test Case
get_outputs 💀 $0.05$ $-0.05$ explicitly_printed_object_uses_newly_registered_print_method_and_returned_as_console_output_string
get_outputs 💀 $0.04$ $-0.04$ explicitly_printed_objects_are_returned_as_console_output_string_in_a_list
get_outputs 👶 $+0.05$ get_output_explicitly_printed_object_uses_newly_registered_print_method_and_returned_as_console_output_string
get_outputs 👶 $+0.04$ get_output_explicitly_printed_objects_are_returned_as_console_output_string_in_a_list
get_outputs 👶 $+0.05$ get_output_implicitly_printed_list_is_returned_asis_even_if_its_print_is_overridden
get_outputs 👶 $+0.09$ get_output_implicitly_printed_objects_are_returned_asis_in_a_list_and_are_identical_to_ones_in_the_environment
get_outputs 👶 $+0.03$ get_output_intermediate_plots_are_not_kept
get_outputs 👶 $+0.02$ get_output_messages_are_returned_asis_in_a_list
get_outputs 👶 $+0.03$ get_output_printed_plots_are_returned_as_recordedplot_in_a_list_1_
get_outputs 👶 $+0.03$ get_output_printed_plots_are_returned_as_recordedplot_in_a_list_2_
get_outputs 👶 $+0.02$ get_output_prints_inside_for_are_bundled_together
get_outputs 👶 $+0.12$ get_output_returns_an_empty_list_if_nothing_is_printed
get_outputs 👶 $+0.02$ get_output_warnings_are_returned_asis_in_a_list
get_outputs 💀 $0.04$ $-0.04$ implicitly_printed_list_is_returned_asis_even_if_its_print_is_overridden
get_outputs 💀 $0.08$ $-0.08$ implicitly_printed_objects_are_returned_asis_in_a_list_and_are_identical_to_ones_in_the_environment
get_outputs 💀 $0.03$ $-0.03$ intermediate_plots_are_not_kept
get_outputs 💀 $0.02$ $-0.02$ messages_are_returned_asis_in_a_list
get_outputs 💀 $0.03$ $-0.03$ printed_plots_are_returned_as_recordedplot_in_a_list_1_
get_outputs 💀 $0.03$ $-0.03$ printed_plots_are_returned_as_recordedplot_in_a_list_2_
get_outputs 💀 $0.02$ $-0.02$ prints_inside_for_are_bundled_together
get_outputs 💀 $0.12$ $-0.12$ returns_an_empty_list_if_nothing_is_printed
get_outputs 💀 $0.02$ $-0.02$ warnings_are_returned_asis_in_a_list
qenv-class 💀 $0.01$ $-0.01$ creates_a_locked_environment
qenv-class 💀 $0.01$ $-0.01$ creates_a_locked_environment_when_.xData_is_manually_defined
qenv-class 💀 $0.01$ $-0.01$ initialized_qenv_s_have_different_environments
qenv-class 👶 $+0.02$ methods_new_qenv_creates_a_locked_environment
qenv-class 👶 $+0.01$ methods_new_qenv_creates_a_locked_environment_when_.xData_is_manually_defined
qenv-class 👶 $+0.01$ methods_new_qenv_initialized_qenv_s_have_different_environments
qenv-class 👶 $+0.01$ methods_new_qenv_throws_error_when_.xData_is_not_an_environment
qenv-class 💀 $0.01$ $-0.01$ throws_error_when_.xData_is_not_an_environment
qenv_constructor 💀 $0.01$ $-0.01$ does_not_allow_binding_to_be_added
qenv_constructor 💀 $0.02$ $-0.02$ does_not_allow_binding_to_be_modified
qenv_constructor 💀 $0.01$ $-0.01$ is_an_environment
qenv_constructor 💀 $0.02$ $-0.02$ ls_all.names_TRUE_show_all_objects
qenv_constructor 💀 $0.02$ $-0.02$ ls_does_not_show_hidden_objects
qenv_constructor 💀 $0.01$ $-0.01$ names_shows_available_objets
qenv_constructor 💀 $0.02$ $-0.02$ names_shows_hidden_objects
qenv_constructor 💀 $0.00$ $-0.00$ names_shows_nothing_on_empty_environment
qenv_constructor 👶 $+0.00$ parent_of_qenv_environment_is_the_parent_of_.GlobalEnv_via_qenv_directly
qenv_constructor 👶 $+0.00$ parent_of_qenv_environment_is_the_parent_of_.GlobalEnv_via_slot
qenv_constructor 👶 $+0.01$ qenv_inherits_from_environment_does_not_allow_binding_to_be_added
qenv_constructor 👶 $+0.02$ qenv_inherits_from_environment_does_not_allow_binding_to_be_modified
qenv_constructor 👶 $+0.01$ qenv_inherits_from_environment_is_an_environment
qenv_constructor 👶 $+0.03$ qenv_inherits_from_environment_ls_all.names_TRUE_show_all_objects
qenv_constructor 👶 $+0.02$ qenv_inherits_from_environment_ls_does_not_show_hidden_objects
qenv_constructor 👶 $+0.01$ qenv_inherits_from_environment_names_shows_available_objets
qenv_constructor 👶 $+0.03$ qenv_inherits_from_environment_names_shows_hidden_objects
qenv_constructor 👶 $+0.00$ qenv_inherits_from_environment_names_shows_nothing_on_empty_environment
qenv_constructor 💀 $0.00$ $-0.00$ via_qenv_directly
qenv_constructor 💀 $0.00$ $-0.00$ via_slot
qenv_get_code 👶 $+0.08$ Backticked_symbol_code_can_be_retrieved_with_get_code
qenv_get_code 👶 $+0.04$ Backticked_symbol_starting_with_underscore_is_detected_in_code_dependency
qenv_get_code 👶 $+0.04$ Backticked_symbol_with_non_native_pipe_is_detected_code_dependency
qenv_get_code 👶 $+0.04$ Backticked_symbol_with_non_native_pipe_used_as_function_is_detected_code_dependency
qenv_get_code 👶 $+0.04$ Backticked_symbol_with_space_character_is_detected_in_code_dependency
qenv_get_code 👶 $+0.04$ Backticked_symbol_without_special_characters_is_cleaned_and_detected_in_code_dependency
qenv_get_code 💀 $0.08$ $-0.08$ code_can_be_retrieved_with_get_code
qenv_get_code 💀 $0.04$ $-0.04$ detects_calls_associated_with_object_if_calls_are_separated_by_
qenv_get_code 💀 $0.04$ $-0.04$ detects_every_assign_calls_even_if_not_evaluated_if_there_is_only_one_assignment_in_this_line
qenv_get_code 💀 $0.04$ $-0.04$ does_not_break_if_code_uses_quote_
qenv_get_code 💀 $0.04$ $-0.04$ does_not_break_if_object_is_used_in_a_function_on_lhs
qenv_get_code 💀 $0.05$ $-0.05$ does_not_break_if_object_is_used_in_a_function_on_lhs_and_influencers_are_both_on_lhs_and_rhs
qenv_get_code 💀 $0.04$ $-0.04$ does_not_fall_into_a_loop
qenv_get_code 💀 $0.06$ $-0.06$ doesn_t_consider_function_called_on_the_lhs_as_a_dependent_in_this_call_dependency_in_further_calls_
qenv_get_code 💀 $0.03$ $-0.03$ extracts_code_of_a_parent_binding_but_only_those_evaluated_before_coocurence
qenv_get_code 💀 $0.03$ $-0.03$ extracts_the_code_of_a_binding_from_character_vector_containing_simple_code
qenv_get_code 💀 $0.04$ $-0.04$ extracts_the_code_of_a_parent_binding_if_used_as_an_arg_in_a_function_call
qenv_get_code 💀 $0.03$ $-0.03$ extracts_the_code_when_using_
qenv_get_code 💀 $0.02$ $-0.02$ extracts_the_code_without_downstream_usage
qenv_get_code 👶 $+0.04$ get_code_for_specific_names_detects_calls_associated_with_object_if_calls_are_separated_by_
qenv_get_code 👶 $+0.04$ get_code_for_specific_names_detects_every_assign_calls_even_if_not_evaluated_if_there_is_only_one_assignment_in_this_line
qenv_get_code 👶 $+0.04$ get_code_for_specific_names_does_not_break_if_code_uses_quote_
qenv_get_code 👶 $+0.05$ get_code_for_specific_names_does_not_break_if_object_is_used_in_a_function_on_lhs
qenv_get_code 👶 $+0.04$ get_code_for_specific_names_does_not_break_if_object_is_used_in_a_function_on_lhs_and_influencers_are_both_on_lhs_and_rhs
qenv_get_code 👶 $+0.04$ get_code_for_specific_names_does_not_fall_into_a_loop
qenv_get_code 👶 $+0.07$ get_code_for_specific_names_doesn_t_consider_function_called_on_the_lhs_as_a_dependent_in_this_call_dependency_in_further_calls_
qenv_get_code 👶 $+0.03$ get_code_for_specific_names_extracts_code_of_a_parent_binding_but_only_those_evaluated_before_coocurence
qenv_get_code 👶 $+0.03$ get_code_for_specific_names_extracts_the_code_of_a_binding_from_character_vector_containing_simple_code
qenv_get_code 👶 $+0.04$ get_code_for_specific_names_extracts_the_code_of_a_parent_binding_if_used_as_an_arg_in_a_function_call
qenv_get_code 👶 $+0.04$ get_code_for_specific_names_extracts_the_code_when_using_
qenv_get_code 👶 $+0.02$ get_code_for_specific_names_extracts_the_code_without_downstream_usage
qenv_get_code 👶 $+0.01$ get_code_for_specific_names_handles_the_code_included_in_curly_brackets
qenv_get_code 👶 $+0.05$ get_code_for_specific_names_handles_the_code_of_length_1_when_at_least_one_is_enclosed_in_curly_brackets
qenv_get_code 👶 $+0.03$ get_code_for_specific_names_handles_the_code_without_symbols_on_rhs
qenv_get_code 👶 $+0.04$ get_code_for_specific_names_returns_result_of_length_1_for_non_empty_input_and_deparse_FALSE
qenv_get_code 👶 $+0.02$ get_code_for_specific_names_warns_if_binding_doesn_t_exist_in_code
qenv_get_code 👶 $+0.01$ get_code_for_specific_names_warns_if_empty_code_slot
qenv_get_code 👶 $+0.03$ get_code_for_specific_names_works_for_names_of_length_1
qenv_get_code 👶 $+0.01$ get_code_returns_character_of_length_0_if_no_code
qenv_get_code 💀 $0.00$ $-0.00$ handles_the_code_included_in_curly_brackets
qenv_get_code 💀 $0.05$ $-0.05$ handles_the_code_of_length_1_when_at_least_one_is_enclosed_in_curly_brackets
qenv_get_code 💀 $0.03$ $-0.03$ handles_the_code_without_symbols_on_rhs
qenv_get_code 💀 $0.04$ $-0.04$ returns_result_of_length_1_for_non_empty_input_and_deparse_FALSE
qenv_get_code 💀 $0.04$ $-0.04$ starting_with_underscore_is_detected_in_code_dependency
qenv_get_code 💀 $0.02$ $-0.02$ warns_if_binding_doesn_t_exist_in_code
qenv_get_code 💀 $0.01$ $-0.01$ warns_if_empty_code_slot
qenv_get_code 💀 $0.04$ $-0.04$ with_non_native_pipe_is_detected_code_dependency
qenv_get_code 💀 $0.04$ $-0.04$ with_non_native_pipe_used_as_function_is_detected_code_dependency
qenv_get_code 💀 $0.04$ $-0.04$ with_space_character_is_detected_in_code_dependency
qenv_get_code 💀 $0.04$ $-0.04$ without_special_characters_is_cleaned_and_detected_in_code_dependency
qenv_get_code 💀 $0.03$ $-0.03$ works_for_names_of_length_1
qenv_within 💀 $0.04$ $-0.04$ multiple_expressions
qenv_within 👶 $+0.04$ within_run_with_multiple_expressions
qenv_within 👶 $+0.02$ within_run_with_single_expression
utils-get_code_dependency 💀 $0.05$ $-0.05$ detects_
utils-get_code_dependency 💀 $0.07$ $-0.07$ detects_assign_function
utils-get_code_dependency 💀 $0.07$ $-0.07$ detects_function
utils-get_code_dependency 👶 $+0.04$ get_code_with_multiple_assignments_inside_an_expression_detects_assign_function
utils-get_code_dependency 👶 $+0.07$ get_code_with_multiple_assignments_inside_an_expression_detects_function
utils-get_code_dependency 👶 $+0.05$ get_code_with_single_assignments_inside_an_expression_detects_
utils-get_code_dependency 👶 $+0.03$ get_code_with_single_assignments_inside_an_expression_detects_assign_function

Results for commit c5b25ea

♻️ This comment has been updated with latest results.

@osenan osenan self-assigned this Dec 5, 2025

@osenan osenan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very useful test. Good job!

@llrs-roche
llrs-roche merged commit eb976f3 into main Dec 11, 2025
26 checks passed
@llrs-roche
llrs-roche deleted the empty_qenv@main branch December 11, 2025 09:57
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants