def test_format_should_fail_with_warning_about_incorrect_settings_when_dump_invoked( self, stdout): self.assertFail( execute_cmake_tidy(command='format', arguments=['--dump-config', 'file.txt'])) normalized_output = normalize(stdout.getvalue()) verify(normalized_output, self.reporter)
def test_format_should_fail_with_warning_about_incorrect_settings_when_trying_to_format( self, stdout): self.assertFail( execute_cmake_tidy(command='format', arguments=[get_input_file('arguments.cmake')])) normalized_output = normalize(stdout.getvalue()) verify(normalized_output, self.reporter)
def test_format_tabs_with_spaces_replacement(self, load_settings, stdout): self.fake_settings['tabs_as_spaces'] = True load_settings.return_value = self.fake_settings self.format_file('spaces_violations.cmake') normalized_output = normalize(stdout.getvalue()) verify(normalized_output, self.reporter)
def test_format_should_dump_full_config_even_if_file_overrides_only_one( self, stdout): self.assertSuccess( execute_cmake_tidy(command='format', arguments=['--dump-config', 'file.txt'])) normalized_output = normalize(stdout.getvalue()) verify(normalized_output, self.reporter)
def test_format_should_dump_config_only_configuration_to_stdout_by_default( self, stdout): self.assertSuccess( execute_cmake_tidy(command='format', arguments=['--dump-config', 'dummy.txt'])) normalized_output = normalize(stdout.getvalue()) verify(normalized_output, self.reporter)
def test_formatting_with_tabs(self, load_settings, stdout): self.fake_settings['line_length'] = 80 load_settings.return_value = self.fake_settings self.format_file('line_length_handling.cmake') normalized_output = normalize(stdout.getvalue()) verify(normalized_output, self.reporter)
def test_format_inplace_with_error_should_inform_about_failure_and_keep_initial_file( self, write, stderr): self.assertFail( execute_cmake_tidy( command='format', arguments=['-i', get_input_file('incorrect_file.cmake')])) write.assert_not_called() normalized_output = normalize(stderr.getvalue()) verify(normalized_output, self.reporter)
def test_formatting_complicated_conditions(self, load_settings, stdout): self.fake_settings['tabs_as_spaces'] = False self.fake_settings['wrap_short_invocations_to_single_line'] = True load_settings.return_value = self.fake_settings self.format_file('complicated_conditions.cmake') normalized_output = normalize(stdout.getvalue()) verify(normalized_output, self.reporter)
def test_format_against_newline_violations_with_custom_settings( self, load_settings, stdout): self.fake_settings['succeeding_newlines'] = 4 load_settings.return_value = self.fake_settings self.format_file('newlines_violations.cmake') normalized_output = normalize(stdout.getvalue()) verify(normalized_output, self.reporter)
def test_format_line_splitting(self, load_settings, stdout): self.fake_settings['wrap_short_invocations_to_single_line'] = True self.fake_settings['line_length'] = 80 load_settings.return_value = self.fake_settings self.format_file('line_length_handling.cmake') normalized_output = normalize(stdout.getvalue()) verify(normalized_output, self.reporter)
def test_condition_formatting_with_different_kinds_of_parentheses( self, load_settings, stdout): self.fake_settings['wrap_short_invocations_to_single_line'] = True load_settings.return_value = self.fake_settings self.format_file('conditions_with_parentheses.cmake') normalized_output = normalize(stdout.getvalue()) verify(normalized_output, self.reporter)
def test_format_should_return_error_when_file_is_read_only_and_inplace_param_is_used( self, stderr): self.assertFail( execute_cmake_tidy( command='format', arguments=['-i', get_input_file('arguments.cmake')])) normalized_output = normalize(stderr.getvalue()) normalized_output = re.sub(r'File .*arguments', 'File <path>arguments', normalized_output) verify(normalized_output, self.reporter)
def test_format_should_provide_unified_diff_to_stdout(self, stdout): self.assertSuccess( execute_cmake_tidy( command='format', arguments=['--diff', get_input_file('arguments.cmake')])) normalized_output = normalize(stdout.getvalue()) normalized_output = self.__replace_with_fake_path( 'arguments.cmake', normalized_output) verify(normalized_output, self.reporter)
def test_format_indentation_when_spaces_after_command_name_are_present( self, load_settings, stdout): self.fake_settings[ 'space_between_command_and_begin_parentheses'] = True self.fake_settings['tabs_as_spaces'] = False load_settings.return_value = self.fake_settings self.format_file('indentations.cmake') normalized_output = normalize(stdout.getvalue()) verify(normalized_output, self.reporter)
def test_formatting_file_with_multiple_settings(self, load_settings, stdout): self.fake_settings['keywords'] = ['GROUP'] self.fake_settings['wrap_short_invocations_to_single_line'] = False self.fake_settings['keyword_and_single_value_in_one_line'] = False load_settings.return_value = self.fake_settings self.format_file('target_setting.cmake') normalized_output = normalize(stdout.getvalue()) verify(normalized_output, self.reporter)
def test_formatting_of_install_commands(self, load_settings, stdout): self.fake_settings['tabs_as_spaces'] = False self.fake_settings['closing_parentheses_in_newline_when_split'] = True self.fake_settings['wrap_short_invocations_to_single_line'] = True self.fake_settings['keyword_and_single_value_in_one_line'] = True load_settings.return_value = self.fake_settings self.format_file('install.cmake') normalized_output = normalize(stdout.getvalue()) verify(normalized_output, self.reporter)
def test_format_inplace_simple_file_with_verbose_option( self, stdout, write): self.assertSuccess( execute_cmake_tidy(command='format', arguments=[ '-i', '--verbose', get_input_file('arguments.cmake') ])) write.assert_called_once() self.assertIn(get_input_file('arguments.cmake'), stdout.getvalue()) normalized_output = normalize(write.call_args[0][1]) verify(normalized_output, self.reporter)
def test_handling_of_single_line_comments_within_different_parts_of_cmake_file( self, load_settings, stdout): self.fake_settings['wrap_short_invocations_to_single_line'] = True self.fake_settings['keep_property_and_value_in_one_line'] = True self.fake_settings['keyword_and_single_value_in_one_line'] = True self.fake_settings['closing_parentheses_in_newline_when_split'] = True load_settings.return_value = self.fake_settings self.format_file('comments.cmake') normalized_output = normalize(stdout.getvalue()) verify(normalized_output, self.reporter)
def test_real_implementation_of_feature_in_cmake_split_keywords_and_values( self, load_settings, stdout): self.fake_settings['tabs_as_spaces'] = False self.fake_settings['line_length'] = 80 self.fake_settings['closing_parentheses_in_newline_when_split'] = False self.fake_settings['wrap_short_invocations_to_single_line'] = False self.fake_settings['keyword_and_single_value_in_one_line'] = False load_settings.return_value = self.fake_settings self.format_file('set_of_functions.cmake') normalized_output = normalize(stdout.getvalue()) verify(normalized_output, self.reporter)
def test_incorrect_command_should_print_error_with_usage_help( self, stderr): self.assertFail(execute_cmake_tidy(command='invalid', arguments=[])) normalized_output = normalize(stderr.getvalue()) verify(normalized_output, self.reporter)
def test_analyze_command_help_shown(self, stdout): self.assertSuccess( execute_cmake_tidy(command='analyze', arguments=['--help'])) normalized_output = normalize(stdout.getvalue()) verify(normalized_output, self.reporter)
def test_format_indentation_of_basic_invocations(self, stdout): self.format_file('indentations.cmake') normalized_output = normalize(stdout.getvalue()) verify(normalized_output, self.reporter)
def test_format_bracket_arguments_handling(self, stdout): self.format_file('arguments.cmake') normalized_output = normalize(stdout.getvalue()) verify(normalized_output, self.reporter)
def test_format_against_newline_violations(self, stdout): self.format_file('newlines_violations.cmake') normalized_output = normalize(stdout.getvalue()) verify(normalized_output, self.reporter)
def test_version_argument_should_provide_correct_tool_version( self, stdout): self.assertSuccess(execute_cmake_tidy(command=None, arguments=['-v'])) normalized_output = normalize(stdout.getvalue()) verify(normalized_output, self.reporter)
def test_format_command_should_print_file_to_output(self, stdout): self.format_file('first_example.cmake') normalized_output = normalize(stdout.getvalue()) verify(normalized_output, self.reporter)