Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions scripts/auto_test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -59,45 +59,46 @@
"import os\n",
"import subprocess\n",
"\n",
"# Set your OpenAI API key\n",
"os.environ['OPENAI_API_KEY'] = ''\n",
"\n",
"# Specify project you want to detect\n",
"# Specify the project you want to detect\n",
"project_file = 18\n",
"\n",
"# Specify the folder path\n",
"# Define the folder path\n",
"folder_path = f'./benchmark/contracts/{project_file}'\n",
"\n",
"files = os.listdir(folder_path)\n",
"\n",
"# Function to run the command for a given file\n",
"def run_command(file_path):\n",
" with open(file_path, 'r', encoding='utf-8') as f:\n",
" file_content = f.read()\n",
" \n",
"\n",
" command = [\n",
" \"python\", \"run.py\",\n",
" \"--org\", \"RealWord\",\n",
" \"--config\", \"SmartContractBA\",\n",
" \"--task\", file_content,\n",
" \"--name\", f\"RealWorld_BA_{project_file}_{os.path.splitext(os.path.basename(file_path))[0]}\"\n",
" ]\n",
" \n",
"\n",
" try:\n",
" result = subprocess.run(command, check=True, capture_output=True, text=True)\n",
" print(f\"Successfully ran {file_path}\")\n",
" print(f\"Successfully ran {file_path}\")\n",
" print(result.stdout)\n",
" except subprocess.CalledProcessError as e:\n",
" print(f\"Error running {file_path}\")\n",
" print(f\"Error running {file_path}\")\n",
" print(e.stderr)\n",
"\n",
"# Walk through the folder and process each .sol file\n",
"for root, dirs, files in os.walk(folder_path):\n",
" for file in files:\n",
" if file.endswith('.sol'):\n",
" file_path = os.path.join(root, file)\n",
" print(f\"Processing {file_path}...\")\n",
" print(f\"🚀 Processing {file_path}...\")\n",
" run_command(file_path)\n",
" else:\n",
" print(f\"Skipping {file} (not a .sol file)\")"
" print(f\"⚠️ Skipping {file} (not a .sol file)\")\n"
]
},
{
Expand Down