This commit is contained in:
Kevin Turcios 2024-12-16 18:59:24 -05:00
parent 7ff89e1e72
commit 74f5ebd160
2 changed files with 82 additions and 6 deletions

78
.gitignore vendored
View file

@ -173,3 +173,81 @@ cython_debug/
# IDE settings
.idea/
.vscode/
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# AWS User-specific
.idea/**/aws.xml
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# SonarLint plugin
.idea/sonarlint/
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

View file

@ -42,9 +42,8 @@ def generate_tests(
)
if response and isinstance(response, tuple) and len(response) == 2:
generated_test_source, instrumented_test_source = response
temp_run_dir = get_run_tmp_file(Path())
path = str(temp_run_dir).replace("\\", "\\\\")
instrumented_test_source = instrumented_test_source.replace("{codeflash_run_tmp_dir_client_side}", path)
temp_run_dir = get_run_tmp_file(Path()).as_posix()
instrumented_test_source = instrumented_test_source.replace("{codeflash_run_tmp_dir_client_side}", temp_run_dir)
else:
logger.warning(f"Failed to generate and instrument tests for {function_to_optimize.function_name}")
return None
@ -64,9 +63,8 @@ def merge_unit_tests(unit_test_source: str, inspired_unit_tests: str, test_frame
if test_framework == "pytest":
# Because we only want to modify the top level test functions
for node in ast.iter_child_nodes(modified_ast):
if isinstance(node, ast.FunctionDef):
if node.name.startswith("test_"):
node.name = node.name + "__inspired"
if isinstance(node, ast.FunctionDef) and node.name.startswith("test_"):
node.name = node.name + "__inspired"
unit_test_source_ast.body.extend(modified_ast.body)
unit_test_source_ast.body = import_list + unit_test_source_ast.body
if test_framework == "unittest":