From e890aa3f8fe38beaa95c08fed7d1c5901c7f9ed6 Mon Sep 17 00:00:00 2001 From: Stefan Heule Date: Mon, 2 Sep 2024 11:35:14 -0700 Subject: [PATCH 1/4] Use language names --- polyglot_piranha.pyi | 2 +- src/models/default_configs.rs | 4 ++-- src/models/language.rs | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/polyglot_piranha.pyi b/polyglot_piranha.pyi index 8700b3bff..da1ff1226 100644 --- a/polyglot_piranha.pyi +++ b/polyglot_piranha.pyi @@ -13,7 +13,7 @@ from __future__ import annotations from typing import List, Optional, Literal # Languages that Piranha supports (see ./src/models/language.rs) -PiranhaLanguage = Literal["java", "kt", "kotlin", "go", "py", "swift", "ts", "tsx", "thrift", "strings", "scm", "scala", "rb", "yaml", "yml"] +PiranhaLanguage = Literal["java", "kt", "kotlin", "go", "python", "swift", "typescript", "tsx", "thrift", "strings", "scm", "scala", "ruby", "yaml", "yml"] def execute_piranha(piranha_argument: PiranhaArguments) -> list[PiranhaOutputSummary]: diff --git a/src/models/default_configs.rs b/src/models/default_configs.rs index b610b08d7..d07ae8a67 100644 --- a/src/models/default_configs.rs +++ b/src/models/default_configs.rs @@ -25,9 +25,9 @@ pub const JAVA_CS: &str = "java_cs"; pub const KOTLIN: &str = "kt"; pub const KOTLIN_ALIAS: &str = "kotlin"; pub const GO: &str = "go"; -pub const PYTHON: &str = "py"; +pub const PYTHON: &str = "python"; pub const SWIFT: &str = "swift"; -pub const TYPESCRIPT: &str = "ts"; +pub const TYPESCRIPT: &str = "typescript"; pub const TSX: &str = "tsx"; pub const THRIFT: &str = "thrift"; pub const STRINGS: &str = "strings"; diff --git a/src/models/language.rs b/src/models/language.rs index 13ac4fbf9..d5ff22b7a 100644 --- a/src/models/language.rs +++ b/src/models/language.rs @@ -193,7 +193,7 @@ impl std::str::FromStr for PiranhaLanguage { }) } PYTHON => Ok(PiranhaLanguage { - extension: language.to_string(), + extension: "py".to_string(), supported_language: SupportedLanguage::Python, language: tree_sitter_python::language(), rules: None, @@ -219,7 +219,7 @@ impl std::str::FromStr for PiranhaLanguage { }) } TYPESCRIPT => Ok(PiranhaLanguage { - extension: language.to_string(), + extension: "ts".to_string(), supported_language: SupportedLanguage::Ts, language: tree_sitter_typescript::language_typescript(), rules: None, @@ -278,7 +278,7 @@ impl std::str::FromStr for PiranhaLanguage { let ruby_rules: Rules = parse_toml(include_str!("../cleanup_rules/ruby/rules.toml")); let ruby_edges: Edges = parse_toml(include_str!("../cleanup_rules/ruby/edges.toml")); Ok(PiranhaLanguage { - extension: language.to_string(), + extension: "rs".to_string(), supported_language: SupportedLanguage::Ruby, language: tree_sitter_ruby::language(), scopes: parse_toml::(include_str!( From 1ce8dd554fce98f517f19882531224f06decbe2d Mon Sep 17 00:00:00 2001 From: Stefan Heule Date: Mon, 2 Sep 2024 12:43:32 -0700 Subject: [PATCH 2/4] fix --- src/models/default_configs.rs | 2 +- src/tests/test_piranha_python.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/models/default_configs.rs b/src/models/default_configs.rs index d07ae8a67..19120455e 100644 --- a/src/models/default_configs.rs +++ b/src/models/default_configs.rs @@ -33,7 +33,7 @@ pub const THRIFT: &str = "thrift"; pub const STRINGS: &str = "strings"; pub const TS_SCHEME: &str = "scm"; // We support scheme files that contain tree-sitter query pub const SCALA: &str = "scala"; -pub const RUBY: &str = "rb"; +pub const RUBY: &str = "ruby"; pub const YAML: &str = "yaml"; pub const YAML_ALIAS: &str = "yml"; diff --git a/src/tests/test_piranha_python.rs b/src/tests/test_piranha_python.rs index 4d2b980bd..fcb8fd12d 100644 --- a/src/tests/test_piranha_python.rs +++ b/src/tests/test_piranha_python.rs @@ -39,7 +39,7 @@ fn test_delete_modify_str_literal_from_list_via_cli() { "-f", "test-resources/py/delete_cleanup_str_in_list/configurations", ]) - .args(["-l", "py"]) + .args(["-l", "python"]) .args(["-j", temp_file.to_str().unwrap()]) .arg("--dry-run") .args(["-s", "str_literal=dependency2"]) From 329d0d0dfedd31fc9c770d316f04ca15f2b6a702 Mon Sep 17 00:00:00 2001 From: Stefan Heule Date: Mon, 2 Sep 2024 13:43:23 -0700 Subject: [PATCH 3/4] fix --- .../delete_cleanup_str_in_list/configurations/edges.toml | 0 .../delete_cleanup_str_in_list/configurations/rules.toml | 0 .../delete_cleanup_str_in_list/expected/only_lists.py | 0 .../{py => python}/delete_cleanup_str_in_list/input/only_lists.py | 0 .../{py => python}/structural_find/configurations/rules.toml | 0 .../{py => python}/structural_find/input/list_as_arg.py | 0 test-resources/{py => python}/structural_find/input/only_lists.py | 0 .../delete_lines_after_return/configurations/rules.toml | 0 .../expected/delete_lines_after_return.rb | 0 .../delete_lines_after_return/input/delete_lines_after_return.rb | 0 .../configurations/rules.toml | 0 .../expected/test_empty_if_unless_rules.rb | 0 .../input/test_empty_if_unless_rules.rb | 0 .../{rb => ruby}/replace_if_statement/configurations/rules.toml | 0 .../replace_if_statement/expected/test_if_rules_inline.rb | 0 .../expected/test_if_rules_with_else_block.rb | 0 .../expected/test_if_rules_without_else_block.rb | 0 .../replace_if_statement/input/test_if_rules_inline.rb | 0 .../replace_if_statement/input/test_if_rules_with_else_block.rb | 0 .../input/test_if_rules_without_else_block.rb | 0 .../replace_ternary_operator/configurations/rules.toml | 0 .../replace_ternary_operator/expected/test_if_rules_ternary.rb | 0 .../replace_ternary_operator/input/test_if_rules_ternary.rb | 0 .../replace_unless_statement/configurations/rules.toml | 0 .../replace_unless_statement/expected/test_unless_rules_inline.rb | 0 .../expected/test_unless_rules_with_else_block.rb | 0 .../expected/test_unless_rules_without_else_block.rb | 0 .../replace_unless_statement/input/test_unless_rules_inline.rb | 0 .../input/test_unless_rules_with_else_block.rb | 0 .../input/test_unless_rules_without_else_block.rb | 0 .../simplify_boolean_expressions/configurations/rules.toml | 0 .../simplify_boolean_expressions/expected/boolean_simplify.rb | 0 .../simplify_boolean_expressions/input/boolean_simplify.rb | 0 .../configurations/rules.toml | 0 .../expected/simplify_if_lambda_conditional_statements.rb | 0 .../input/simplify_if_lambda_conditional_statements.rb | 0 .../configurations/rules.toml | 0 .../expected/simplify_if_proc_conditional_statements.rb | 0 .../input/simplify_if_proc_conditional_statements.rb | 0 .../simplify_rspec_block_expressions/configurations/rules.toml | 0 .../expected/simplify_rspec_block_expressions.rb | 0 .../input/simplify_rspec_block_expressions.rb | 0 .../configurations/rules.toml | 0 .../expected/simplify_unless_lambda_conditional_statements.rb | 0 .../input/simplify_unless_lambda_conditional_statements.rb | 0 .../configurations/rules.toml | 0 .../expected/simplify_unless_proc_conditional_statements.rb | 0 .../input/simplify_unless_proc_conditional_statements.rb | 0 .../configurations/edges.toml | 0 .../configurations/rules.toml | 0 .../expected/simplify_variable_assigned_flag_check.rb | 0 .../input/simplify_variable_assigned_flag_check.rb | 0 .../structural_find/find_fors/configurations/rules.toml | 0 .../{ts => typescript}/structural_find/find_fors/input/sample.ts | 0 .../find_fors_within_functions/configurations/rules.toml | 0 .../structural_find/find_fors_within_functions/input/sample.ts | 0 .../configurations/rules.toml | 0 .../find_fors_within_functions_not_within_whiles/input/sample.ts | 0 58 files changed, 0 insertions(+), 0 deletions(-) rename test-resources/{py => python}/delete_cleanup_str_in_list/configurations/edges.toml (100%) rename test-resources/{py => python}/delete_cleanup_str_in_list/configurations/rules.toml (100%) rename test-resources/{py => python}/delete_cleanup_str_in_list/expected/only_lists.py (100%) rename test-resources/{py => python}/delete_cleanup_str_in_list/input/only_lists.py (100%) rename test-resources/{py => python}/structural_find/configurations/rules.toml (100%) rename test-resources/{py => python}/structural_find/input/list_as_arg.py (100%) rename test-resources/{py => python}/structural_find/input/only_lists.py (100%) rename test-resources/{rb => ruby}/delete_lines_after_return/configurations/rules.toml (100%) rename test-resources/{rb => ruby}/delete_lines_after_return/expected/delete_lines_after_return.rb (100%) rename test-resources/{rb => ruby}/delete_lines_after_return/input/delete_lines_after_return.rb (100%) rename test-resources/{rb => ruby}/replace_empty_if_or_unless_statement/configurations/rules.toml (100%) rename test-resources/{rb => ruby}/replace_empty_if_or_unless_statement/expected/test_empty_if_unless_rules.rb (100%) rename test-resources/{rb => ruby}/replace_empty_if_or_unless_statement/input/test_empty_if_unless_rules.rb (100%) rename test-resources/{rb => ruby}/replace_if_statement/configurations/rules.toml (100%) rename test-resources/{rb => ruby}/replace_if_statement/expected/test_if_rules_inline.rb (100%) rename test-resources/{rb => ruby}/replace_if_statement/expected/test_if_rules_with_else_block.rb (100%) rename test-resources/{rb => ruby}/replace_if_statement/expected/test_if_rules_without_else_block.rb (100%) rename test-resources/{rb => ruby}/replace_if_statement/input/test_if_rules_inline.rb (100%) rename test-resources/{rb => ruby}/replace_if_statement/input/test_if_rules_with_else_block.rb (100%) rename test-resources/{rb => ruby}/replace_if_statement/input/test_if_rules_without_else_block.rb (100%) rename test-resources/{rb => ruby}/replace_ternary_operator/configurations/rules.toml (100%) rename test-resources/{rb => ruby}/replace_ternary_operator/expected/test_if_rules_ternary.rb (100%) rename test-resources/{rb => ruby}/replace_ternary_operator/input/test_if_rules_ternary.rb (100%) rename test-resources/{rb => ruby}/replace_unless_statement/configurations/rules.toml (100%) rename test-resources/{rb => ruby}/replace_unless_statement/expected/test_unless_rules_inline.rb (100%) rename test-resources/{rb => ruby}/replace_unless_statement/expected/test_unless_rules_with_else_block.rb (100%) rename test-resources/{rb => ruby}/replace_unless_statement/expected/test_unless_rules_without_else_block.rb (100%) rename test-resources/{rb => ruby}/replace_unless_statement/input/test_unless_rules_inline.rb (100%) rename test-resources/{rb => ruby}/replace_unless_statement/input/test_unless_rules_with_else_block.rb (100%) rename test-resources/{rb => ruby}/replace_unless_statement/input/test_unless_rules_without_else_block.rb (100%) rename test-resources/{rb => ruby}/simplify_boolean_expressions/configurations/rules.toml (100%) rename test-resources/{rb => ruby}/simplify_boolean_expressions/expected/boolean_simplify.rb (100%) rename test-resources/{rb => ruby}/simplify_boolean_expressions/input/boolean_simplify.rb (100%) rename test-resources/{rb => ruby}/simplify_if_lambda_conditional_statements/configurations/rules.toml (100%) rename test-resources/{rb => ruby}/simplify_if_lambda_conditional_statements/expected/simplify_if_lambda_conditional_statements.rb (100%) rename test-resources/{rb => ruby}/simplify_if_lambda_conditional_statements/input/simplify_if_lambda_conditional_statements.rb (100%) rename test-resources/{rb => ruby}/simplify_if_proc_conditional_statements/configurations/rules.toml (100%) rename test-resources/{rb => ruby}/simplify_if_proc_conditional_statements/expected/simplify_if_proc_conditional_statements.rb (100%) rename test-resources/{rb => ruby}/simplify_if_proc_conditional_statements/input/simplify_if_proc_conditional_statements.rb (100%) rename test-resources/{rb => ruby}/simplify_rspec_block_expressions/configurations/rules.toml (100%) rename test-resources/{rb => ruby}/simplify_rspec_block_expressions/expected/simplify_rspec_block_expressions.rb (100%) rename test-resources/{rb => ruby}/simplify_rspec_block_expressions/input/simplify_rspec_block_expressions.rb (100%) rename test-resources/{rb => ruby}/simplify_unless_lambda_conditional_statements/configurations/rules.toml (100%) rename test-resources/{rb => ruby}/simplify_unless_lambda_conditional_statements/expected/simplify_unless_lambda_conditional_statements.rb (100%) rename test-resources/{rb => ruby}/simplify_unless_lambda_conditional_statements/input/simplify_unless_lambda_conditional_statements.rb (100%) rename test-resources/{rb => ruby}/simplify_unless_proc_conditional_statements/configurations/rules.toml (100%) rename test-resources/{rb => ruby}/simplify_unless_proc_conditional_statements/expected/simplify_unless_proc_conditional_statements.rb (100%) rename test-resources/{rb => ruby}/simplify_unless_proc_conditional_statements/input/simplify_unless_proc_conditional_statements.rb (100%) rename test-resources/{rb => ruby}/simplify_variable_assigned_flag_check/configurations/edges.toml (100%) rename test-resources/{rb => ruby}/simplify_variable_assigned_flag_check/configurations/rules.toml (100%) rename test-resources/{rb => ruby}/simplify_variable_assigned_flag_check/expected/simplify_variable_assigned_flag_check.rb (100%) rename test-resources/{rb => ruby}/simplify_variable_assigned_flag_check/input/simplify_variable_assigned_flag_check.rb (100%) rename test-resources/{ts => typescript}/structural_find/find_fors/configurations/rules.toml (100%) rename test-resources/{ts => typescript}/structural_find/find_fors/input/sample.ts (100%) rename test-resources/{ts => typescript}/structural_find/find_fors_within_functions/configurations/rules.toml (100%) rename test-resources/{ts => typescript}/structural_find/find_fors_within_functions/input/sample.ts (100%) rename test-resources/{ts => typescript}/structural_find/find_fors_within_functions_not_within_whiles/configurations/rules.toml (100%) rename test-resources/{ts => typescript}/structural_find/find_fors_within_functions_not_within_whiles/input/sample.ts (100%) diff --git a/test-resources/py/delete_cleanup_str_in_list/configurations/edges.toml b/test-resources/python/delete_cleanup_str_in_list/configurations/edges.toml similarity index 100% rename from test-resources/py/delete_cleanup_str_in_list/configurations/edges.toml rename to test-resources/python/delete_cleanup_str_in_list/configurations/edges.toml diff --git a/test-resources/py/delete_cleanup_str_in_list/configurations/rules.toml b/test-resources/python/delete_cleanup_str_in_list/configurations/rules.toml similarity index 100% rename from test-resources/py/delete_cleanup_str_in_list/configurations/rules.toml rename to test-resources/python/delete_cleanup_str_in_list/configurations/rules.toml diff --git a/test-resources/py/delete_cleanup_str_in_list/expected/only_lists.py b/test-resources/python/delete_cleanup_str_in_list/expected/only_lists.py similarity index 100% rename from test-resources/py/delete_cleanup_str_in_list/expected/only_lists.py rename to test-resources/python/delete_cleanup_str_in_list/expected/only_lists.py diff --git a/test-resources/py/delete_cleanup_str_in_list/input/only_lists.py b/test-resources/python/delete_cleanup_str_in_list/input/only_lists.py similarity index 100% rename from test-resources/py/delete_cleanup_str_in_list/input/only_lists.py rename to test-resources/python/delete_cleanup_str_in_list/input/only_lists.py diff --git a/test-resources/py/structural_find/configurations/rules.toml b/test-resources/python/structural_find/configurations/rules.toml similarity index 100% rename from test-resources/py/structural_find/configurations/rules.toml rename to test-resources/python/structural_find/configurations/rules.toml diff --git a/test-resources/py/structural_find/input/list_as_arg.py b/test-resources/python/structural_find/input/list_as_arg.py similarity index 100% rename from test-resources/py/structural_find/input/list_as_arg.py rename to test-resources/python/structural_find/input/list_as_arg.py diff --git a/test-resources/py/structural_find/input/only_lists.py b/test-resources/python/structural_find/input/only_lists.py similarity index 100% rename from test-resources/py/structural_find/input/only_lists.py rename to test-resources/python/structural_find/input/only_lists.py diff --git a/test-resources/rb/delete_lines_after_return/configurations/rules.toml b/test-resources/ruby/delete_lines_after_return/configurations/rules.toml similarity index 100% rename from test-resources/rb/delete_lines_after_return/configurations/rules.toml rename to test-resources/ruby/delete_lines_after_return/configurations/rules.toml diff --git a/test-resources/rb/delete_lines_after_return/expected/delete_lines_after_return.rb b/test-resources/ruby/delete_lines_after_return/expected/delete_lines_after_return.rb similarity index 100% rename from test-resources/rb/delete_lines_after_return/expected/delete_lines_after_return.rb rename to test-resources/ruby/delete_lines_after_return/expected/delete_lines_after_return.rb diff --git a/test-resources/rb/delete_lines_after_return/input/delete_lines_after_return.rb b/test-resources/ruby/delete_lines_after_return/input/delete_lines_after_return.rb similarity index 100% rename from test-resources/rb/delete_lines_after_return/input/delete_lines_after_return.rb rename to test-resources/ruby/delete_lines_after_return/input/delete_lines_after_return.rb diff --git a/test-resources/rb/replace_empty_if_or_unless_statement/configurations/rules.toml b/test-resources/ruby/replace_empty_if_or_unless_statement/configurations/rules.toml similarity index 100% rename from test-resources/rb/replace_empty_if_or_unless_statement/configurations/rules.toml rename to test-resources/ruby/replace_empty_if_or_unless_statement/configurations/rules.toml diff --git a/test-resources/rb/replace_empty_if_or_unless_statement/expected/test_empty_if_unless_rules.rb b/test-resources/ruby/replace_empty_if_or_unless_statement/expected/test_empty_if_unless_rules.rb similarity index 100% rename from test-resources/rb/replace_empty_if_or_unless_statement/expected/test_empty_if_unless_rules.rb rename to test-resources/ruby/replace_empty_if_or_unless_statement/expected/test_empty_if_unless_rules.rb diff --git a/test-resources/rb/replace_empty_if_or_unless_statement/input/test_empty_if_unless_rules.rb b/test-resources/ruby/replace_empty_if_or_unless_statement/input/test_empty_if_unless_rules.rb similarity index 100% rename from test-resources/rb/replace_empty_if_or_unless_statement/input/test_empty_if_unless_rules.rb rename to test-resources/ruby/replace_empty_if_or_unless_statement/input/test_empty_if_unless_rules.rb diff --git a/test-resources/rb/replace_if_statement/configurations/rules.toml b/test-resources/ruby/replace_if_statement/configurations/rules.toml similarity index 100% rename from test-resources/rb/replace_if_statement/configurations/rules.toml rename to test-resources/ruby/replace_if_statement/configurations/rules.toml diff --git a/test-resources/rb/replace_if_statement/expected/test_if_rules_inline.rb b/test-resources/ruby/replace_if_statement/expected/test_if_rules_inline.rb similarity index 100% rename from test-resources/rb/replace_if_statement/expected/test_if_rules_inline.rb rename to test-resources/ruby/replace_if_statement/expected/test_if_rules_inline.rb diff --git a/test-resources/rb/replace_if_statement/expected/test_if_rules_with_else_block.rb b/test-resources/ruby/replace_if_statement/expected/test_if_rules_with_else_block.rb similarity index 100% rename from test-resources/rb/replace_if_statement/expected/test_if_rules_with_else_block.rb rename to test-resources/ruby/replace_if_statement/expected/test_if_rules_with_else_block.rb diff --git a/test-resources/rb/replace_if_statement/expected/test_if_rules_without_else_block.rb b/test-resources/ruby/replace_if_statement/expected/test_if_rules_without_else_block.rb similarity index 100% rename from test-resources/rb/replace_if_statement/expected/test_if_rules_without_else_block.rb rename to test-resources/ruby/replace_if_statement/expected/test_if_rules_without_else_block.rb diff --git a/test-resources/rb/replace_if_statement/input/test_if_rules_inline.rb b/test-resources/ruby/replace_if_statement/input/test_if_rules_inline.rb similarity index 100% rename from test-resources/rb/replace_if_statement/input/test_if_rules_inline.rb rename to test-resources/ruby/replace_if_statement/input/test_if_rules_inline.rb diff --git a/test-resources/rb/replace_if_statement/input/test_if_rules_with_else_block.rb b/test-resources/ruby/replace_if_statement/input/test_if_rules_with_else_block.rb similarity index 100% rename from test-resources/rb/replace_if_statement/input/test_if_rules_with_else_block.rb rename to test-resources/ruby/replace_if_statement/input/test_if_rules_with_else_block.rb diff --git a/test-resources/rb/replace_if_statement/input/test_if_rules_without_else_block.rb b/test-resources/ruby/replace_if_statement/input/test_if_rules_without_else_block.rb similarity index 100% rename from test-resources/rb/replace_if_statement/input/test_if_rules_without_else_block.rb rename to test-resources/ruby/replace_if_statement/input/test_if_rules_without_else_block.rb diff --git a/test-resources/rb/replace_ternary_operator/configurations/rules.toml b/test-resources/ruby/replace_ternary_operator/configurations/rules.toml similarity index 100% rename from test-resources/rb/replace_ternary_operator/configurations/rules.toml rename to test-resources/ruby/replace_ternary_operator/configurations/rules.toml diff --git a/test-resources/rb/replace_ternary_operator/expected/test_if_rules_ternary.rb b/test-resources/ruby/replace_ternary_operator/expected/test_if_rules_ternary.rb similarity index 100% rename from test-resources/rb/replace_ternary_operator/expected/test_if_rules_ternary.rb rename to test-resources/ruby/replace_ternary_operator/expected/test_if_rules_ternary.rb diff --git a/test-resources/rb/replace_ternary_operator/input/test_if_rules_ternary.rb b/test-resources/ruby/replace_ternary_operator/input/test_if_rules_ternary.rb similarity index 100% rename from test-resources/rb/replace_ternary_operator/input/test_if_rules_ternary.rb rename to test-resources/ruby/replace_ternary_operator/input/test_if_rules_ternary.rb diff --git a/test-resources/rb/replace_unless_statement/configurations/rules.toml b/test-resources/ruby/replace_unless_statement/configurations/rules.toml similarity index 100% rename from test-resources/rb/replace_unless_statement/configurations/rules.toml rename to test-resources/ruby/replace_unless_statement/configurations/rules.toml diff --git a/test-resources/rb/replace_unless_statement/expected/test_unless_rules_inline.rb b/test-resources/ruby/replace_unless_statement/expected/test_unless_rules_inline.rb similarity index 100% rename from test-resources/rb/replace_unless_statement/expected/test_unless_rules_inline.rb rename to test-resources/ruby/replace_unless_statement/expected/test_unless_rules_inline.rb diff --git a/test-resources/rb/replace_unless_statement/expected/test_unless_rules_with_else_block.rb b/test-resources/ruby/replace_unless_statement/expected/test_unless_rules_with_else_block.rb similarity index 100% rename from test-resources/rb/replace_unless_statement/expected/test_unless_rules_with_else_block.rb rename to test-resources/ruby/replace_unless_statement/expected/test_unless_rules_with_else_block.rb diff --git a/test-resources/rb/replace_unless_statement/expected/test_unless_rules_without_else_block.rb b/test-resources/ruby/replace_unless_statement/expected/test_unless_rules_without_else_block.rb similarity index 100% rename from test-resources/rb/replace_unless_statement/expected/test_unless_rules_without_else_block.rb rename to test-resources/ruby/replace_unless_statement/expected/test_unless_rules_without_else_block.rb diff --git a/test-resources/rb/replace_unless_statement/input/test_unless_rules_inline.rb b/test-resources/ruby/replace_unless_statement/input/test_unless_rules_inline.rb similarity index 100% rename from test-resources/rb/replace_unless_statement/input/test_unless_rules_inline.rb rename to test-resources/ruby/replace_unless_statement/input/test_unless_rules_inline.rb diff --git a/test-resources/rb/replace_unless_statement/input/test_unless_rules_with_else_block.rb b/test-resources/ruby/replace_unless_statement/input/test_unless_rules_with_else_block.rb similarity index 100% rename from test-resources/rb/replace_unless_statement/input/test_unless_rules_with_else_block.rb rename to test-resources/ruby/replace_unless_statement/input/test_unless_rules_with_else_block.rb diff --git a/test-resources/rb/replace_unless_statement/input/test_unless_rules_without_else_block.rb b/test-resources/ruby/replace_unless_statement/input/test_unless_rules_without_else_block.rb similarity index 100% rename from test-resources/rb/replace_unless_statement/input/test_unless_rules_without_else_block.rb rename to test-resources/ruby/replace_unless_statement/input/test_unless_rules_without_else_block.rb diff --git a/test-resources/rb/simplify_boolean_expressions/configurations/rules.toml b/test-resources/ruby/simplify_boolean_expressions/configurations/rules.toml similarity index 100% rename from test-resources/rb/simplify_boolean_expressions/configurations/rules.toml rename to test-resources/ruby/simplify_boolean_expressions/configurations/rules.toml diff --git a/test-resources/rb/simplify_boolean_expressions/expected/boolean_simplify.rb b/test-resources/ruby/simplify_boolean_expressions/expected/boolean_simplify.rb similarity index 100% rename from test-resources/rb/simplify_boolean_expressions/expected/boolean_simplify.rb rename to test-resources/ruby/simplify_boolean_expressions/expected/boolean_simplify.rb diff --git a/test-resources/rb/simplify_boolean_expressions/input/boolean_simplify.rb b/test-resources/ruby/simplify_boolean_expressions/input/boolean_simplify.rb similarity index 100% rename from test-resources/rb/simplify_boolean_expressions/input/boolean_simplify.rb rename to test-resources/ruby/simplify_boolean_expressions/input/boolean_simplify.rb diff --git a/test-resources/rb/simplify_if_lambda_conditional_statements/configurations/rules.toml b/test-resources/ruby/simplify_if_lambda_conditional_statements/configurations/rules.toml similarity index 100% rename from test-resources/rb/simplify_if_lambda_conditional_statements/configurations/rules.toml rename to test-resources/ruby/simplify_if_lambda_conditional_statements/configurations/rules.toml diff --git a/test-resources/rb/simplify_if_lambda_conditional_statements/expected/simplify_if_lambda_conditional_statements.rb b/test-resources/ruby/simplify_if_lambda_conditional_statements/expected/simplify_if_lambda_conditional_statements.rb similarity index 100% rename from test-resources/rb/simplify_if_lambda_conditional_statements/expected/simplify_if_lambda_conditional_statements.rb rename to test-resources/ruby/simplify_if_lambda_conditional_statements/expected/simplify_if_lambda_conditional_statements.rb diff --git a/test-resources/rb/simplify_if_lambda_conditional_statements/input/simplify_if_lambda_conditional_statements.rb b/test-resources/ruby/simplify_if_lambda_conditional_statements/input/simplify_if_lambda_conditional_statements.rb similarity index 100% rename from test-resources/rb/simplify_if_lambda_conditional_statements/input/simplify_if_lambda_conditional_statements.rb rename to test-resources/ruby/simplify_if_lambda_conditional_statements/input/simplify_if_lambda_conditional_statements.rb diff --git a/test-resources/rb/simplify_if_proc_conditional_statements/configurations/rules.toml b/test-resources/ruby/simplify_if_proc_conditional_statements/configurations/rules.toml similarity index 100% rename from test-resources/rb/simplify_if_proc_conditional_statements/configurations/rules.toml rename to test-resources/ruby/simplify_if_proc_conditional_statements/configurations/rules.toml diff --git a/test-resources/rb/simplify_if_proc_conditional_statements/expected/simplify_if_proc_conditional_statements.rb b/test-resources/ruby/simplify_if_proc_conditional_statements/expected/simplify_if_proc_conditional_statements.rb similarity index 100% rename from test-resources/rb/simplify_if_proc_conditional_statements/expected/simplify_if_proc_conditional_statements.rb rename to test-resources/ruby/simplify_if_proc_conditional_statements/expected/simplify_if_proc_conditional_statements.rb diff --git a/test-resources/rb/simplify_if_proc_conditional_statements/input/simplify_if_proc_conditional_statements.rb b/test-resources/ruby/simplify_if_proc_conditional_statements/input/simplify_if_proc_conditional_statements.rb similarity index 100% rename from test-resources/rb/simplify_if_proc_conditional_statements/input/simplify_if_proc_conditional_statements.rb rename to test-resources/ruby/simplify_if_proc_conditional_statements/input/simplify_if_proc_conditional_statements.rb diff --git a/test-resources/rb/simplify_rspec_block_expressions/configurations/rules.toml b/test-resources/ruby/simplify_rspec_block_expressions/configurations/rules.toml similarity index 100% rename from test-resources/rb/simplify_rspec_block_expressions/configurations/rules.toml rename to test-resources/ruby/simplify_rspec_block_expressions/configurations/rules.toml diff --git a/test-resources/rb/simplify_rspec_block_expressions/expected/simplify_rspec_block_expressions.rb b/test-resources/ruby/simplify_rspec_block_expressions/expected/simplify_rspec_block_expressions.rb similarity index 100% rename from test-resources/rb/simplify_rspec_block_expressions/expected/simplify_rspec_block_expressions.rb rename to test-resources/ruby/simplify_rspec_block_expressions/expected/simplify_rspec_block_expressions.rb diff --git a/test-resources/rb/simplify_rspec_block_expressions/input/simplify_rspec_block_expressions.rb b/test-resources/ruby/simplify_rspec_block_expressions/input/simplify_rspec_block_expressions.rb similarity index 100% rename from test-resources/rb/simplify_rspec_block_expressions/input/simplify_rspec_block_expressions.rb rename to test-resources/ruby/simplify_rspec_block_expressions/input/simplify_rspec_block_expressions.rb diff --git a/test-resources/rb/simplify_unless_lambda_conditional_statements/configurations/rules.toml b/test-resources/ruby/simplify_unless_lambda_conditional_statements/configurations/rules.toml similarity index 100% rename from test-resources/rb/simplify_unless_lambda_conditional_statements/configurations/rules.toml rename to test-resources/ruby/simplify_unless_lambda_conditional_statements/configurations/rules.toml diff --git a/test-resources/rb/simplify_unless_lambda_conditional_statements/expected/simplify_unless_lambda_conditional_statements.rb b/test-resources/ruby/simplify_unless_lambda_conditional_statements/expected/simplify_unless_lambda_conditional_statements.rb similarity index 100% rename from test-resources/rb/simplify_unless_lambda_conditional_statements/expected/simplify_unless_lambda_conditional_statements.rb rename to test-resources/ruby/simplify_unless_lambda_conditional_statements/expected/simplify_unless_lambda_conditional_statements.rb diff --git a/test-resources/rb/simplify_unless_lambda_conditional_statements/input/simplify_unless_lambda_conditional_statements.rb b/test-resources/ruby/simplify_unless_lambda_conditional_statements/input/simplify_unless_lambda_conditional_statements.rb similarity index 100% rename from test-resources/rb/simplify_unless_lambda_conditional_statements/input/simplify_unless_lambda_conditional_statements.rb rename to test-resources/ruby/simplify_unless_lambda_conditional_statements/input/simplify_unless_lambda_conditional_statements.rb diff --git a/test-resources/rb/simplify_unless_proc_conditional_statements/configurations/rules.toml b/test-resources/ruby/simplify_unless_proc_conditional_statements/configurations/rules.toml similarity index 100% rename from test-resources/rb/simplify_unless_proc_conditional_statements/configurations/rules.toml rename to test-resources/ruby/simplify_unless_proc_conditional_statements/configurations/rules.toml diff --git a/test-resources/rb/simplify_unless_proc_conditional_statements/expected/simplify_unless_proc_conditional_statements.rb b/test-resources/ruby/simplify_unless_proc_conditional_statements/expected/simplify_unless_proc_conditional_statements.rb similarity index 100% rename from test-resources/rb/simplify_unless_proc_conditional_statements/expected/simplify_unless_proc_conditional_statements.rb rename to test-resources/ruby/simplify_unless_proc_conditional_statements/expected/simplify_unless_proc_conditional_statements.rb diff --git a/test-resources/rb/simplify_unless_proc_conditional_statements/input/simplify_unless_proc_conditional_statements.rb b/test-resources/ruby/simplify_unless_proc_conditional_statements/input/simplify_unless_proc_conditional_statements.rb similarity index 100% rename from test-resources/rb/simplify_unless_proc_conditional_statements/input/simplify_unless_proc_conditional_statements.rb rename to test-resources/ruby/simplify_unless_proc_conditional_statements/input/simplify_unless_proc_conditional_statements.rb diff --git a/test-resources/rb/simplify_variable_assigned_flag_check/configurations/edges.toml b/test-resources/ruby/simplify_variable_assigned_flag_check/configurations/edges.toml similarity index 100% rename from test-resources/rb/simplify_variable_assigned_flag_check/configurations/edges.toml rename to test-resources/ruby/simplify_variable_assigned_flag_check/configurations/edges.toml diff --git a/test-resources/rb/simplify_variable_assigned_flag_check/configurations/rules.toml b/test-resources/ruby/simplify_variable_assigned_flag_check/configurations/rules.toml similarity index 100% rename from test-resources/rb/simplify_variable_assigned_flag_check/configurations/rules.toml rename to test-resources/ruby/simplify_variable_assigned_flag_check/configurations/rules.toml diff --git a/test-resources/rb/simplify_variable_assigned_flag_check/expected/simplify_variable_assigned_flag_check.rb b/test-resources/ruby/simplify_variable_assigned_flag_check/expected/simplify_variable_assigned_flag_check.rb similarity index 100% rename from test-resources/rb/simplify_variable_assigned_flag_check/expected/simplify_variable_assigned_flag_check.rb rename to test-resources/ruby/simplify_variable_assigned_flag_check/expected/simplify_variable_assigned_flag_check.rb diff --git a/test-resources/rb/simplify_variable_assigned_flag_check/input/simplify_variable_assigned_flag_check.rb b/test-resources/ruby/simplify_variable_assigned_flag_check/input/simplify_variable_assigned_flag_check.rb similarity index 100% rename from test-resources/rb/simplify_variable_assigned_flag_check/input/simplify_variable_assigned_flag_check.rb rename to test-resources/ruby/simplify_variable_assigned_flag_check/input/simplify_variable_assigned_flag_check.rb diff --git a/test-resources/ts/structural_find/find_fors/configurations/rules.toml b/test-resources/typescript/structural_find/find_fors/configurations/rules.toml similarity index 100% rename from test-resources/ts/structural_find/find_fors/configurations/rules.toml rename to test-resources/typescript/structural_find/find_fors/configurations/rules.toml diff --git a/test-resources/ts/structural_find/find_fors/input/sample.ts b/test-resources/typescript/structural_find/find_fors/input/sample.ts similarity index 100% rename from test-resources/ts/structural_find/find_fors/input/sample.ts rename to test-resources/typescript/structural_find/find_fors/input/sample.ts diff --git a/test-resources/ts/structural_find/find_fors_within_functions/configurations/rules.toml b/test-resources/typescript/structural_find/find_fors_within_functions/configurations/rules.toml similarity index 100% rename from test-resources/ts/structural_find/find_fors_within_functions/configurations/rules.toml rename to test-resources/typescript/structural_find/find_fors_within_functions/configurations/rules.toml diff --git a/test-resources/ts/structural_find/find_fors_within_functions/input/sample.ts b/test-resources/typescript/structural_find/find_fors_within_functions/input/sample.ts similarity index 100% rename from test-resources/ts/structural_find/find_fors_within_functions/input/sample.ts rename to test-resources/typescript/structural_find/find_fors_within_functions/input/sample.ts diff --git a/test-resources/ts/structural_find/find_fors_within_functions_not_within_whiles/configurations/rules.toml b/test-resources/typescript/structural_find/find_fors_within_functions_not_within_whiles/configurations/rules.toml similarity index 100% rename from test-resources/ts/structural_find/find_fors_within_functions_not_within_whiles/configurations/rules.toml rename to test-resources/typescript/structural_find/find_fors_within_functions_not_within_whiles/configurations/rules.toml diff --git a/test-resources/ts/structural_find/find_fors_within_functions_not_within_whiles/input/sample.ts b/test-resources/typescript/structural_find/find_fors_within_functions_not_within_whiles/input/sample.ts similarity index 100% rename from test-resources/ts/structural_find/find_fors_within_functions_not_within_whiles/input/sample.ts rename to test-resources/typescript/structural_find/find_fors_within_functions_not_within_whiles/input/sample.ts From 8bbdd403e1164c857e38400866f7ce415024173e Mon Sep 17 00:00:00 2001 From: Stefan Heule Date: Mon, 2 Sep 2024 14:49:56 -0700 Subject: [PATCH 4/4] fix --- src/tests/mod.rs | 1 - src/tests/test_piranha_python.rs | 9 ++++++--- src/tests/test_piranha_ruby.rs | 32 -------------------------------- 3 files changed, 6 insertions(+), 36 deletions(-) delete mode 100644 src/tests/test_piranha_ruby.rs diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 09799cca2..8554f3c4e 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -37,7 +37,6 @@ mod test_piranha_scala; mod test_piranha_thrift; -mod test_piranha_ruby; mod test_piranha_scm; mod test_piranha_strings; mod test_piranha_yaml; diff --git a/src/tests/test_piranha_python.rs b/src/tests/test_piranha_python.rs index fcb8fd12d..8ab288ff8 100644 --- a/src/tests/test_piranha_python.rs +++ b/src/tests/test_piranha_python.rs @@ -34,10 +34,13 @@ fn test_delete_modify_str_literal_from_list_via_cli() { let mut cmd = Command::cargo_bin("polyglot_piranha").unwrap(); cmd - .args(["-c", "test-resources/py/delete_cleanup_str_in_list/input"]) + .args([ + "-c", + "test-resources/python/delete_cleanup_str_in_list/input", + ]) .args([ "-f", - "test-resources/py/delete_cleanup_str_in_list/configurations", + "test-resources/python/delete_cleanup_str_in_list/configurations", ]) .args(["-l", "python"]) .args(["-j", temp_file.to_str().unwrap()]) @@ -50,7 +53,7 @@ fn test_delete_modify_str_literal_from_list_via_cli() { let content = read_file(&temp_file).unwrap(); let output: Vec = serde_json::from_str(&content).unwrap(); let expected_path = - Path::new("test-resources/py/delete_cleanup_str_in_list/expected/only_lists.py"); + Path::new("test-resources/python/delete_cleanup_str_in_list/expected/only_lists.py"); let expected = read_file(&expected_path.to_path_buf()).unwrap(); assert!(eq_without_whitespace(output[0].content(), &expected)); diff --git a/src/tests/test_piranha_ruby.rs b/src/tests/test_piranha_ruby.rs deleted file mode 100644 index 0966bcbc2..000000000 --- a/src/tests/test_piranha_ruby.rs +++ /dev/null @@ -1,32 +0,0 @@ -/* - Copyright (c) 2023 Uber Technologies, Inc. - -

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file - except in compliance with the License. You may obtain a copy of the License at -

http://www.apache.org/licenses/LICENSE-2.0 - -

Unless required by applicable law or agreed to in writing, software distributed under the - License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - express or implied. See the License for the specific language governing permissions and - limitations under the License. -*/ - -use crate::models::default_configs::RUBY; - -use super::create_rewrite_tests; - -create_rewrite_tests! { - RUBY, - test_replace_empty_if_unless_statement: "replace_empty_if_or_unless_statement", 1; - test_replace_ternary_operator: "replace_ternary_operator", 1; - test_replace_if_statement: "replace_if_statement", 3; - test_replace_unless_statement: "replace_unless_statement", 3; - test_boolean_cleanup: "simplify_boolean_expressions", 1; - test_simplify_rspec_block_expressions: "simplify_rspec_block_expressions", 1; - test_simplify_if_lambda_conditional_statements: "simplify_if_lambda_conditional_statements", 1; - test_simplify_unless_lambda_conditional_statements: "simplify_unless_lambda_conditional_statements", 1; - test_simplify_if_proc_conditional_statements: "simplify_if_proc_conditional_statements", 1; - test_simplify_unless_proc_conditional_statements: "simplify_if_proc_conditional_statements", 1; - test_delete_lines_after_return: "delete_lines_after_return", 1; - simplify_variable_assigned_flag_check: "simplify_variable_assigned_flag_check", 1; -}