Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/bitcoin/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/bitcoin/bitcoin.py +711 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/catchorg/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/catchorg/catch2.py +420 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/cgal/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/cgal/cgal.py +277 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/fmtlib/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/fmtlib/fmt.py +276 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/halide/Halide.py +475 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/halide/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/nlohmann/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/nlohmann/json.py +385 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/rootproject/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/rootproject/root.py +286 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/simdjson/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/simdjson/simdjson.py +339 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/yhirose/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/yhirose/cpp_httplib.py +276 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/beego/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/beego/beego.py +286 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/caddyserver/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/caddyserver/caddy.py +286 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/cli/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/cli/cli.py +286 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/etcd_io/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/etcd_io/etcd.py +321 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/fatedier/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/fatedier/frp.py +286 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/gin_gonic/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/gin_gonic/gin.py +289 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/go_gorm/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/go_gorm/gorm.py +289 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/gohugoio/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/gohugoio/hugo.py +286 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/grpc/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/grpc/grpc_go.py +289 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/istio/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/istio/istio.py +286 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/jesseduffield/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/jesseduffield/lazygit.py +286 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/junegunn/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/junegunn/fzf.py +286 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/labstack/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/labstack/echo.py +286 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/nektos/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/nektos/act.py +286 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/prometheus/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/prometheus/prometheus.py +286 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/syncthing/__init__.py +1 -0
- SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/syncthing/syncthing.py +286 -0
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/bitcoin/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.eval.harness.repos.cpp.bitcoin.bitcoin import *
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/bitcoin/bitcoin.py
ADDED
|
@@ -0,0 +1,711 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class BitcoinImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "gcc:11"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 50 |
+
ENV TZ=Etc/UTC
|
| 51 |
+
|
| 52 |
+
{code}
|
| 53 |
+
|
| 54 |
+
RUN wget https://cmake.org/files/v3.22/cmake-3.22.0-linux-x86_64.tar.gz && \
|
| 55 |
+
tar -zxvf cmake-3.22.0-linux-x86_64.tar.gz && \
|
| 56 |
+
mv cmake-3.22.0-linux-x86_64 /opt/cmake && \
|
| 57 |
+
ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake && \
|
| 58 |
+
rm cmake-3.22.0-linux-x86_64.tar.gz
|
| 59 |
+
|
| 60 |
+
RUN apt-get update && apt-get install -y cmake pkgconf python3 libevent-dev libboost-dev libsqlite3-dev libzmq3-dev systemtap-sdt-dev
|
| 61 |
+
RUN apt-get install -y qtbase5-dev qttools5-dev qttools5-dev-tools qtwayland5 libqrencode-dev
|
| 62 |
+
|
| 63 |
+
{self.clear_env}
|
| 64 |
+
|
| 65 |
+
"""
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
class BitcoinImageBaseCpp11(Image):
|
| 69 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 70 |
+
self._pr = pr
|
| 71 |
+
self._config = config
|
| 72 |
+
|
| 73 |
+
@property
|
| 74 |
+
def pr(self) -> PullRequest:
|
| 75 |
+
return self._pr
|
| 76 |
+
|
| 77 |
+
@property
|
| 78 |
+
def config(self) -> Config:
|
| 79 |
+
return self._config
|
| 80 |
+
|
| 81 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 82 |
+
return "gcc:11"
|
| 83 |
+
|
| 84 |
+
def image_tag(self) -> str:
|
| 85 |
+
return "base-cpp-11"
|
| 86 |
+
|
| 87 |
+
def workdir(self) -> str:
|
| 88 |
+
return "base-cpp-11"
|
| 89 |
+
|
| 90 |
+
def files(self) -> list[File]:
|
| 91 |
+
return []
|
| 92 |
+
|
| 93 |
+
def dockerfile(self) -> str:
|
| 94 |
+
image_name = self.dependency()
|
| 95 |
+
if isinstance(image_name, Image):
|
| 96 |
+
image_name = image_name.image_full_name()
|
| 97 |
+
|
| 98 |
+
if self.config.need_clone:
|
| 99 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 100 |
+
else:
|
| 101 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 102 |
+
|
| 103 |
+
return f"""FROM {image_name}
|
| 104 |
+
|
| 105 |
+
{self.global_env}
|
| 106 |
+
|
| 107 |
+
WORKDIR /home/
|
| 108 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 109 |
+
ENV TZ=Etc/UTC
|
| 110 |
+
|
| 111 |
+
{code}
|
| 112 |
+
|
| 113 |
+
RUN apt-get update && apt-get install -y libtool autotools-dev automake pkg-config bsdmainutils python3 libevent-dev libboost-dev libsqlite3-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev systemtap-sdt-dev python3-zmq
|
| 114 |
+
RUN apt-get install -y qtbase5-dev qttools5-dev qttools5-dev-tools qtwayland5 libqrencode-dev
|
| 115 |
+
|
| 116 |
+
{self.clear_env}
|
| 117 |
+
|
| 118 |
+
"""
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
class BitcoinImageBaseCpp11V2(Image):
|
| 122 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 123 |
+
self._pr = pr
|
| 124 |
+
self._config = config
|
| 125 |
+
|
| 126 |
+
@property
|
| 127 |
+
def pr(self) -> PullRequest:
|
| 128 |
+
return self._pr
|
| 129 |
+
|
| 130 |
+
@property
|
| 131 |
+
def config(self) -> Config:
|
| 132 |
+
return self._config
|
| 133 |
+
|
| 134 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 135 |
+
return "gcc:11"
|
| 136 |
+
|
| 137 |
+
def image_tag(self) -> str:
|
| 138 |
+
return "base-cpp-11V2"
|
| 139 |
+
|
| 140 |
+
def workdir(self) -> str:
|
| 141 |
+
return "base-cpp-11V2"
|
| 142 |
+
|
| 143 |
+
def files(self) -> list[File]:
|
| 144 |
+
return []
|
| 145 |
+
|
| 146 |
+
def dockerfile(self) -> str:
|
| 147 |
+
image_name = self.dependency()
|
| 148 |
+
if isinstance(image_name, Image):
|
| 149 |
+
image_name = image_name.image_full_name()
|
| 150 |
+
|
| 151 |
+
if self.config.need_clone:
|
| 152 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 153 |
+
else:
|
| 154 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 155 |
+
|
| 156 |
+
return f"""FROM {image_name}
|
| 157 |
+
|
| 158 |
+
{self.global_env}
|
| 159 |
+
|
| 160 |
+
WORKDIR /home/
|
| 161 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 162 |
+
ENV TZ=Etc/UTC
|
| 163 |
+
|
| 164 |
+
{code}
|
| 165 |
+
|
| 166 |
+
RUN apt-get update && apt-get install -y libtool autotools-dev automake pkg-config bsdmainutils python3 libevent-dev libboost-dev libboost-system-dev libboost-filesystem-dev libboost-test-dev libsqlite3-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev systemtap-sdt-dev python3-zmq
|
| 167 |
+
RUN apt-get install -y qtbase5-dev qttools5-dev qttools5-dev-tools qtwayland5 libqrencode-dev
|
| 168 |
+
RUN apt-get install -y libdb-dev libdb++-dev
|
| 169 |
+
{self.clear_env}
|
| 170 |
+
|
| 171 |
+
"""
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
class BitcoinImageBaseCpp11V3(Image):
|
| 175 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 176 |
+
self._pr = pr
|
| 177 |
+
self._config = config
|
| 178 |
+
|
| 179 |
+
@property
|
| 180 |
+
def pr(self) -> PullRequest:
|
| 181 |
+
return self._pr
|
| 182 |
+
|
| 183 |
+
@property
|
| 184 |
+
def config(self) -> Config:
|
| 185 |
+
return self._config
|
| 186 |
+
|
| 187 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 188 |
+
return "gcc:11"
|
| 189 |
+
|
| 190 |
+
def image_tag(self) -> str:
|
| 191 |
+
return "base-cpp-11V3"
|
| 192 |
+
|
| 193 |
+
def workdir(self) -> str:
|
| 194 |
+
return "base-cpp-11V3"
|
| 195 |
+
|
| 196 |
+
def files(self) -> list[File]:
|
| 197 |
+
return []
|
| 198 |
+
|
| 199 |
+
def dockerfile(self) -> str:
|
| 200 |
+
image_name = self.dependency()
|
| 201 |
+
if isinstance(image_name, Image):
|
| 202 |
+
image_name = image_name.image_full_name()
|
| 203 |
+
|
| 204 |
+
if self.config.need_clone:
|
| 205 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 206 |
+
else:
|
| 207 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 208 |
+
|
| 209 |
+
return f"""FROM {image_name}
|
| 210 |
+
|
| 211 |
+
{self.global_env}
|
| 212 |
+
|
| 213 |
+
WORKDIR /home/
|
| 214 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 215 |
+
ENV TZ=Etc/UTC
|
| 216 |
+
|
| 217 |
+
{code}
|
| 218 |
+
|
| 219 |
+
RUN apt-get update && apt-get install -y build-essential libtool autotools-dev automake pkg-config bsdmainutils python3 libevent-dev libboost-dev libboost-system-dev libboost-filesystem-dev libboost-test-dev libboost-thread-dev libsqlite3-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev systemtap-sdt-dev python3-zmq
|
| 220 |
+
RUN apt-get install -y qtbase5-dev qttools5-dev qttools5-dev-tools qtwayland5 libqrencode-dev
|
| 221 |
+
RUN apt-get install -y libdb-dev libdb++-dev
|
| 222 |
+
{self.clear_env}
|
| 223 |
+
|
| 224 |
+
"""
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
class BitcoinImageBaseCpp8(Image):
|
| 228 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 229 |
+
self._pr = pr
|
| 230 |
+
self._config = config
|
| 231 |
+
|
| 232 |
+
@property
|
| 233 |
+
def pr(self) -> PullRequest:
|
| 234 |
+
return self._pr
|
| 235 |
+
|
| 236 |
+
@property
|
| 237 |
+
def config(self) -> Config:
|
| 238 |
+
return self._config
|
| 239 |
+
|
| 240 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 241 |
+
return "gcc:8"
|
| 242 |
+
|
| 243 |
+
def image_tag(self) -> str:
|
| 244 |
+
return "base-cpp-8"
|
| 245 |
+
|
| 246 |
+
def workdir(self) -> str:
|
| 247 |
+
return "base-cpp-8"
|
| 248 |
+
|
| 249 |
+
def files(self) -> list[File]:
|
| 250 |
+
return []
|
| 251 |
+
|
| 252 |
+
def dockerfile(self) -> str:
|
| 253 |
+
image_name = self.dependency()
|
| 254 |
+
if isinstance(image_name, Image):
|
| 255 |
+
image_name = image_name.image_full_name()
|
| 256 |
+
|
| 257 |
+
if self.config.need_clone:
|
| 258 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 259 |
+
else:
|
| 260 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 261 |
+
|
| 262 |
+
return f"""FROM {image_name}
|
| 263 |
+
|
| 264 |
+
{self.global_env}
|
| 265 |
+
|
| 266 |
+
WORKDIR /home/
|
| 267 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 268 |
+
ENV TZ=Etc/UTC
|
| 269 |
+
|
| 270 |
+
{code}
|
| 271 |
+
|
| 272 |
+
RUN apt-get update && apt-get install -y build-essential libtool autotools-dev automake pkg-config bsdmainutils python3 libevent-dev libboost-system-dev libboost-filesystem-dev libboost-test-dev libboost-thread-dev libminiupnpc-dev libzmq3-dev python3-zmq
|
| 273 |
+
RUN apt-get install -y libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libqrencode-dev
|
| 274 |
+
RUN apt-get install -y libdb-dev libdb++-dev
|
| 275 |
+
{self.clear_env}
|
| 276 |
+
|
| 277 |
+
"""
|
| 278 |
+
|
| 279 |
+
|
| 280 |
+
class BitcoinImageDefault(Image):
|
| 281 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 282 |
+
self._pr = pr
|
| 283 |
+
self._config = config
|
| 284 |
+
|
| 285 |
+
@property
|
| 286 |
+
def pr(self) -> PullRequest:
|
| 287 |
+
return self._pr
|
| 288 |
+
|
| 289 |
+
@property
|
| 290 |
+
def config(self) -> Config:
|
| 291 |
+
return self._config
|
| 292 |
+
|
| 293 |
+
def dependency(self) -> Image | None:
|
| 294 |
+
if 24138 <= self.pr.number <= 30762:
|
| 295 |
+
return BitcoinImageBaseCpp11(self.pr, self._config)
|
| 296 |
+
elif 20166 < self.pr.number <= 24104:
|
| 297 |
+
return BitcoinImageBaseCpp11V2(self.pr, self._config)
|
| 298 |
+
elif 19054 <= self.pr.number <= 20166:
|
| 299 |
+
return BitcoinImageBaseCpp11V3(self.pr, self._config)
|
| 300 |
+
elif self.pr.number <= 18982:
|
| 301 |
+
return BitcoinImageBaseCpp8(self.pr, self._config)
|
| 302 |
+
return BitcoinImageBase(self.pr, self._config)
|
| 303 |
+
|
| 304 |
+
def image_tag(self) -> str:
|
| 305 |
+
return f"pr-{self.pr.number}"
|
| 306 |
+
|
| 307 |
+
def workdir(self) -> str:
|
| 308 |
+
return f"pr-{self.pr.number}"
|
| 309 |
+
|
| 310 |
+
def files(self) -> list[File]:
|
| 311 |
+
if 24138 <= self.pr.number <= 30762:
|
| 312 |
+
return [
|
| 313 |
+
File(
|
| 314 |
+
".",
|
| 315 |
+
"fix.patch",
|
| 316 |
+
f"{self.pr.fix_patch}",
|
| 317 |
+
),
|
| 318 |
+
File(
|
| 319 |
+
".",
|
| 320 |
+
"test.patch",
|
| 321 |
+
f"{self.pr.test_patch}",
|
| 322 |
+
),
|
| 323 |
+
File(
|
| 324 |
+
".",
|
| 325 |
+
"check_git_changes.sh",
|
| 326 |
+
"""#!/bin/bash
|
| 327 |
+
set -e
|
| 328 |
+
|
| 329 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 330 |
+
echo "check_git_changes: Not inside a git repository"
|
| 331 |
+
exit 1
|
| 332 |
+
fi
|
| 333 |
+
|
| 334 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 335 |
+
echo "check_git_changes: Uncommitted changes"
|
| 336 |
+
exit 1
|
| 337 |
+
fi
|
| 338 |
+
|
| 339 |
+
echo "check_git_changes: No uncommitted changes"
|
| 340 |
+
exit 0
|
| 341 |
+
|
| 342 |
+
""".format(
|
| 343 |
+
pr=self.pr
|
| 344 |
+
),
|
| 345 |
+
),
|
| 346 |
+
File(
|
| 347 |
+
".",
|
| 348 |
+
"prepare.sh",
|
| 349 |
+
"""#!/bin/bash
|
| 350 |
+
set -e
|
| 351 |
+
|
| 352 |
+
cd /home/{pr.repo}
|
| 353 |
+
git reset --hard
|
| 354 |
+
bash /home/check_git_changes.sh
|
| 355 |
+
git checkout {pr.base.sha}
|
| 356 |
+
bash /home/check_git_changes.sh
|
| 357 |
+
|
| 358 |
+
""".format(
|
| 359 |
+
pr=self.pr
|
| 360 |
+
),
|
| 361 |
+
),
|
| 362 |
+
File(
|
| 363 |
+
".",
|
| 364 |
+
"run.sh",
|
| 365 |
+
"""#!/bin/bash
|
| 366 |
+
set -e
|
| 367 |
+
|
| 368 |
+
cd /home/{pr.repo}
|
| 369 |
+
./autogen.sh
|
| 370 |
+
./configure
|
| 371 |
+
make check -j 4
|
| 372 |
+
test/functional/test_runner.py --extended
|
| 373 |
+
""".format(
|
| 374 |
+
pr=self.pr
|
| 375 |
+
),
|
| 376 |
+
),
|
| 377 |
+
File(
|
| 378 |
+
".",
|
| 379 |
+
"test-run.sh",
|
| 380 |
+
"""#!/bin/bash
|
| 381 |
+
set -e
|
| 382 |
+
|
| 383 |
+
cd /home/{pr.repo}
|
| 384 |
+
git apply --whitespace=nowarn /home/test.patch
|
| 385 |
+
./autogen.sh
|
| 386 |
+
./configure
|
| 387 |
+
make check -j 4
|
| 388 |
+
test/functional/test_runner.py --extended
|
| 389 |
+
|
| 390 |
+
""".format(
|
| 391 |
+
pr=self.pr
|
| 392 |
+
),
|
| 393 |
+
),
|
| 394 |
+
File(
|
| 395 |
+
".",
|
| 396 |
+
"fix-run.sh",
|
| 397 |
+
"""#!/bin/bash
|
| 398 |
+
set -e
|
| 399 |
+
|
| 400 |
+
cd /home/{pr.repo}
|
| 401 |
+
git apply --whitespace=nowarn /home/test.patch /home/fix.patch
|
| 402 |
+
./autogen.sh
|
| 403 |
+
./configure
|
| 404 |
+
make check -j 4
|
| 405 |
+
test/functional/test_runner.py --extended
|
| 406 |
+
|
| 407 |
+
""".format(
|
| 408 |
+
pr=self.pr
|
| 409 |
+
),
|
| 410 |
+
),
|
| 411 |
+
]
|
| 412 |
+
elif self.pr.number <= 24104:
|
| 413 |
+
return [
|
| 414 |
+
File(
|
| 415 |
+
".",
|
| 416 |
+
"fix.patch",
|
| 417 |
+
f"{self.pr.fix_patch}",
|
| 418 |
+
),
|
| 419 |
+
File(
|
| 420 |
+
".",
|
| 421 |
+
"test.patch",
|
| 422 |
+
f"{self.pr.test_patch}",
|
| 423 |
+
),
|
| 424 |
+
File(
|
| 425 |
+
".",
|
| 426 |
+
"check_git_changes.sh",
|
| 427 |
+
"""#!/bin/bash
|
| 428 |
+
set -e
|
| 429 |
+
|
| 430 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 431 |
+
echo "check_git_changes: Not inside a git repository"
|
| 432 |
+
exit 1
|
| 433 |
+
fi
|
| 434 |
+
|
| 435 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 436 |
+
echo "check_git_changes: Uncommitted changes"
|
| 437 |
+
exit 1
|
| 438 |
+
fi
|
| 439 |
+
|
| 440 |
+
echo "check_git_changes: No uncommitted changes"
|
| 441 |
+
exit 0
|
| 442 |
+
|
| 443 |
+
""".format(
|
| 444 |
+
pr=self.pr
|
| 445 |
+
),
|
| 446 |
+
),
|
| 447 |
+
File(
|
| 448 |
+
".",
|
| 449 |
+
"prepare.sh",
|
| 450 |
+
"""#!/bin/bash
|
| 451 |
+
set -e
|
| 452 |
+
|
| 453 |
+
cd /home/{pr.repo}
|
| 454 |
+
git reset --hard
|
| 455 |
+
bash /home/check_git_changes.sh
|
| 456 |
+
git checkout {pr.base.sha}
|
| 457 |
+
bash /home/check_git_changes.sh
|
| 458 |
+
|
| 459 |
+
""".format(
|
| 460 |
+
pr=self.pr
|
| 461 |
+
),
|
| 462 |
+
),
|
| 463 |
+
File(
|
| 464 |
+
".",
|
| 465 |
+
"run.sh",
|
| 466 |
+
"""#!/bin/bash
|
| 467 |
+
set -e
|
| 468 |
+
|
| 469 |
+
cd /home/{pr.repo}
|
| 470 |
+
./autogen.sh
|
| 471 |
+
./configure --with-incompatible-bdb
|
| 472 |
+
make check -j 4
|
| 473 |
+
test/functional/test_runner.py --extended
|
| 474 |
+
""".format(
|
| 475 |
+
pr=self.pr
|
| 476 |
+
),
|
| 477 |
+
),
|
| 478 |
+
File(
|
| 479 |
+
".",
|
| 480 |
+
"test-run.sh",
|
| 481 |
+
"""#!/bin/bash
|
| 482 |
+
set -e
|
| 483 |
+
|
| 484 |
+
cd /home/{pr.repo}
|
| 485 |
+
git apply --whitespace=nowarn /home/test.patch
|
| 486 |
+
./autogen.sh
|
| 487 |
+
./configure --with-incompatible-bdb
|
| 488 |
+
make check -j 4
|
| 489 |
+
test/functional/test_runner.py --extended
|
| 490 |
+
|
| 491 |
+
""".format(
|
| 492 |
+
pr=self.pr
|
| 493 |
+
),
|
| 494 |
+
),
|
| 495 |
+
File(
|
| 496 |
+
".",
|
| 497 |
+
"fix-run.sh",
|
| 498 |
+
"""#!/bin/bash
|
| 499 |
+
set -e
|
| 500 |
+
|
| 501 |
+
cd /home/{pr.repo}
|
| 502 |
+
git apply --whitespace=nowarn /home/test.patch /home/fix.patch
|
| 503 |
+
./autogen.sh
|
| 504 |
+
./configure --with-incompatible-bdb
|
| 505 |
+
make check -j 4
|
| 506 |
+
test/functional/test_runner.py --extended
|
| 507 |
+
|
| 508 |
+
""".format(
|
| 509 |
+
pr=self.pr
|
| 510 |
+
),
|
| 511 |
+
),
|
| 512 |
+
]
|
| 513 |
+
return [
|
| 514 |
+
File(
|
| 515 |
+
".",
|
| 516 |
+
"fix.patch",
|
| 517 |
+
f"{self.pr.fix_patch}",
|
| 518 |
+
),
|
| 519 |
+
File(
|
| 520 |
+
".",
|
| 521 |
+
"test.patch",
|
| 522 |
+
f"{self.pr.test_patch}",
|
| 523 |
+
),
|
| 524 |
+
File(
|
| 525 |
+
".",
|
| 526 |
+
"check_git_changes.sh",
|
| 527 |
+
"""#!/bin/bash
|
| 528 |
+
set -e
|
| 529 |
+
|
| 530 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 531 |
+
echo "check_git_changes: Not inside a git repository"
|
| 532 |
+
exit 1
|
| 533 |
+
fi
|
| 534 |
+
|
| 535 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 536 |
+
echo "check_git_changes: Uncommitted changes"
|
| 537 |
+
exit 1
|
| 538 |
+
fi
|
| 539 |
+
|
| 540 |
+
echo "check_git_changes: No uncommitted changes"
|
| 541 |
+
exit 0
|
| 542 |
+
|
| 543 |
+
""".format(
|
| 544 |
+
pr=self.pr
|
| 545 |
+
),
|
| 546 |
+
),
|
| 547 |
+
File(
|
| 548 |
+
".",
|
| 549 |
+
"prepare.sh",
|
| 550 |
+
"""#!/bin/bash
|
| 551 |
+
set -e
|
| 552 |
+
|
| 553 |
+
cd /home/{pr.repo}
|
| 554 |
+
git reset --hard
|
| 555 |
+
bash /home/check_git_changes.sh
|
| 556 |
+
git checkout {pr.base.sha}
|
| 557 |
+
bash /home/check_git_changes.sh
|
| 558 |
+
mkdir build
|
| 559 |
+
|
| 560 |
+
""".format(
|
| 561 |
+
pr=self.pr
|
| 562 |
+
),
|
| 563 |
+
),
|
| 564 |
+
File(
|
| 565 |
+
".",
|
| 566 |
+
"run.sh",
|
| 567 |
+
"""#!/bin/bash
|
| 568 |
+
set -e
|
| 569 |
+
|
| 570 |
+
cd /home/{pr.repo}
|
| 571 |
+
cd build
|
| 572 |
+
cmake ..
|
| 573 |
+
make -j 4
|
| 574 |
+
ctest -j 4
|
| 575 |
+
test/functional/test_runner.py --extended
|
| 576 |
+
""".format(
|
| 577 |
+
pr=self.pr
|
| 578 |
+
),
|
| 579 |
+
),
|
| 580 |
+
File(
|
| 581 |
+
".",
|
| 582 |
+
"test-run.sh",
|
| 583 |
+
"""#!/bin/bash
|
| 584 |
+
set -e
|
| 585 |
+
|
| 586 |
+
cd /home/{pr.repo}
|
| 587 |
+
git apply --whitespace=nowarn /home/test.patch
|
| 588 |
+
cd build
|
| 589 |
+
cmake ..
|
| 590 |
+
make -j 4
|
| 591 |
+
ctest -j 4
|
| 592 |
+
test/functional/test_runner.py --extended
|
| 593 |
+
|
| 594 |
+
""".format(
|
| 595 |
+
pr=self.pr
|
| 596 |
+
),
|
| 597 |
+
),
|
| 598 |
+
File(
|
| 599 |
+
".",
|
| 600 |
+
"fix-run.sh",
|
| 601 |
+
"""#!/bin/bash
|
| 602 |
+
set -e
|
| 603 |
+
|
| 604 |
+
cd /home/{pr.repo}
|
| 605 |
+
git apply --whitespace=nowarn /home/test.patch /home/fix.patch
|
| 606 |
+
cd build
|
| 607 |
+
cmake ..
|
| 608 |
+
make -j 4
|
| 609 |
+
ctest -j 4
|
| 610 |
+
test/functional/test_runner.py --extended
|
| 611 |
+
|
| 612 |
+
""".format(
|
| 613 |
+
pr=self.pr
|
| 614 |
+
),
|
| 615 |
+
),
|
| 616 |
+
]
|
| 617 |
+
|
| 618 |
+
def dockerfile(self) -> str:
|
| 619 |
+
image = self.dependency()
|
| 620 |
+
name = image.image_name()
|
| 621 |
+
tag = image.image_tag()
|
| 622 |
+
|
| 623 |
+
copy_commands = ""
|
| 624 |
+
for file in self.files():
|
| 625 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 626 |
+
|
| 627 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 628 |
+
|
| 629 |
+
return f"""FROM {name}:{tag}
|
| 630 |
+
|
| 631 |
+
{self.global_env}
|
| 632 |
+
|
| 633 |
+
{copy_commands}
|
| 634 |
+
|
| 635 |
+
{prepare_commands}
|
| 636 |
+
|
| 637 |
+
{self.clear_env}
|
| 638 |
+
|
| 639 |
+
"""
|
| 640 |
+
|
| 641 |
+
|
| 642 |
+
@Instance.register("bitcoin", "bitcoin")
|
| 643 |
+
class Bitcoin(Instance):
|
| 644 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 645 |
+
super().__init__()
|
| 646 |
+
self._pr = pr
|
| 647 |
+
self._config = config
|
| 648 |
+
|
| 649 |
+
@property
|
| 650 |
+
def pr(self) -> PullRequest:
|
| 651 |
+
return self._pr
|
| 652 |
+
|
| 653 |
+
def dependency(self) -> Optional[Image]:
|
| 654 |
+
return BitcoinImageDefault(self.pr, self._config)
|
| 655 |
+
|
| 656 |
+
def run(self, run_cmd: str = "") -> str:
|
| 657 |
+
if run_cmd:
|
| 658 |
+
return run_cmd
|
| 659 |
+
|
| 660 |
+
return "bash /home/run.sh"
|
| 661 |
+
|
| 662 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 663 |
+
if test_patch_run_cmd:
|
| 664 |
+
return test_patch_run_cmd
|
| 665 |
+
|
| 666 |
+
return "bash /home/test-run.sh"
|
| 667 |
+
|
| 668 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 669 |
+
if fix_patch_run_cmd:
|
| 670 |
+
return fix_patch_run_cmd
|
| 671 |
+
|
| 672 |
+
return "bash /home/fix-run.sh"
|
| 673 |
+
|
| 674 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 675 |
+
passed_tests = set()
|
| 676 |
+
failed_tests = set()
|
| 677 |
+
skipped_tests = set()
|
| 678 |
+
|
| 679 |
+
re_pass_tests = [
|
| 680 |
+
re.compile(r"^([\w\-./]+(?:\s+--[\w\-]+)?)\s+\|\s+✓\s+Passed\s+\|")
|
| 681 |
+
]
|
| 682 |
+
re_fail_tests = [
|
| 683 |
+
re.compile(r"^([\w\-./]+(?:\s+--[\w\-]+)?)\s+\|\s+✖\s+Failed\s+\|")
|
| 684 |
+
]
|
| 685 |
+
|
| 686 |
+
for line in test_log.splitlines():
|
| 687 |
+
line = line.strip()
|
| 688 |
+
if not line:
|
| 689 |
+
continue
|
| 690 |
+
|
| 691 |
+
for re_pass_test in re_pass_tests:
|
| 692 |
+
pass_match = re_pass_test.match(line)
|
| 693 |
+
if pass_match:
|
| 694 |
+
test = pass_match.group(1)
|
| 695 |
+
passed_tests.add(test)
|
| 696 |
+
|
| 697 |
+
for re_fail_test in re_fail_tests:
|
| 698 |
+
fail_match = re_fail_test.match(line)
|
| 699 |
+
if fail_match:
|
| 700 |
+
test = fail_match.group(1)
|
| 701 |
+
if test != "ALL":
|
| 702 |
+
failed_tests.add(test)
|
| 703 |
+
|
| 704 |
+
return TestResult(
|
| 705 |
+
passed_count=len(passed_tests),
|
| 706 |
+
failed_count=len(failed_tests),
|
| 707 |
+
skipped_count=len(skipped_tests),
|
| 708 |
+
passed_tests=passed_tests,
|
| 709 |
+
failed_tests=failed_tests,
|
| 710 |
+
skipped_tests=skipped_tests,
|
| 711 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/catchorg/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.eval.harness.repos.cpp.catchorg.catch2 import *
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/catchorg/catch2.py
ADDED
|
@@ -0,0 +1,420 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class Catch2ImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "gcc:latest"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
|
| 50 |
+
{code}
|
| 51 |
+
|
| 52 |
+
RUN apt-get update && apt-get install -y \
|
| 53 |
+
libbrotli-dev \
|
| 54 |
+
libcurl4-openssl-dev \
|
| 55 |
+
clang \
|
| 56 |
+
build-essential \
|
| 57 |
+
cmake \
|
| 58 |
+
python3 \
|
| 59 |
+
python3-dev \
|
| 60 |
+
python3-pip
|
| 61 |
+
|
| 62 |
+
{self.clear_env}
|
| 63 |
+
|
| 64 |
+
"""
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
class Catch2ImageBaseCpp12(Image):
|
| 68 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 69 |
+
self._pr = pr
|
| 70 |
+
self._config = config
|
| 71 |
+
|
| 72 |
+
@property
|
| 73 |
+
def pr(self) -> PullRequest:
|
| 74 |
+
return self._pr
|
| 75 |
+
|
| 76 |
+
@property
|
| 77 |
+
def config(self) -> Config:
|
| 78 |
+
return self._config
|
| 79 |
+
|
| 80 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 81 |
+
return "gcc:12"
|
| 82 |
+
|
| 83 |
+
def image_tag(self) -> str:
|
| 84 |
+
return "base-cpp-12"
|
| 85 |
+
|
| 86 |
+
def workdir(self) -> str:
|
| 87 |
+
return "base-cpp-12"
|
| 88 |
+
|
| 89 |
+
def files(self) -> list[File]:
|
| 90 |
+
return []
|
| 91 |
+
|
| 92 |
+
def dockerfile(self) -> str:
|
| 93 |
+
image_name = self.dependency()
|
| 94 |
+
if isinstance(image_name, Image):
|
| 95 |
+
image_name = image_name.image_full_name()
|
| 96 |
+
|
| 97 |
+
if self.config.need_clone:
|
| 98 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 99 |
+
else:
|
| 100 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 101 |
+
|
| 102 |
+
return f"""FROM {image_name}
|
| 103 |
+
|
| 104 |
+
{self.global_env}
|
| 105 |
+
|
| 106 |
+
WORKDIR /home/
|
| 107 |
+
|
| 108 |
+
{code}
|
| 109 |
+
|
| 110 |
+
RUN apt-get update && apt-get install -y \
|
| 111 |
+
libbrotli-dev \
|
| 112 |
+
libcurl4-openssl-dev \
|
| 113 |
+
clang \
|
| 114 |
+
build-essential \
|
| 115 |
+
cmake \
|
| 116 |
+
python3 \
|
| 117 |
+
python3-dev \
|
| 118 |
+
python3-pip
|
| 119 |
+
|
| 120 |
+
{self.clear_env}
|
| 121 |
+
|
| 122 |
+
"""
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
class Catch2ImageBaseCpp7(Image):
|
| 126 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 127 |
+
self._pr = pr
|
| 128 |
+
self._config = config
|
| 129 |
+
|
| 130 |
+
@property
|
| 131 |
+
def pr(self) -> PullRequest:
|
| 132 |
+
return self._pr
|
| 133 |
+
|
| 134 |
+
@property
|
| 135 |
+
def config(self) -> Config:
|
| 136 |
+
return self._config
|
| 137 |
+
|
| 138 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 139 |
+
return "gcc:7"
|
| 140 |
+
|
| 141 |
+
def image_tag(self) -> str:
|
| 142 |
+
return "base-cpp-7"
|
| 143 |
+
|
| 144 |
+
def workdir(self) -> str:
|
| 145 |
+
return "base-cpp-7"
|
| 146 |
+
|
| 147 |
+
def files(self) -> list[File]:
|
| 148 |
+
return []
|
| 149 |
+
|
| 150 |
+
def dockerfile(self) -> str:
|
| 151 |
+
image_name = self.dependency()
|
| 152 |
+
if isinstance(image_name, Image):
|
| 153 |
+
image_name = image_name.image_full_name()
|
| 154 |
+
|
| 155 |
+
if self.config.need_clone:
|
| 156 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 157 |
+
else:
|
| 158 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 159 |
+
|
| 160 |
+
return f"""FROM {image_name}
|
| 161 |
+
|
| 162 |
+
{self.global_env}
|
| 163 |
+
|
| 164 |
+
WORKDIR /home/
|
| 165 |
+
|
| 166 |
+
{code}
|
| 167 |
+
|
| 168 |
+
RUN apt-get update && apt-get install -y \
|
| 169 |
+
libbrotli-dev \
|
| 170 |
+
libcurl4-openssl-dev \
|
| 171 |
+
clang \
|
| 172 |
+
build-essential \
|
| 173 |
+
cmake \
|
| 174 |
+
python3 \
|
| 175 |
+
python3-dev \
|
| 176 |
+
python3-pip
|
| 177 |
+
|
| 178 |
+
{self.clear_env}
|
| 179 |
+
|
| 180 |
+
"""
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
class Catch2ImageDefault(Image):
|
| 184 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 185 |
+
self._pr = pr
|
| 186 |
+
self._config = config
|
| 187 |
+
|
| 188 |
+
@property
|
| 189 |
+
def pr(self) -> PullRequest:
|
| 190 |
+
return self._pr
|
| 191 |
+
|
| 192 |
+
@property
|
| 193 |
+
def config(self) -> Config:
|
| 194 |
+
return self._config
|
| 195 |
+
|
| 196 |
+
def dependency(self) -> Image | None:
|
| 197 |
+
if 2288 <= self.pr.number and self.pr.number <= 2554:
|
| 198 |
+
return Catch2ImageBaseCpp12(self.pr, self._config)
|
| 199 |
+
elif self.pr.number <= 2187:
|
| 200 |
+
return Catch2ImageBaseCpp7(self.pr, self._config)
|
| 201 |
+
return Catch2ImageBase(self.pr, self._config)
|
| 202 |
+
|
| 203 |
+
def image_tag(self) -> str:
|
| 204 |
+
return f"pr-{self.pr.number}"
|
| 205 |
+
|
| 206 |
+
def workdir(self) -> str:
|
| 207 |
+
return f"pr-{self.pr.number}"
|
| 208 |
+
|
| 209 |
+
def files(self) -> list[File]:
|
| 210 |
+
return [
|
| 211 |
+
File(
|
| 212 |
+
".",
|
| 213 |
+
"fix.patch",
|
| 214 |
+
f"{self.pr.fix_patch}",
|
| 215 |
+
),
|
| 216 |
+
File(
|
| 217 |
+
".",
|
| 218 |
+
"test.patch",
|
| 219 |
+
f"{self.pr.test_patch}",
|
| 220 |
+
),
|
| 221 |
+
File(
|
| 222 |
+
".",
|
| 223 |
+
"check_git_changes.sh",
|
| 224 |
+
"""#!/bin/bash
|
| 225 |
+
set -e
|
| 226 |
+
|
| 227 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 228 |
+
echo "check_git_changes: Not inside a git repository"
|
| 229 |
+
exit 1
|
| 230 |
+
fi
|
| 231 |
+
|
| 232 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 233 |
+
echo "check_git_changes: Uncommitted changes"
|
| 234 |
+
exit 1
|
| 235 |
+
fi
|
| 236 |
+
|
| 237 |
+
echo "check_git_changes: No uncommitted changes"
|
| 238 |
+
exit 0
|
| 239 |
+
|
| 240 |
+
""".format(
|
| 241 |
+
pr=self.pr
|
| 242 |
+
),
|
| 243 |
+
),
|
| 244 |
+
File(
|
| 245 |
+
".",
|
| 246 |
+
"prepare.sh",
|
| 247 |
+
"""#!/bin/bash
|
| 248 |
+
set -e
|
| 249 |
+
|
| 250 |
+
cd /home/{pr.repo}
|
| 251 |
+
git reset --hard
|
| 252 |
+
bash /home/check_git_changes.sh
|
| 253 |
+
git checkout {pr.base.sha}
|
| 254 |
+
bash /home/check_git_changes.sh
|
| 255 |
+
|
| 256 |
+
mkdir build
|
| 257 |
+
|
| 258 |
+
""".format(
|
| 259 |
+
pr=self.pr
|
| 260 |
+
),
|
| 261 |
+
),
|
| 262 |
+
File(
|
| 263 |
+
".",
|
| 264 |
+
"run.sh",
|
| 265 |
+
"""#!/bin/bash
|
| 266 |
+
set -e
|
| 267 |
+
|
| 268 |
+
cd /home/{pr.repo}
|
| 269 |
+
cd build
|
| 270 |
+
cmake -DCATCH_DEVELOPMENT_BUILD=ON ..
|
| 271 |
+
make
|
| 272 |
+
ctest
|
| 273 |
+
""".format(
|
| 274 |
+
pr=self.pr
|
| 275 |
+
),
|
| 276 |
+
),
|
| 277 |
+
File(
|
| 278 |
+
".",
|
| 279 |
+
"test-run.sh",
|
| 280 |
+
"""#!/bin/bash
|
| 281 |
+
set -e
|
| 282 |
+
|
| 283 |
+
cd /home/{pr.repo}
|
| 284 |
+
git apply --whitespace=nowarn /home/test.patch
|
| 285 |
+
cd build
|
| 286 |
+
cmake -DCATCH_DEVELOPMENT_BUILD=ON ..
|
| 287 |
+
make
|
| 288 |
+
ctest
|
| 289 |
+
|
| 290 |
+
""".format(
|
| 291 |
+
pr=self.pr
|
| 292 |
+
),
|
| 293 |
+
),
|
| 294 |
+
File(
|
| 295 |
+
".",
|
| 296 |
+
"fix-run.sh",
|
| 297 |
+
"""#!/bin/bash
|
| 298 |
+
set -e
|
| 299 |
+
|
| 300 |
+
cd /home/{pr.repo}
|
| 301 |
+
git apply --whitespace=nowarn /home/test.patch /home/fix.patch
|
| 302 |
+
cd build
|
| 303 |
+
cmake -DCATCH_DEVELOPMENT_BUILD=ON ..
|
| 304 |
+
make
|
| 305 |
+
ctest
|
| 306 |
+
|
| 307 |
+
""".format(
|
| 308 |
+
pr=self.pr
|
| 309 |
+
),
|
| 310 |
+
),
|
| 311 |
+
]
|
| 312 |
+
|
| 313 |
+
def dockerfile(self) -> str:
|
| 314 |
+
image = self.dependency()
|
| 315 |
+
name = image.image_name()
|
| 316 |
+
tag = image.image_tag()
|
| 317 |
+
|
| 318 |
+
copy_commands = ""
|
| 319 |
+
for file in self.files():
|
| 320 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 321 |
+
|
| 322 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 323 |
+
|
| 324 |
+
return f"""FROM {name}:{tag}
|
| 325 |
+
|
| 326 |
+
{self.global_env}
|
| 327 |
+
|
| 328 |
+
{copy_commands}
|
| 329 |
+
|
| 330 |
+
{prepare_commands}
|
| 331 |
+
|
| 332 |
+
{self.clear_env}
|
| 333 |
+
|
| 334 |
+
"""
|
| 335 |
+
|
| 336 |
+
|
| 337 |
+
@Instance.register("catchorg", "Catch2")
|
| 338 |
+
class Catch2(Instance):
|
| 339 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 340 |
+
super().__init__()
|
| 341 |
+
self._pr = pr
|
| 342 |
+
self._config = config
|
| 343 |
+
|
| 344 |
+
@property
|
| 345 |
+
def pr(self) -> PullRequest:
|
| 346 |
+
return self._pr
|
| 347 |
+
|
| 348 |
+
def dependency(self) -> Optional[Image]:
|
| 349 |
+
return Catch2ImageDefault(self.pr, self._config)
|
| 350 |
+
|
| 351 |
+
def run(self, run_cmd: str = "") -> str:
|
| 352 |
+
if run_cmd:
|
| 353 |
+
return run_cmd
|
| 354 |
+
|
| 355 |
+
return "bash /home/run.sh"
|
| 356 |
+
|
| 357 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 358 |
+
if test_patch_run_cmd:
|
| 359 |
+
return test_patch_run_cmd
|
| 360 |
+
|
| 361 |
+
return "bash /home/test-run.sh"
|
| 362 |
+
|
| 363 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 364 |
+
if fix_patch_run_cmd:
|
| 365 |
+
return fix_patch_run_cmd
|
| 366 |
+
|
| 367 |
+
return "bash /home/fix-run.sh"
|
| 368 |
+
|
| 369 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 370 |
+
passed_tests = set()
|
| 371 |
+
failed_tests = set()
|
| 372 |
+
skipped_tests = set()
|
| 373 |
+
|
| 374 |
+
re_passes = [
|
| 375 |
+
re.compile(r"^-- Performing Test (.+) - Success$", re.IGNORECASE),
|
| 376 |
+
re.compile(
|
| 377 |
+
r"^\d+/\d+ Test\s+#\d+: (.+) \.+\s+ Passed\s+.+$", re.IGNORECASE
|
| 378 |
+
),
|
| 379 |
+
]
|
| 380 |
+
re_fails = [
|
| 381 |
+
re.compile(r"^-- Performing Test (.+) - Failed$", re.IGNORECASE),
|
| 382 |
+
re.compile(
|
| 383 |
+
r"^\d+/\d+ Test\s+#\d+: (.+) \.+\*\*\*Failed\s+.+$", re.IGNORECASE
|
| 384 |
+
),
|
| 385 |
+
]
|
| 386 |
+
re_skips = [
|
| 387 |
+
re.compile(r"^-- Performing Test (.+) - skipped$", re.IGNORECASE),
|
| 388 |
+
]
|
| 389 |
+
|
| 390 |
+
for line in test_log.splitlines():
|
| 391 |
+
line = line.strip().lower()
|
| 392 |
+
if not line:
|
| 393 |
+
continue
|
| 394 |
+
|
| 395 |
+
for re_pass in re_passes:
|
| 396 |
+
pass_match = re_pass.match(line)
|
| 397 |
+
if pass_match:
|
| 398 |
+
test = pass_match.group(1)
|
| 399 |
+
passed_tests.add(test)
|
| 400 |
+
|
| 401 |
+
for re_fail in re_fails:
|
| 402 |
+
fail_match = re_fail.match(line)
|
| 403 |
+
if fail_match:
|
| 404 |
+
test = fail_match.group(1)
|
| 405 |
+
failed_tests.add(test)
|
| 406 |
+
|
| 407 |
+
for re_skip in re_skips:
|
| 408 |
+
skip_match = re_skip.match(line)
|
| 409 |
+
if skip_match:
|
| 410 |
+
test = skip_match.group(1)
|
| 411 |
+
skipped_tests.add(test)
|
| 412 |
+
|
| 413 |
+
return TestResult(
|
| 414 |
+
passed_count=len(passed_tests),
|
| 415 |
+
failed_count=len(failed_tests),
|
| 416 |
+
skipped_count=len(skipped_tests),
|
| 417 |
+
passed_tests=passed_tests,
|
| 418 |
+
failed_tests=failed_tests,
|
| 419 |
+
skipped_tests=skipped_tests,
|
| 420 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/cgal/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.eval.harness.repos.cpp.cgal.cgal import *
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/cgal/cgal.py
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class CgalImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "ubuntu:22.04"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 50 |
+
ENV TZ=Etc/UTC
|
| 51 |
+
RUN apt-get update && apt-get install -y clang wget sudo git build-essential pkg-config tar tzdata cmake
|
| 52 |
+
RUN apt-get install -y libboost-dev libboost-program-options-dev libmpfr-dev libeigen3-dev
|
| 53 |
+
RUN apt-get install -y libmpfr-dev \
|
| 54 |
+
libeigen3-dev qtbase5-dev libqt5sql5-sqlite libqt5opengl5-dev qtscript5-dev \
|
| 55 |
+
libqt5svg5-dev qttools5-dev qttools5-dev-tools libboost-dev libinsighttoolkit5-dev zsh
|
| 56 |
+
|
| 57 |
+
{code}
|
| 58 |
+
|
| 59 |
+
{self.clear_env}
|
| 60 |
+
|
| 61 |
+
"""
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
class CgalImageDefault(Image):
|
| 65 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 66 |
+
self._pr = pr
|
| 67 |
+
self._config = config
|
| 68 |
+
|
| 69 |
+
@property
|
| 70 |
+
def pr(self) -> PullRequest:
|
| 71 |
+
return self._pr
|
| 72 |
+
|
| 73 |
+
@property
|
| 74 |
+
def config(self) -> Config:
|
| 75 |
+
return self._config
|
| 76 |
+
|
| 77 |
+
def dependency(self) -> Image | None:
|
| 78 |
+
return CgalImageBase(self.pr, self._config)
|
| 79 |
+
|
| 80 |
+
def image_tag(self) -> str:
|
| 81 |
+
return f"pr-{self.pr.number}"
|
| 82 |
+
|
| 83 |
+
def workdir(self) -> str:
|
| 84 |
+
return f"pr-{self.pr.number}"
|
| 85 |
+
|
| 86 |
+
def files(self) -> list[File]:
|
| 87 |
+
return [
|
| 88 |
+
File(
|
| 89 |
+
".",
|
| 90 |
+
"fix.patch",
|
| 91 |
+
f"{self.pr.fix_patch}",
|
| 92 |
+
),
|
| 93 |
+
File(
|
| 94 |
+
".",
|
| 95 |
+
"test.patch",
|
| 96 |
+
f"{self.pr.test_patch}",
|
| 97 |
+
),
|
| 98 |
+
File(
|
| 99 |
+
".",
|
| 100 |
+
"check_git_changes.sh",
|
| 101 |
+
"""#!/bin/bash
|
| 102 |
+
set -e
|
| 103 |
+
|
| 104 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 105 |
+
echo "check_git_changes: Not inside a git repository"
|
| 106 |
+
exit 1
|
| 107 |
+
fi
|
| 108 |
+
|
| 109 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 110 |
+
echo "check_git_changes: Uncommitted changes"
|
| 111 |
+
exit 1
|
| 112 |
+
fi
|
| 113 |
+
|
| 114 |
+
echo "check_git_changes: No uncommitted changes"
|
| 115 |
+
exit 0
|
| 116 |
+
|
| 117 |
+
""".format(
|
| 118 |
+
pr=self.pr
|
| 119 |
+
),
|
| 120 |
+
),
|
| 121 |
+
File(
|
| 122 |
+
".",
|
| 123 |
+
"prepare.sh",
|
| 124 |
+
"""#!/bin/bash
|
| 125 |
+
set -e
|
| 126 |
+
|
| 127 |
+
cd /home/{pr.repo}
|
| 128 |
+
git reset --hard
|
| 129 |
+
bash /home/check_git_changes.sh
|
| 130 |
+
git checkout {pr.base.sha}
|
| 131 |
+
bash /home/check_git_changes.sh
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
""".format(
|
| 135 |
+
pr=self.pr
|
| 136 |
+
),
|
| 137 |
+
),
|
| 138 |
+
File(
|
| 139 |
+
".",
|
| 140 |
+
"run.sh",
|
| 141 |
+
"""#!/bin/bash
|
| 142 |
+
set -e
|
| 143 |
+
|
| 144 |
+
cd /home/{pr.repo}
|
| 145 |
+
set -e
|
| 146 |
+
mkdir build && cd build && CXX=clang++ cmake -DWITH_examples=ON -DWITH_tests=ON -DWITH_demos=ON -DBUILD_TESTING=ON ..
|
| 147 |
+
ctest -j 8
|
| 148 |
+
|
| 149 |
+
""".format(
|
| 150 |
+
pr=self.pr
|
| 151 |
+
),
|
| 152 |
+
),
|
| 153 |
+
File(
|
| 154 |
+
".",
|
| 155 |
+
"test-run.sh",
|
| 156 |
+
"""#!/bin/bash
|
| 157 |
+
set -e
|
| 158 |
+
|
| 159 |
+
cd /home/{pr.repo}
|
| 160 |
+
git apply --whitespace=nowarn /home/test.patch
|
| 161 |
+
set -e
|
| 162 |
+
mkdir build && cd build && CXX=clang++ cmake -DWITH_examples=ON -DWITH_tests=ON -DWITH_demos=ON -DBUILD_TESTING=ON ..
|
| 163 |
+
ctest -j 8
|
| 164 |
+
|
| 165 |
+
""".format(
|
| 166 |
+
pr=self.pr
|
| 167 |
+
),
|
| 168 |
+
),
|
| 169 |
+
File(
|
| 170 |
+
".",
|
| 171 |
+
"fix-run.sh",
|
| 172 |
+
"""#!/bin/bash
|
| 173 |
+
set -e
|
| 174 |
+
|
| 175 |
+
cd /home/{pr.repo}
|
| 176 |
+
git apply --whitespace=nowarn /home/test.patch /home/fix.patch
|
| 177 |
+
set -e
|
| 178 |
+
mkdir build && cd build && CXX=clang++ cmake -DWITH_examples=ON -DWITH_tests=ON -DWITH_demos=ON -DBUILD_TESTING=ON ..
|
| 179 |
+
ctest -j 8
|
| 180 |
+
|
| 181 |
+
""".format(
|
| 182 |
+
pr=self.pr
|
| 183 |
+
),
|
| 184 |
+
),
|
| 185 |
+
]
|
| 186 |
+
|
| 187 |
+
def dockerfile(self) -> str:
|
| 188 |
+
image = self.dependency()
|
| 189 |
+
name = image.image_name()
|
| 190 |
+
tag = image.image_tag()
|
| 191 |
+
|
| 192 |
+
copy_commands = ""
|
| 193 |
+
for file in self.files():
|
| 194 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 195 |
+
|
| 196 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 197 |
+
|
| 198 |
+
return f"""FROM {name}:{tag}
|
| 199 |
+
|
| 200 |
+
{self.global_env}
|
| 201 |
+
|
| 202 |
+
{copy_commands}
|
| 203 |
+
|
| 204 |
+
{prepare_commands}
|
| 205 |
+
|
| 206 |
+
{self.clear_env}
|
| 207 |
+
|
| 208 |
+
"""
|
| 209 |
+
|
| 210 |
+
|
| 211 |
+
@Instance.register("CGAL", "cgal")
|
| 212 |
+
class Cgal(Instance):
|
| 213 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 214 |
+
super().__init__()
|
| 215 |
+
self._pr = pr
|
| 216 |
+
self._config = config
|
| 217 |
+
|
| 218 |
+
@property
|
| 219 |
+
def pr(self) -> PullRequest:
|
| 220 |
+
return self._pr
|
| 221 |
+
|
| 222 |
+
def dependency(self) -> Optional[Image]:
|
| 223 |
+
return CgalImageDefault(self.pr, self._config)
|
| 224 |
+
|
| 225 |
+
def run(self, run_cmd: str = "") -> str:
|
| 226 |
+
if run_cmd:
|
| 227 |
+
return run_cmd
|
| 228 |
+
|
| 229 |
+
return "bash /home/run.sh"
|
| 230 |
+
|
| 231 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 232 |
+
if test_patch_run_cmd:
|
| 233 |
+
return test_patch_run_cmd
|
| 234 |
+
|
| 235 |
+
return "bash /home/test-run.sh"
|
| 236 |
+
|
| 237 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 238 |
+
if fix_patch_run_cmd:
|
| 239 |
+
return fix_patch_run_cmd
|
| 240 |
+
|
| 241 |
+
return "bash /home/fix-run.sh"
|
| 242 |
+
|
| 243 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 244 |
+
passed_tests = set()
|
| 245 |
+
failed_tests = set()
|
| 246 |
+
skipped_tests = set()
|
| 247 |
+
|
| 248 |
+
re_pass_tests = [re.compile(r"^\d+/\d+\s*Test\s*#\d+:\s*(.*?)\s*\.+\s*Passed")]
|
| 249 |
+
re_fail_tests = [
|
| 250 |
+
re.compile(r"^\d+/\d+\s*Test\s*#\d+:\s*(.*?)\s*\.+\s*\*+Failed")
|
| 251 |
+
]
|
| 252 |
+
|
| 253 |
+
for line in test_log.splitlines():
|
| 254 |
+
line = line.strip()
|
| 255 |
+
if not line:
|
| 256 |
+
continue
|
| 257 |
+
|
| 258 |
+
for re_pass_test in re_pass_tests:
|
| 259 |
+
pass_match = re_pass_test.match(line)
|
| 260 |
+
if pass_match:
|
| 261 |
+
test = pass_match.group(1)
|
| 262 |
+
passed_tests.add(test)
|
| 263 |
+
|
| 264 |
+
for re_fail_test in re_fail_tests:
|
| 265 |
+
fail_match = re_fail_test.match(line)
|
| 266 |
+
if fail_match:
|
| 267 |
+
test = fail_match.group(1)
|
| 268 |
+
failed_tests.add(test)
|
| 269 |
+
|
| 270 |
+
return TestResult(
|
| 271 |
+
passed_count=len(passed_tests),
|
| 272 |
+
failed_count=len(failed_tests),
|
| 273 |
+
skipped_count=len(skipped_tests),
|
| 274 |
+
passed_tests=passed_tests,
|
| 275 |
+
failed_tests=failed_tests,
|
| 276 |
+
skipped_tests=skipped_tests,
|
| 277 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/fmtlib/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.eval.harness.repos.cpp.fmtlib.fmt import *
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class ImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "gcc:latest"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 50 |
+
ENV LANG=C.UTF-8
|
| 51 |
+
ENV LC_ALL=C.UTF-8
|
| 52 |
+
RUN apt-get update && apt-get install -y cmake
|
| 53 |
+
|
| 54 |
+
{code}
|
| 55 |
+
|
| 56 |
+
{self.clear_env}
|
| 57 |
+
|
| 58 |
+
"""
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
class ImageDefault(Image):
|
| 62 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 63 |
+
self._pr = pr
|
| 64 |
+
self._config = config
|
| 65 |
+
|
| 66 |
+
@property
|
| 67 |
+
def pr(self) -> PullRequest:
|
| 68 |
+
return self._pr
|
| 69 |
+
|
| 70 |
+
@property
|
| 71 |
+
def config(self) -> Config:
|
| 72 |
+
return self._config
|
| 73 |
+
|
| 74 |
+
def dependency(self) -> Image | None:
|
| 75 |
+
return ImageBase(self.pr, self._config)
|
| 76 |
+
|
| 77 |
+
def image_tag(self) -> str:
|
| 78 |
+
return f"pr-{self.pr.number}"
|
| 79 |
+
|
| 80 |
+
def workdir(self) -> str:
|
| 81 |
+
return f"pr-{self.pr.number}"
|
| 82 |
+
|
| 83 |
+
def files(self) -> list[File]:
|
| 84 |
+
return [
|
| 85 |
+
File(
|
| 86 |
+
".",
|
| 87 |
+
"fix.patch",
|
| 88 |
+
f"{self.pr.fix_patch}",
|
| 89 |
+
),
|
| 90 |
+
File(
|
| 91 |
+
".",
|
| 92 |
+
"test.patch",
|
| 93 |
+
f"{self.pr.test_patch}",
|
| 94 |
+
),
|
| 95 |
+
File(
|
| 96 |
+
".",
|
| 97 |
+
"check_git_changes.sh",
|
| 98 |
+
"""#!/bin/bash
|
| 99 |
+
set -e
|
| 100 |
+
|
| 101 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 102 |
+
echo "check_git_changes: Not inside a git repository"
|
| 103 |
+
exit 1
|
| 104 |
+
fi
|
| 105 |
+
|
| 106 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 107 |
+
echo "check_git_changes: Uncommitted changes"
|
| 108 |
+
exit 1
|
| 109 |
+
fi
|
| 110 |
+
|
| 111 |
+
echo "check_git_changes: No uncommitted changes"
|
| 112 |
+
exit 0
|
| 113 |
+
|
| 114 |
+
""".format(
|
| 115 |
+
pr=self.pr
|
| 116 |
+
),
|
| 117 |
+
),
|
| 118 |
+
File(
|
| 119 |
+
".",
|
| 120 |
+
"prepare.sh",
|
| 121 |
+
"""#!/bin/bash
|
| 122 |
+
set -e
|
| 123 |
+
|
| 124 |
+
cd /home/{pr.repo}
|
| 125 |
+
git reset --hard
|
| 126 |
+
bash /home/check_git_changes.sh
|
| 127 |
+
git checkout {pr.base.sha}
|
| 128 |
+
bash /home/check_git_changes.sh
|
| 129 |
+
mkdir build || true
|
| 130 |
+
|
| 131 |
+
""".format(
|
| 132 |
+
pr=self.pr
|
| 133 |
+
),
|
| 134 |
+
),
|
| 135 |
+
File(
|
| 136 |
+
".",
|
| 137 |
+
"run.sh",
|
| 138 |
+
"""#!/bin/bash
|
| 139 |
+
set -e
|
| 140 |
+
|
| 141 |
+
cd /home/{pr.repo}
|
| 142 |
+
cd build
|
| 143 |
+
cmake ..
|
| 144 |
+
cmake --build .
|
| 145 |
+
ctest
|
| 146 |
+
""".format(
|
| 147 |
+
pr=self.pr
|
| 148 |
+
),
|
| 149 |
+
),
|
| 150 |
+
File(
|
| 151 |
+
".",
|
| 152 |
+
"test-run.sh",
|
| 153 |
+
"""#!/bin/bash
|
| 154 |
+
set -e
|
| 155 |
+
|
| 156 |
+
cd /home/{pr.repo}
|
| 157 |
+
git apply --whitespace=nowarn /home/test.patch
|
| 158 |
+
cd build
|
| 159 |
+
cmake ..
|
| 160 |
+
cmake --build .
|
| 161 |
+
ctest
|
| 162 |
+
|
| 163 |
+
""".format(
|
| 164 |
+
pr=self.pr
|
| 165 |
+
),
|
| 166 |
+
),
|
| 167 |
+
File(
|
| 168 |
+
".",
|
| 169 |
+
"fix-run.sh",
|
| 170 |
+
"""#!/bin/bash
|
| 171 |
+
set -e
|
| 172 |
+
|
| 173 |
+
cd /home/{pr.repo}
|
| 174 |
+
git apply --whitespace=nowarn /home/test.patch /home/fix.patch
|
| 175 |
+
cd build
|
| 176 |
+
cmake ..
|
| 177 |
+
cmake --build .
|
| 178 |
+
ctest
|
| 179 |
+
|
| 180 |
+
""".format(
|
| 181 |
+
pr=self.pr
|
| 182 |
+
),
|
| 183 |
+
),
|
| 184 |
+
]
|
| 185 |
+
|
| 186 |
+
def dockerfile(self) -> str:
|
| 187 |
+
image = self.dependency()
|
| 188 |
+
name = image.image_name()
|
| 189 |
+
tag = image.image_tag()
|
| 190 |
+
|
| 191 |
+
copy_commands = ""
|
| 192 |
+
for file in self.files():
|
| 193 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 194 |
+
|
| 195 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 196 |
+
|
| 197 |
+
return f"""FROM {name}:{tag}
|
| 198 |
+
|
| 199 |
+
{self.global_env}
|
| 200 |
+
|
| 201 |
+
{copy_commands}
|
| 202 |
+
|
| 203 |
+
{prepare_commands}
|
| 204 |
+
|
| 205 |
+
{self.clear_env}
|
| 206 |
+
|
| 207 |
+
"""
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
@Instance.register("fmtlib", "fmt")
|
| 211 |
+
class Fmt(Instance):
|
| 212 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 213 |
+
super().__init__()
|
| 214 |
+
self._pr = pr
|
| 215 |
+
self._config = config
|
| 216 |
+
|
| 217 |
+
@property
|
| 218 |
+
def pr(self) -> PullRequest:
|
| 219 |
+
return self._pr
|
| 220 |
+
|
| 221 |
+
def dependency(self) -> Optional[Image]:
|
| 222 |
+
return ImageDefault(self.pr, self._config)
|
| 223 |
+
|
| 224 |
+
def run(self, run_cmd: str = "") -> str:
|
| 225 |
+
if run_cmd:
|
| 226 |
+
return run_cmd
|
| 227 |
+
|
| 228 |
+
return "bash /home/run.sh"
|
| 229 |
+
|
| 230 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 231 |
+
if test_patch_run_cmd:
|
| 232 |
+
return test_patch_run_cmd
|
| 233 |
+
|
| 234 |
+
return "bash /home/test-run.sh"
|
| 235 |
+
|
| 236 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 237 |
+
if fix_patch_run_cmd:
|
| 238 |
+
return fix_patch_run_cmd
|
| 239 |
+
|
| 240 |
+
return "bash /home/fix-run.sh"
|
| 241 |
+
|
| 242 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 243 |
+
passed_tests = set()
|
| 244 |
+
failed_tests = set()
|
| 245 |
+
skipped_tests = set()
|
| 246 |
+
|
| 247 |
+
re_pass_tests = [re.compile(r"^\d+/\d+\s*Test\s*#\d+:\s*(.*?)\s*\.+\s*Passed")]
|
| 248 |
+
re_fail_tests = [
|
| 249 |
+
re.compile(r"^\d+/\d+\s*Test\s*#\d+:\s*(.*?)\s*\.+\s*\*+Failed$")
|
| 250 |
+
]
|
| 251 |
+
|
| 252 |
+
for line in test_log.splitlines():
|
| 253 |
+
line = line.strip()
|
| 254 |
+
if not line:
|
| 255 |
+
continue
|
| 256 |
+
|
| 257 |
+
for re_pass_test in re_pass_tests:
|
| 258 |
+
pass_match = re_pass_test.match(line)
|
| 259 |
+
if pass_match:
|
| 260 |
+
test = pass_match.group(1)
|
| 261 |
+
passed_tests.add(test)
|
| 262 |
+
|
| 263 |
+
for re_fail_test in re_fail_tests:
|
| 264 |
+
fail_match = re_fail_test.match(line)
|
| 265 |
+
if fail_match:
|
| 266 |
+
test = fail_match.group(1)
|
| 267 |
+
failed_tests.add(test)
|
| 268 |
+
|
| 269 |
+
return TestResult(
|
| 270 |
+
passed_count=len(passed_tests),
|
| 271 |
+
failed_count=len(failed_tests),
|
| 272 |
+
skipped_count=len(skipped_tests),
|
| 273 |
+
passed_tests=passed_tests,
|
| 274 |
+
failed_tests=failed_tests,
|
| 275 |
+
skipped_tests=skipped_tests,
|
| 276 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/halide/Halide.py
ADDED
|
@@ -0,0 +1,475 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class HalideImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "gcc:latest"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 50 |
+
ENV TZ=Etc/UTC
|
| 51 |
+
RUN wget https://cmake.org/files/v3.28/cmake-3.28.0-linux-x86_64.tar.gz && \
|
| 52 |
+
tar -zxvf cmake-3.28.0-linux-x86_64.tar.gz && \
|
| 53 |
+
mv cmake-3.28.0-linux-x86_64 /opt/cmake && \
|
| 54 |
+
ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake && \
|
| 55 |
+
rm cmake-3.28.0-linux-x86_64.tar.gz
|
| 56 |
+
RUN wget https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.4/clang+llvm-17.0.4-x86_64-linux-gnu-ubuntu-22.04.tar.xz && \
|
| 57 |
+
tar -xf clang+llvm-17.0.4-x86_64-linux-gnu-ubuntu-22.04.tar.xz && mv clang+llvm-17.0.4-x86_64-linux-gnu-ubuntu-22.04 /usr/local/llvm-17 && echo 'export PATH=/usr/local/llvm-17/bin:$PATH' >> ~/.bashrc && . ~/.bashrc
|
| 58 |
+
RUN apt-get update && apt-get install -y clang-tools lld llvm-dev libclang-dev liblld-dev \
|
| 59 |
+
libpng-dev libjpeg-dev libgl-dev python3-dev python3-numpy python3-scipy \
|
| 60 |
+
python3-imageio python3-pybind11 libopenblas-dev libeigen3-dev cmake
|
| 61 |
+
|
| 62 |
+
{code}
|
| 63 |
+
|
| 64 |
+
{self.clear_env}
|
| 65 |
+
|
| 66 |
+
"""
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
class HalideImageBaseGCC11(Image):
|
| 70 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 71 |
+
self._pr = pr
|
| 72 |
+
self._config = config
|
| 73 |
+
|
| 74 |
+
@property
|
| 75 |
+
def pr(self) -> PullRequest:
|
| 76 |
+
return self._pr
|
| 77 |
+
|
| 78 |
+
@property
|
| 79 |
+
def config(self) -> Config:
|
| 80 |
+
return self._config
|
| 81 |
+
|
| 82 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 83 |
+
return "gcc:11"
|
| 84 |
+
|
| 85 |
+
def image_tag(self) -> str:
|
| 86 |
+
return "base-gcc-11"
|
| 87 |
+
|
| 88 |
+
def workdir(self) -> str:
|
| 89 |
+
return "base-gcc-11"
|
| 90 |
+
|
| 91 |
+
def files(self) -> list[File]:
|
| 92 |
+
return []
|
| 93 |
+
|
| 94 |
+
def dockerfile(self) -> str:
|
| 95 |
+
image_name = self.dependency()
|
| 96 |
+
if isinstance(image_name, Image):
|
| 97 |
+
image_name = image_name.image_full_name()
|
| 98 |
+
|
| 99 |
+
if self.config.need_clone:
|
| 100 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 101 |
+
else:
|
| 102 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 103 |
+
|
| 104 |
+
return f"""FROM {image_name}
|
| 105 |
+
|
| 106 |
+
{self.global_env}
|
| 107 |
+
|
| 108 |
+
WORKDIR /home/
|
| 109 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 110 |
+
ENV TZ=Etc/UTC
|
| 111 |
+
RUN wget https://cmake.org/files/v3.22/cmake-3.22.0-linux-x86_64.tar.gz && \
|
| 112 |
+
tar -zxvf cmake-3.22.0-linux-x86_64.tar.gz && \
|
| 113 |
+
mv cmake-3.22.0-linux-x86_64 /opt/cmake && \
|
| 114 |
+
ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake && \
|
| 115 |
+
rm cmake-3.22.0-linux-x86_64.tar.gz
|
| 116 |
+
|
| 117 |
+
RUN apt update && apt install -y lsb-release software-properties-common gnupg
|
| 118 |
+
RUN wget https://apt.llvm.org/llvm.sh && \
|
| 119 |
+
chmod +x llvm.sh && \
|
| 120 |
+
./llvm.sh 14 all && \
|
| 121 |
+
apt autoremove
|
| 122 |
+
|
| 123 |
+
RUN apt install -y libpng-dev libjpeg-dev libgl-dev python3-dev python3-numpy python3-scipy \
|
| 124 |
+
python3-imageio python3-pybind11 libopenblas-dev libeigen3-dev cmake
|
| 125 |
+
|
| 126 |
+
{code}
|
| 127 |
+
|
| 128 |
+
{self.clear_env}
|
| 129 |
+
|
| 130 |
+
"""
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
class HalideImageBaseGCC11V2(Image):
|
| 134 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 135 |
+
self._pr = pr
|
| 136 |
+
self._config = config
|
| 137 |
+
|
| 138 |
+
@property
|
| 139 |
+
def pr(self) -> PullRequest:
|
| 140 |
+
return self._pr
|
| 141 |
+
|
| 142 |
+
@property
|
| 143 |
+
def config(self) -> Config:
|
| 144 |
+
return self._config
|
| 145 |
+
|
| 146 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 147 |
+
return "gcc:11"
|
| 148 |
+
|
| 149 |
+
def image_tag(self) -> str:
|
| 150 |
+
return "base-gcc-11-V2"
|
| 151 |
+
|
| 152 |
+
def workdir(self) -> str:
|
| 153 |
+
return "base-gcc-11-V2"
|
| 154 |
+
|
| 155 |
+
def files(self) -> list[File]:
|
| 156 |
+
return []
|
| 157 |
+
|
| 158 |
+
def dockerfile(self) -> str:
|
| 159 |
+
image_name = self.dependency()
|
| 160 |
+
if isinstance(image_name, Image):
|
| 161 |
+
image_name = image_name.image_full_name()
|
| 162 |
+
|
| 163 |
+
if self.config.need_clone:
|
| 164 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 165 |
+
else:
|
| 166 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 167 |
+
|
| 168 |
+
return f"""FROM {image_name}
|
| 169 |
+
|
| 170 |
+
{self.global_env}
|
| 171 |
+
|
| 172 |
+
WORKDIR /home/
|
| 173 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 174 |
+
ENV TZ=Etc/UTC
|
| 175 |
+
RUN apt update && apt install -y --fix-missing clang-tools lld llvm-dev libclang-dev \
|
| 176 |
+
libpng-dev libjpeg-dev libgl-dev \
|
| 177 |
+
python3-dev python3-numpy python3-scipy python3-imageio python3-pybind11 \
|
| 178 |
+
libopenblas-dev libeigen3-dev libatlas-base-dev \
|
| 179 |
+
doxygen ninja-build cmake
|
| 180 |
+
|
| 181 |
+
{code}
|
| 182 |
+
|
| 183 |
+
{self.clear_env}
|
| 184 |
+
|
| 185 |
+
"""
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
class HalideImageBaseU20(Image):
|
| 189 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 190 |
+
self._pr = pr
|
| 191 |
+
self._config = config
|
| 192 |
+
|
| 193 |
+
@property
|
| 194 |
+
def pr(self) -> PullRequest:
|
| 195 |
+
return self._pr
|
| 196 |
+
|
| 197 |
+
@property
|
| 198 |
+
def config(self) -> Config:
|
| 199 |
+
return self._config
|
| 200 |
+
|
| 201 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 202 |
+
return "ubuntu:20.04"
|
| 203 |
+
|
| 204 |
+
def image_tag(self) -> str:
|
| 205 |
+
return "base-ubuntu-20"
|
| 206 |
+
|
| 207 |
+
def workdir(self) -> str:
|
| 208 |
+
return "base-ubuntu-20"
|
| 209 |
+
|
| 210 |
+
def files(self) -> list[File]:
|
| 211 |
+
return []
|
| 212 |
+
|
| 213 |
+
def dockerfile(self) -> str:
|
| 214 |
+
image_name = self.dependency()
|
| 215 |
+
if isinstance(image_name, Image):
|
| 216 |
+
image_name = image_name.image_full_name()
|
| 217 |
+
|
| 218 |
+
if self.config.need_clone:
|
| 219 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 220 |
+
else:
|
| 221 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 222 |
+
|
| 223 |
+
return f"""FROM {image_name}
|
| 224 |
+
|
| 225 |
+
{self.global_env}
|
| 226 |
+
|
| 227 |
+
WORKDIR /home/
|
| 228 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 229 |
+
ENV TZ=Etc/UTC
|
| 230 |
+
RUN apt update && apt install -y --fix-missing git clang-tools lld llvm-dev libclang-dev liblld-10-dev \
|
| 231 |
+
libpng-dev libjpeg-dev libgl-dev \
|
| 232 |
+
python3-dev python3-numpy python3-scipy python3-imageio python3-pybind11 \
|
| 233 |
+
libopenblas-dev libeigen3-dev libatlas-base-dev \
|
| 234 |
+
doxygen ninja-build cmake
|
| 235 |
+
{code}
|
| 236 |
+
|
| 237 |
+
{self.clear_env}
|
| 238 |
+
|
| 239 |
+
"""
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
class HalideImageDefault(Image):
|
| 243 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 244 |
+
self._pr = pr
|
| 245 |
+
self._config = config
|
| 246 |
+
|
| 247 |
+
@property
|
| 248 |
+
def pr(self) -> PullRequest:
|
| 249 |
+
return self._pr
|
| 250 |
+
|
| 251 |
+
@property
|
| 252 |
+
def config(self) -> Config:
|
| 253 |
+
return self._config
|
| 254 |
+
|
| 255 |
+
def dependency(self) -> Image | None:
|
| 256 |
+
if 6626 <= self.pr.number <= 7557:
|
| 257 |
+
return HalideImageBaseGCC11(self.pr, self._config)
|
| 258 |
+
elif 5626 < self.pr.number <= 6533:
|
| 259 |
+
return HalideImageBaseGCC11V2(self.pr, self._config)
|
| 260 |
+
elif self.pr.number <= 5626:
|
| 261 |
+
return HalideImageBaseU20(self.pr, self._config)
|
| 262 |
+
return HalideImageBase(self.pr, self._config)
|
| 263 |
+
|
| 264 |
+
def image_tag(self) -> str:
|
| 265 |
+
return f"pr-{self.pr.number}"
|
| 266 |
+
|
| 267 |
+
def workdir(self) -> str:
|
| 268 |
+
return f"pr-{self.pr.number}"
|
| 269 |
+
|
| 270 |
+
def files(self) -> list[File]:
|
| 271 |
+
return [
|
| 272 |
+
File(
|
| 273 |
+
".",
|
| 274 |
+
"fix.patch",
|
| 275 |
+
f"{self.pr.fix_patch}",
|
| 276 |
+
),
|
| 277 |
+
File(
|
| 278 |
+
".",
|
| 279 |
+
"test.patch",
|
| 280 |
+
f"{self.pr.test_patch}",
|
| 281 |
+
),
|
| 282 |
+
File(
|
| 283 |
+
".",
|
| 284 |
+
"check_git_changes.sh",
|
| 285 |
+
"""#!/bin/bash
|
| 286 |
+
set -e
|
| 287 |
+
|
| 288 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 289 |
+
echo "check_git_changes: Not inside a git repository"
|
| 290 |
+
exit 1
|
| 291 |
+
fi
|
| 292 |
+
|
| 293 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 294 |
+
echo "check_git_changes: Uncommitted changes"
|
| 295 |
+
exit 1
|
| 296 |
+
fi
|
| 297 |
+
|
| 298 |
+
echo "check_git_changes: No uncommitted changes"
|
| 299 |
+
exit 0
|
| 300 |
+
|
| 301 |
+
""".format(
|
| 302 |
+
pr=self.pr
|
| 303 |
+
),
|
| 304 |
+
),
|
| 305 |
+
File(
|
| 306 |
+
".",
|
| 307 |
+
"prepare.sh",
|
| 308 |
+
"""#!/bin/bash
|
| 309 |
+
set -e
|
| 310 |
+
|
| 311 |
+
cd /home/{pr.repo}
|
| 312 |
+
git reset --hard
|
| 313 |
+
bash /home/check_git_changes.sh
|
| 314 |
+
git checkout {pr.base.sha}
|
| 315 |
+
bash /home/check_git_changes.sh
|
| 316 |
+
mkdir build
|
| 317 |
+
|
| 318 |
+
""".format(
|
| 319 |
+
pr=self.pr
|
| 320 |
+
),
|
| 321 |
+
),
|
| 322 |
+
File(
|
| 323 |
+
".",
|
| 324 |
+
"run.sh",
|
| 325 |
+
"""#!/bin/bash
|
| 326 |
+
set -e
|
| 327 |
+
|
| 328 |
+
cd /home/{pr.repo}
|
| 329 |
+
cd build
|
| 330 |
+
cmake -DWITH_TESTS=ON -DTARGET_WEBASSEMBLY=OFF ..
|
| 331 |
+
make -j 4
|
| 332 |
+
ctest -j 4
|
| 333 |
+
""".format(
|
| 334 |
+
pr=self.pr
|
| 335 |
+
),
|
| 336 |
+
),
|
| 337 |
+
File(
|
| 338 |
+
".",
|
| 339 |
+
"test-run.sh",
|
| 340 |
+
"""#!/bin/bash
|
| 341 |
+
set -e
|
| 342 |
+
|
| 343 |
+
cd /home/{pr.repo}
|
| 344 |
+
git apply --whitespace=nowarn /home/test.patch
|
| 345 |
+
cd build
|
| 346 |
+
cmake -DWITH_TESTS=ON -DTARGET_WEBASSEMBLY=OFF ..
|
| 347 |
+
make -j 4
|
| 348 |
+
ctest -j 4
|
| 349 |
+
|
| 350 |
+
""".format(
|
| 351 |
+
pr=self.pr
|
| 352 |
+
),
|
| 353 |
+
),
|
| 354 |
+
File(
|
| 355 |
+
".",
|
| 356 |
+
"fix-run.sh",
|
| 357 |
+
"""#!/bin/bash
|
| 358 |
+
set -e
|
| 359 |
+
|
| 360 |
+
cd /home/{pr.repo}
|
| 361 |
+
git apply --whitespace=nowarn /home/test.patch /home/fix.patch
|
| 362 |
+
cd build
|
| 363 |
+
cmake -DWITH_TESTS=ON -DTARGET_WEBASSEMBLY=OFF ..
|
| 364 |
+
make -j 4
|
| 365 |
+
ctest -j 4
|
| 366 |
+
|
| 367 |
+
""".format(
|
| 368 |
+
pr=self.pr
|
| 369 |
+
),
|
| 370 |
+
),
|
| 371 |
+
]
|
| 372 |
+
|
| 373 |
+
def dockerfile(self) -> str:
|
| 374 |
+
image = self.dependency()
|
| 375 |
+
name = image.image_name()
|
| 376 |
+
tag = image.image_tag()
|
| 377 |
+
|
| 378 |
+
copy_commands = ""
|
| 379 |
+
for file in self.files():
|
| 380 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 381 |
+
|
| 382 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 383 |
+
|
| 384 |
+
return f"""FROM {name}:{tag}
|
| 385 |
+
|
| 386 |
+
{self.global_env}
|
| 387 |
+
|
| 388 |
+
{copy_commands}
|
| 389 |
+
|
| 390 |
+
{prepare_commands}
|
| 391 |
+
|
| 392 |
+
{self.clear_env}
|
| 393 |
+
|
| 394 |
+
"""
|
| 395 |
+
|
| 396 |
+
|
| 397 |
+
@Instance.register("halide", "Halide")
|
| 398 |
+
class Halide(Instance):
|
| 399 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 400 |
+
super().__init__()
|
| 401 |
+
self._pr = pr
|
| 402 |
+
self._config = config
|
| 403 |
+
|
| 404 |
+
@property
|
| 405 |
+
def pr(self) -> PullRequest:
|
| 406 |
+
return self._pr
|
| 407 |
+
|
| 408 |
+
def dependency(self) -> Optional[Image]:
|
| 409 |
+
return HalideImageDefault(self.pr, self._config)
|
| 410 |
+
|
| 411 |
+
def run(self, run_cmd: str = "") -> str:
|
| 412 |
+
if run_cmd:
|
| 413 |
+
return run_cmd
|
| 414 |
+
|
| 415 |
+
return "bash /home/run.sh"
|
| 416 |
+
|
| 417 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 418 |
+
if test_patch_run_cmd:
|
| 419 |
+
return test_patch_run_cmd
|
| 420 |
+
|
| 421 |
+
return "bash /home/test-run.sh"
|
| 422 |
+
|
| 423 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 424 |
+
if fix_patch_run_cmd:
|
| 425 |
+
return fix_patch_run_cmd
|
| 426 |
+
|
| 427 |
+
return "bash /home/fix-run.sh"
|
| 428 |
+
|
| 429 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 430 |
+
passed_tests = set()
|
| 431 |
+
failed_tests = set()
|
| 432 |
+
skipped_tests = set()
|
| 433 |
+
|
| 434 |
+
re_pass_tests = [re.compile(r"^\d+/\d+\s*Test\s*#\d+:\s*(.*?)\s*\.+\s*Passed")]
|
| 435 |
+
re_fail_tests = [
|
| 436 |
+
re.compile(r"^\d+/\d+\s*Test\s*#\d+:\s*(.*?)\s*\.+\s*\*+Failed"),
|
| 437 |
+
re.compile(
|
| 438 |
+
r"^\d+/\d+\s*Test\s*#\d+:\s*(.*?)\s*\.+\s*\*+Exception: Illegal"
|
| 439 |
+
),
|
| 440 |
+
re.compile(
|
| 441 |
+
r"^\d+/\d+\s+Test\s+#\d+:\s+(.+?)\s+\.+\s*Subprocess\s+aborted\*+\s*Exception:"
|
| 442 |
+
),
|
| 443 |
+
re.compile(
|
| 444 |
+
r"^\d+/\d+\s+Test\s+#\d+:\s+(.+?)\s+\.+\s*Child\s+aborted\*+\s*Exception:"
|
| 445 |
+
),
|
| 446 |
+
re.compile(
|
| 447 |
+
r"^\d+/\d+\s*Test\s*#\d+:\s*(.*?)\s*\.+\s*\*+Exception: SegFault"
|
| 448 |
+
),
|
| 449 |
+
]
|
| 450 |
+
|
| 451 |
+
for line in test_log.splitlines():
|
| 452 |
+
line = line.strip()
|
| 453 |
+
if not line:
|
| 454 |
+
continue
|
| 455 |
+
|
| 456 |
+
for re_pass_test in re_pass_tests:
|
| 457 |
+
pass_match = re_pass_test.match(line)
|
| 458 |
+
if pass_match:
|
| 459 |
+
test = pass_match.group(1)
|
| 460 |
+
passed_tests.add(test)
|
| 461 |
+
|
| 462 |
+
for re_fail_test in re_fail_tests:
|
| 463 |
+
fail_match = re_fail_test.match(line)
|
| 464 |
+
if fail_match:
|
| 465 |
+
test = fail_match.group(1)
|
| 466 |
+
failed_tests.add(test)
|
| 467 |
+
|
| 468 |
+
return TestResult(
|
| 469 |
+
passed_count=len(passed_tests),
|
| 470 |
+
failed_count=len(failed_tests),
|
| 471 |
+
skipped_count=len(skipped_tests),
|
| 472 |
+
passed_tests=passed_tests,
|
| 473 |
+
failed_tests=failed_tests,
|
| 474 |
+
skipped_tests=skipped_tests,
|
| 475 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/halide/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.eval.harness.repos.cpp.halide.Halide import *
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/nlohmann/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.eval.harness.repos.cpp.nlohmann.json import *
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/nlohmann/json.py
ADDED
|
@@ -0,0 +1,385 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class JsonImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "gcc:latest"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
|
| 50 |
+
{code}
|
| 51 |
+
|
| 52 |
+
RUN apt-get update && apt-get install -y libbrotli-dev libcurl4-openssl-dev
|
| 53 |
+
RUN apt-get install -y clang build-essential cmake
|
| 54 |
+
RUN cd /home/ && git clone https://github.com/nlohmann/json_test_data.git
|
| 55 |
+
|
| 56 |
+
{self.clear_env}
|
| 57 |
+
|
| 58 |
+
"""
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
class JsonImageBaseCpp12(Image):
|
| 62 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 63 |
+
self._pr = pr
|
| 64 |
+
self._config = config
|
| 65 |
+
|
| 66 |
+
@property
|
| 67 |
+
def pr(self) -> PullRequest:
|
| 68 |
+
return self._pr
|
| 69 |
+
|
| 70 |
+
@property
|
| 71 |
+
def config(self) -> Config:
|
| 72 |
+
return self._config
|
| 73 |
+
|
| 74 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 75 |
+
return "gcc:12"
|
| 76 |
+
|
| 77 |
+
def image_tag(self) -> str:
|
| 78 |
+
return "base-cpp-12"
|
| 79 |
+
|
| 80 |
+
def workdir(self) -> str:
|
| 81 |
+
return "base-cpp-12"
|
| 82 |
+
|
| 83 |
+
def files(self) -> list[File]:
|
| 84 |
+
return []
|
| 85 |
+
|
| 86 |
+
def dockerfile(self) -> str:
|
| 87 |
+
image_name = self.dependency()
|
| 88 |
+
if isinstance(image_name, Image):
|
| 89 |
+
image_name = image_name.image_full_name()
|
| 90 |
+
|
| 91 |
+
if self.config.need_clone:
|
| 92 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 93 |
+
else:
|
| 94 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 95 |
+
return f"""FROM {image_name}
|
| 96 |
+
|
| 97 |
+
{self.global_env}
|
| 98 |
+
|
| 99 |
+
WORKDIR /home/
|
| 100 |
+
|
| 101 |
+
{code}
|
| 102 |
+
|
| 103 |
+
RUN apt-get update && apt-get install -y libbrotli-dev libcurl4-openssl-dev
|
| 104 |
+
RUN apt-get install -y clang build-essential cmake
|
| 105 |
+
RUN cd /home/ && git clone https://github.com/nlohmann/json_test_data.git
|
| 106 |
+
|
| 107 |
+
{self.clear_env}
|
| 108 |
+
|
| 109 |
+
"""
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
class JsonImageBaseCpp7(Image):
|
| 113 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 114 |
+
self._pr = pr
|
| 115 |
+
self._config = config
|
| 116 |
+
|
| 117 |
+
@property
|
| 118 |
+
def pr(self) -> PullRequest:
|
| 119 |
+
return self._pr
|
| 120 |
+
|
| 121 |
+
@property
|
| 122 |
+
def config(self) -> Config:
|
| 123 |
+
return self._config
|
| 124 |
+
|
| 125 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 126 |
+
return "gcc:7"
|
| 127 |
+
|
| 128 |
+
def image_tag(self) -> str:
|
| 129 |
+
return "base-cpp-7"
|
| 130 |
+
|
| 131 |
+
def workdir(self) -> str:
|
| 132 |
+
return "base-cpp-7"
|
| 133 |
+
|
| 134 |
+
def files(self) -> list[File]:
|
| 135 |
+
return []
|
| 136 |
+
|
| 137 |
+
def dockerfile(self) -> str:
|
| 138 |
+
image_name = self.dependency()
|
| 139 |
+
if isinstance(image_name, Image):
|
| 140 |
+
image_name = image_name.image_full_name()
|
| 141 |
+
|
| 142 |
+
if self.config.need_clone:
|
| 143 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 144 |
+
else:
|
| 145 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 146 |
+
return f"""FROM {image_name}
|
| 147 |
+
|
| 148 |
+
{self.global_env}
|
| 149 |
+
|
| 150 |
+
WORKDIR /home/
|
| 151 |
+
|
| 152 |
+
{code}
|
| 153 |
+
|
| 154 |
+
RUN apt-get update && apt-get install -y libbrotli-dev libcurl4-openssl-dev
|
| 155 |
+
RUN apt-get install -y clang build-essential cmake
|
| 156 |
+
RUN cd /home/ && git clone https://github.com/nlohmann/json_test_data.git
|
| 157 |
+
|
| 158 |
+
{self.clear_env}
|
| 159 |
+
|
| 160 |
+
"""
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
class JsonImageDefault(Image):
|
| 164 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 165 |
+
self._pr = pr
|
| 166 |
+
self._config = config
|
| 167 |
+
|
| 168 |
+
@property
|
| 169 |
+
def pr(self) -> PullRequest:
|
| 170 |
+
return self._pr
|
| 171 |
+
|
| 172 |
+
@property
|
| 173 |
+
def config(self) -> Config:
|
| 174 |
+
return self._config
|
| 175 |
+
|
| 176 |
+
def dependency(self) -> Image | None:
|
| 177 |
+
if 2825 <= self.pr.number and self.pr.number <= 3685:
|
| 178 |
+
return JsonImageBaseCpp12(self.pr, self._config)
|
| 179 |
+
elif self.pr.number <= 2576:
|
| 180 |
+
return JsonImageBaseCpp7(self.pr, self._config)
|
| 181 |
+
|
| 182 |
+
return JsonImageBase(self.pr, self._config)
|
| 183 |
+
|
| 184 |
+
def image_tag(self) -> str:
|
| 185 |
+
return f"pr-{self.pr.number}"
|
| 186 |
+
|
| 187 |
+
def workdir(self) -> str:
|
| 188 |
+
return f"pr-{self.pr.number}"
|
| 189 |
+
|
| 190 |
+
def files(self) -> list[File]:
|
| 191 |
+
return [
|
| 192 |
+
File(
|
| 193 |
+
".",
|
| 194 |
+
"fix.patch",
|
| 195 |
+
f"{self.pr.fix_patch}",
|
| 196 |
+
),
|
| 197 |
+
File(
|
| 198 |
+
".",
|
| 199 |
+
"test.patch",
|
| 200 |
+
f"{self.pr.test_patch}",
|
| 201 |
+
),
|
| 202 |
+
File(
|
| 203 |
+
".",
|
| 204 |
+
"check_git_changes.sh",
|
| 205 |
+
"""#!/bin/bash
|
| 206 |
+
set -e
|
| 207 |
+
|
| 208 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 209 |
+
echo "check_git_changes: Not inside a git repository"
|
| 210 |
+
exit 1
|
| 211 |
+
fi
|
| 212 |
+
|
| 213 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 214 |
+
echo "check_git_changes: Uncommitted changes"
|
| 215 |
+
exit 1
|
| 216 |
+
fi
|
| 217 |
+
|
| 218 |
+
echo "check_git_changes: No uncommitted changes"
|
| 219 |
+
exit 0
|
| 220 |
+
|
| 221 |
+
""".format(
|
| 222 |
+
pr=self.pr
|
| 223 |
+
),
|
| 224 |
+
),
|
| 225 |
+
File(
|
| 226 |
+
".",
|
| 227 |
+
"prepare.sh",
|
| 228 |
+
"""#!/bin/bash
|
| 229 |
+
set -e
|
| 230 |
+
|
| 231 |
+
cd /home/{pr.repo}
|
| 232 |
+
git reset --hard
|
| 233 |
+
bash /home/check_git_changes.sh
|
| 234 |
+
git checkout {pr.base.sha}
|
| 235 |
+
bash /home/check_git_changes.sh
|
| 236 |
+
|
| 237 |
+
mkdir -p build
|
| 238 |
+
cp -r /home/json_test_data /home/{pr.repo}/build/
|
| 239 |
+
|
| 240 |
+
""".format(
|
| 241 |
+
pr=self.pr
|
| 242 |
+
),
|
| 243 |
+
),
|
| 244 |
+
File(
|
| 245 |
+
".",
|
| 246 |
+
"run.sh",
|
| 247 |
+
"""#!/bin/bash
|
| 248 |
+
set -e
|
| 249 |
+
|
| 250 |
+
cd /home/{pr.repo}
|
| 251 |
+
cd build
|
| 252 |
+
cmake ..
|
| 253 |
+
cmake --build .
|
| 254 |
+
ctest
|
| 255 |
+
""".format(
|
| 256 |
+
pr=self.pr
|
| 257 |
+
),
|
| 258 |
+
),
|
| 259 |
+
File(
|
| 260 |
+
".",
|
| 261 |
+
"test-run.sh",
|
| 262 |
+
"""#!/bin/bash
|
| 263 |
+
set -e
|
| 264 |
+
|
| 265 |
+
cd /home/{pr.repo}
|
| 266 |
+
git apply --whitespace=nowarn /home/test.patch
|
| 267 |
+
cd build
|
| 268 |
+
cmake ..
|
| 269 |
+
cmake --build .
|
| 270 |
+
ctest
|
| 271 |
+
|
| 272 |
+
""".format(
|
| 273 |
+
pr=self.pr
|
| 274 |
+
),
|
| 275 |
+
),
|
| 276 |
+
File(
|
| 277 |
+
".",
|
| 278 |
+
"fix-run.sh",
|
| 279 |
+
"""#!/bin/bash
|
| 280 |
+
set -e
|
| 281 |
+
|
| 282 |
+
cd /home/{pr.repo}
|
| 283 |
+
git apply --whitespace=nowarn /home/test.patch /home/fix.patch
|
| 284 |
+
cd build
|
| 285 |
+
cmake ..
|
| 286 |
+
cmake --build .
|
| 287 |
+
ctest
|
| 288 |
+
|
| 289 |
+
""".format(
|
| 290 |
+
pr=self.pr
|
| 291 |
+
),
|
| 292 |
+
),
|
| 293 |
+
]
|
| 294 |
+
|
| 295 |
+
def dockerfile(self) -> str:
|
| 296 |
+
image = self.dependency()
|
| 297 |
+
name = image.image_name()
|
| 298 |
+
tag = image.image_tag()
|
| 299 |
+
|
| 300 |
+
copy_commands = ""
|
| 301 |
+
for file in self.files():
|
| 302 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 303 |
+
|
| 304 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 305 |
+
|
| 306 |
+
return f"""FROM {name}:{tag}
|
| 307 |
+
|
| 308 |
+
{self.global_env}
|
| 309 |
+
|
| 310 |
+
{copy_commands}
|
| 311 |
+
|
| 312 |
+
{prepare_commands}
|
| 313 |
+
|
| 314 |
+
{self.clear_env}
|
| 315 |
+
|
| 316 |
+
"""
|
| 317 |
+
|
| 318 |
+
|
| 319 |
+
@Instance.register("nlohmann", "json")
|
| 320 |
+
class Json(Instance):
|
| 321 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 322 |
+
super().__init__()
|
| 323 |
+
self._pr = pr
|
| 324 |
+
self._config = config
|
| 325 |
+
|
| 326 |
+
@property
|
| 327 |
+
def pr(self) -> PullRequest:
|
| 328 |
+
return self._pr
|
| 329 |
+
|
| 330 |
+
def dependency(self) -> Optional[Image]:
|
| 331 |
+
return JsonImageDefault(self.pr, self._config)
|
| 332 |
+
|
| 333 |
+
def run(self, run_cmd: str = "") -> str:
|
| 334 |
+
if run_cmd:
|
| 335 |
+
return run_cmd
|
| 336 |
+
|
| 337 |
+
return "bash /home/run.sh"
|
| 338 |
+
|
| 339 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 340 |
+
if test_patch_run_cmd:
|
| 341 |
+
return test_patch_run_cmd
|
| 342 |
+
|
| 343 |
+
return "bash /home/test-run.sh"
|
| 344 |
+
|
| 345 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 346 |
+
if fix_patch_run_cmd:
|
| 347 |
+
return fix_patch_run_cmd
|
| 348 |
+
|
| 349 |
+
return "bash /home/fix-run.sh"
|
| 350 |
+
|
| 351 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 352 |
+
passed_tests = set()
|
| 353 |
+
failed_tests = set()
|
| 354 |
+
skipped_tests = set()
|
| 355 |
+
|
| 356 |
+
re_pass_tests = [re.compile(r"^\d+/\d+\s*Test\s*#\d+:\s*(.*?)\s*\.+\s*Passed")]
|
| 357 |
+
re_fail_tests = [
|
| 358 |
+
re.compile(r"^\d+/\d+\s*Test\s*#\d+:\s*(.*?)\s*\.+\s*\*+Failed$")
|
| 359 |
+
]
|
| 360 |
+
|
| 361 |
+
for line in test_log.splitlines():
|
| 362 |
+
line = line.strip()
|
| 363 |
+
if not line:
|
| 364 |
+
continue
|
| 365 |
+
|
| 366 |
+
for re_pass_test in re_pass_tests:
|
| 367 |
+
pass_match = re_pass_test.match(line)
|
| 368 |
+
if pass_match:
|
| 369 |
+
test = pass_match.group(1)
|
| 370 |
+
passed_tests.add(test)
|
| 371 |
+
|
| 372 |
+
for re_fail_test in re_fail_tests:
|
| 373 |
+
fail_match = re_fail_test.match(line)
|
| 374 |
+
if fail_match:
|
| 375 |
+
test = fail_match.group(1)
|
| 376 |
+
failed_tests.add(test)
|
| 377 |
+
|
| 378 |
+
return TestResult(
|
| 379 |
+
passed_count=len(passed_tests),
|
| 380 |
+
failed_count=len(failed_tests),
|
| 381 |
+
skipped_count=len(skipped_tests),
|
| 382 |
+
passed_tests=passed_tests,
|
| 383 |
+
failed_tests=failed_tests,
|
| 384 |
+
skipped_tests=skipped_tests,
|
| 385 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/rootproject/__init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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class RootImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "gcc:11"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
|
| 50 |
+
{code}
|
| 51 |
+
|
| 52 |
+
RUN apt-get update && \
|
| 53 |
+
apt-get install -y \
|
| 54 |
+
wget \
|
| 55 |
+
tar && \
|
| 56 |
+
wget https://cmake.org/files/v3.20/cmake-3.20.0-linux-x86_64.tar.gz && \
|
| 57 |
+
tar -zxvf cmake-3.20.0-linux-x86_64.tar.gz && \
|
| 58 |
+
mv cmake-3.20.0-linux-x86_64 /opt/cmake && \
|
| 59 |
+
ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake && \
|
| 60 |
+
rm cmake-3.20.0-linux-x86_64.tar.gz
|
| 61 |
+
|
| 62 |
+
RUN apt-get install -y binutils cmake dpkg-dev libssl-dev git libx11-dev \
|
| 63 |
+
libxext-dev libxft-dev libxpm-dev python3 libtbb-dev libgif-dev
|
| 64 |
+
|
| 65 |
+
{self.clear_env}
|
| 66 |
+
|
| 67 |
+
"""
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
class RootImageDefault(Image):
|
| 71 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 72 |
+
self._pr = pr
|
| 73 |
+
self._config = config
|
| 74 |
+
|
| 75 |
+
@property
|
| 76 |
+
def pr(self) -> PullRequest:
|
| 77 |
+
return self._pr
|
| 78 |
+
|
| 79 |
+
@property
|
| 80 |
+
def config(self) -> Config:
|
| 81 |
+
return self._config
|
| 82 |
+
|
| 83 |
+
def dependency(self) -> Image | None:
|
| 84 |
+
return RootImageBase(self.pr, self._config)
|
| 85 |
+
|
| 86 |
+
def image_tag(self) -> str:
|
| 87 |
+
return f"pr-{self.pr.number}"
|
| 88 |
+
|
| 89 |
+
def workdir(self) -> str:
|
| 90 |
+
return f"pr-{self.pr.number}"
|
| 91 |
+
|
| 92 |
+
def files(self) -> list[File]:
|
| 93 |
+
return [
|
| 94 |
+
File(
|
| 95 |
+
".",
|
| 96 |
+
"fix.patch",
|
| 97 |
+
f"{self.pr.fix_patch}",
|
| 98 |
+
),
|
| 99 |
+
File(
|
| 100 |
+
".",
|
| 101 |
+
"test.patch",
|
| 102 |
+
f"{self.pr.test_patch}",
|
| 103 |
+
),
|
| 104 |
+
File(
|
| 105 |
+
".",
|
| 106 |
+
"check_git_changes.sh",
|
| 107 |
+
"""#!/bin/bash
|
| 108 |
+
set -e
|
| 109 |
+
|
| 110 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 111 |
+
echo "check_git_changes: Not inside a git repository"
|
| 112 |
+
exit 1
|
| 113 |
+
fi
|
| 114 |
+
|
| 115 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 116 |
+
echo "check_git_changes: Uncommitted changes"
|
| 117 |
+
exit 1
|
| 118 |
+
fi
|
| 119 |
+
|
| 120 |
+
echo "check_git_changes: No uncommitted changes"
|
| 121 |
+
exit 0
|
| 122 |
+
|
| 123 |
+
""".format(
|
| 124 |
+
pr=self.pr
|
| 125 |
+
),
|
| 126 |
+
),
|
| 127 |
+
File(
|
| 128 |
+
".",
|
| 129 |
+
"prepare.sh",
|
| 130 |
+
"""#!/bin/bash
|
| 131 |
+
set -e
|
| 132 |
+
|
| 133 |
+
cd /home/{pr.repo}
|
| 134 |
+
git reset --hard
|
| 135 |
+
bash /home/check_git_changes.sh
|
| 136 |
+
git checkout {pr.base.sha}
|
| 137 |
+
bash /home/check_git_changes.sh
|
| 138 |
+
|
| 139 |
+
mkdir -p build
|
| 140 |
+
|
| 141 |
+
""".format(
|
| 142 |
+
pr=self.pr
|
| 143 |
+
),
|
| 144 |
+
),
|
| 145 |
+
File(
|
| 146 |
+
".",
|
| 147 |
+
"run.sh",
|
| 148 |
+
"""#!/bin/bash
|
| 149 |
+
set -e
|
| 150 |
+
|
| 151 |
+
cd /home/{pr.repo}
|
| 152 |
+
cd build
|
| 153 |
+
cmake -Dtesting=ON ..
|
| 154 |
+
make -j 8
|
| 155 |
+
ctest -j 8
|
| 156 |
+
""".format(
|
| 157 |
+
pr=self.pr
|
| 158 |
+
),
|
| 159 |
+
),
|
| 160 |
+
File(
|
| 161 |
+
".",
|
| 162 |
+
"test-run.sh",
|
| 163 |
+
"""#!/bin/bash
|
| 164 |
+
set -e
|
| 165 |
+
|
| 166 |
+
cd /home/{pr.repo}
|
| 167 |
+
git apply --whitespace=nowarn /home/test.patch
|
| 168 |
+
cd build
|
| 169 |
+
cmake -Dtesting=ON ..
|
| 170 |
+
make -j 8
|
| 171 |
+
ctest -j 8
|
| 172 |
+
|
| 173 |
+
""".format(
|
| 174 |
+
pr=self.pr
|
| 175 |
+
),
|
| 176 |
+
),
|
| 177 |
+
File(
|
| 178 |
+
".",
|
| 179 |
+
"fix-run.sh",
|
| 180 |
+
"""#!/bin/bash
|
| 181 |
+
set -e
|
| 182 |
+
|
| 183 |
+
cd /home/{pr.repo}
|
| 184 |
+
git apply --whitespace=nowarn /home/test.patch /home/fix.patch
|
| 185 |
+
cd build
|
| 186 |
+
cmake -Dtesting=ON ..
|
| 187 |
+
make -j 8
|
| 188 |
+
ctest -j 8
|
| 189 |
+
|
| 190 |
+
""".format(
|
| 191 |
+
pr=self.pr
|
| 192 |
+
),
|
| 193 |
+
),
|
| 194 |
+
]
|
| 195 |
+
|
| 196 |
+
def dockerfile(self) -> str:
|
| 197 |
+
image = self.dependency()
|
| 198 |
+
name = image.image_name()
|
| 199 |
+
tag = image.image_tag()
|
| 200 |
+
|
| 201 |
+
copy_commands = ""
|
| 202 |
+
for file in self.files():
|
| 203 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 204 |
+
|
| 205 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 206 |
+
|
| 207 |
+
return f"""FROM {name}:{tag}
|
| 208 |
+
|
| 209 |
+
{self.global_env}
|
| 210 |
+
|
| 211 |
+
{copy_commands}
|
| 212 |
+
|
| 213 |
+
{prepare_commands}
|
| 214 |
+
|
| 215 |
+
{self.clear_env}
|
| 216 |
+
|
| 217 |
+
"""
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
@Instance.register("root-project", "root")
|
| 221 |
+
class Root(Instance):
|
| 222 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 223 |
+
super().__init__()
|
| 224 |
+
self._pr = pr
|
| 225 |
+
self._config = config
|
| 226 |
+
|
| 227 |
+
@property
|
| 228 |
+
def pr(self) -> PullRequest:
|
| 229 |
+
return self._pr
|
| 230 |
+
|
| 231 |
+
def dependency(self) -> Optional[Image]:
|
| 232 |
+
return RootImageDefault(self.pr, self._config)
|
| 233 |
+
|
| 234 |
+
def run(self, run_cmd: str = "") -> str:
|
| 235 |
+
if run_cmd:
|
| 236 |
+
return run_cmd
|
| 237 |
+
|
| 238 |
+
return "bash /home/run.sh"
|
| 239 |
+
|
| 240 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 241 |
+
if test_patch_run_cmd:
|
| 242 |
+
return test_patch_run_cmd
|
| 243 |
+
|
| 244 |
+
return "bash /home/test-run.sh"
|
| 245 |
+
|
| 246 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 247 |
+
if fix_patch_run_cmd:
|
| 248 |
+
return fix_patch_run_cmd
|
| 249 |
+
|
| 250 |
+
return "bash /home/fix-run.sh"
|
| 251 |
+
|
| 252 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 253 |
+
passed_tests = set()
|
| 254 |
+
failed_tests = set()
|
| 255 |
+
skipped_tests = set()
|
| 256 |
+
|
| 257 |
+
re_pass_tests = [re.compile(r"^\d+/\d+\s*Test\s*#\d+:\s*(.*?)\s*\.+\s*Passed")]
|
| 258 |
+
re_fail_tests = [
|
| 259 |
+
re.compile(r"^\d+/\d+\s*Test\s*#\d+:\s*(.*?)\s*\.+\s*\*+Failed")
|
| 260 |
+
]
|
| 261 |
+
|
| 262 |
+
for line in test_log.splitlines():
|
| 263 |
+
line = line.strip()
|
| 264 |
+
if not line:
|
| 265 |
+
continue
|
| 266 |
+
|
| 267 |
+
for re_pass_test in re_pass_tests:
|
| 268 |
+
pass_match = re_pass_test.match(line)
|
| 269 |
+
if pass_match:
|
| 270 |
+
test = pass_match.group(1)
|
| 271 |
+
passed_tests.add(test)
|
| 272 |
+
|
| 273 |
+
for re_fail_test in re_fail_tests:
|
| 274 |
+
fail_match = re_fail_test.match(line)
|
| 275 |
+
if fail_match:
|
| 276 |
+
test = fail_match.group(1)
|
| 277 |
+
failed_tests.add(test)
|
| 278 |
+
|
| 279 |
+
return TestResult(
|
| 280 |
+
passed_count=len(passed_tests),
|
| 281 |
+
failed_count=len(failed_tests),
|
| 282 |
+
skipped_count=len(skipped_tests),
|
| 283 |
+
passed_tests=passed_tests,
|
| 284 |
+
failed_tests=failed_tests,
|
| 285 |
+
skipped_tests=skipped_tests,
|
| 286 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/simdjson/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.eval.harness.repos.cpp.simdjson.simdjson import *
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/simdjson/simdjson.py
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class SimdjsonImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "gcc:11"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
|
| 50 |
+
{code}
|
| 51 |
+
|
| 52 |
+
RUN apt-get update && apt-get install -y libbrotli-dev libcurl4-openssl-dev
|
| 53 |
+
RUN apt-get install -y clang build-essential cmake pkg-config
|
| 54 |
+
|
| 55 |
+
{self.clear_env}
|
| 56 |
+
|
| 57 |
+
"""
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
class SimdjsonImageBaseCpp7(Image):
|
| 61 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 62 |
+
self._pr = pr
|
| 63 |
+
self._config = config
|
| 64 |
+
|
| 65 |
+
@property
|
| 66 |
+
def pr(self) -> PullRequest:
|
| 67 |
+
return self._pr
|
| 68 |
+
|
| 69 |
+
@property
|
| 70 |
+
def config(self) -> Config:
|
| 71 |
+
return self._config
|
| 72 |
+
|
| 73 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 74 |
+
return "gcc:7"
|
| 75 |
+
|
| 76 |
+
def image_tag(self) -> str:
|
| 77 |
+
return "base-cpp-7"
|
| 78 |
+
|
| 79 |
+
def workdir(self) -> str:
|
| 80 |
+
return "base-cpp-7"
|
| 81 |
+
|
| 82 |
+
def files(self) -> list[File]:
|
| 83 |
+
return []
|
| 84 |
+
|
| 85 |
+
def dockerfile(self) -> str:
|
| 86 |
+
image_name = self.dependency()
|
| 87 |
+
if isinstance(image_name, Image):
|
| 88 |
+
image_name = image_name.image_full_name()
|
| 89 |
+
|
| 90 |
+
if self.config.need_clone:
|
| 91 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 92 |
+
else:
|
| 93 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 94 |
+
return f"""FROM {image_name}
|
| 95 |
+
|
| 96 |
+
{self.global_env}
|
| 97 |
+
|
| 98 |
+
WORKDIR /home/
|
| 99 |
+
|
| 100 |
+
{code}
|
| 101 |
+
|
| 102 |
+
RUN apt-get update && \
|
| 103 |
+
apt-get install -y \
|
| 104 |
+
build-essential \
|
| 105 |
+
pkg-config \
|
| 106 |
+
wget \
|
| 107 |
+
tar && \
|
| 108 |
+
wget https://cmake.org/files/v3.14/cmake-3.14.0-Linux-x86_64.tar.gz && \
|
| 109 |
+
tar -zxvf cmake-3.14.0-Linux-x86_64.tar.gz && \
|
| 110 |
+
mv cmake-3.14.0-Linux-x86_64 /opt/cmake && \
|
| 111 |
+
ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake && \
|
| 112 |
+
rm cmake-3.14.0-Linux-x86_64.tar.gz
|
| 113 |
+
RUN apt-get install -y cmake
|
| 114 |
+
|
| 115 |
+
{self.clear_env}
|
| 116 |
+
|
| 117 |
+
"""
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
class SimdjsonImageDefault(Image):
|
| 121 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 122 |
+
self._pr = pr
|
| 123 |
+
self._config = config
|
| 124 |
+
|
| 125 |
+
@property
|
| 126 |
+
def pr(self) -> PullRequest:
|
| 127 |
+
return self._pr
|
| 128 |
+
|
| 129 |
+
@property
|
| 130 |
+
def config(self) -> Config:
|
| 131 |
+
return self._config
|
| 132 |
+
|
| 133 |
+
def dependency(self) -> Image | None:
|
| 134 |
+
if self.pr.number <= 958:
|
| 135 |
+
return SimdjsonImageBaseCpp7(self.pr, self._config)
|
| 136 |
+
|
| 137 |
+
return SimdjsonImageBase(self.pr, self._config)
|
| 138 |
+
|
| 139 |
+
def image_tag(self) -> str:
|
| 140 |
+
return f"pr-{self.pr.number}"
|
| 141 |
+
|
| 142 |
+
def workdir(self) -> str:
|
| 143 |
+
return f"pr-{self.pr.number}"
|
| 144 |
+
|
| 145 |
+
def files(self) -> list[File]:
|
| 146 |
+
return [
|
| 147 |
+
File(
|
| 148 |
+
".",
|
| 149 |
+
"fix.patch",
|
| 150 |
+
f"{self.pr.fix_patch}",
|
| 151 |
+
),
|
| 152 |
+
File(
|
| 153 |
+
".",
|
| 154 |
+
"test.patch",
|
| 155 |
+
f"{self.pr.test_patch}",
|
| 156 |
+
),
|
| 157 |
+
File(
|
| 158 |
+
".",
|
| 159 |
+
"check_git_changes.sh",
|
| 160 |
+
"""#!/bin/bash
|
| 161 |
+
set -e
|
| 162 |
+
|
| 163 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 164 |
+
echo "check_git_changes: Not inside a git repository"
|
| 165 |
+
exit 1
|
| 166 |
+
fi
|
| 167 |
+
|
| 168 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 169 |
+
echo "check_git_changes: Uncommitted changes"
|
| 170 |
+
exit 1
|
| 171 |
+
fi
|
| 172 |
+
|
| 173 |
+
echo "check_git_changes: No uncommitted changes"
|
| 174 |
+
exit 0
|
| 175 |
+
|
| 176 |
+
""".format(
|
| 177 |
+
pr=self.pr
|
| 178 |
+
),
|
| 179 |
+
),
|
| 180 |
+
File(
|
| 181 |
+
".",
|
| 182 |
+
"prepare.sh",
|
| 183 |
+
"""#!/bin/bash
|
| 184 |
+
set -e
|
| 185 |
+
|
| 186 |
+
cd /home/{pr.repo}
|
| 187 |
+
git reset --hard
|
| 188 |
+
bash /home/check_git_changes.sh
|
| 189 |
+
git checkout {pr.base.sha}
|
| 190 |
+
bash /home/check_git_changes.sh
|
| 191 |
+
|
| 192 |
+
mkdir build
|
| 193 |
+
|
| 194 |
+
""".format(
|
| 195 |
+
pr=self.pr
|
| 196 |
+
),
|
| 197 |
+
),
|
| 198 |
+
File(
|
| 199 |
+
".",
|
| 200 |
+
"run.sh",
|
| 201 |
+
"""#!/bin/bash
|
| 202 |
+
set -e
|
| 203 |
+
|
| 204 |
+
cd /home/{pr.repo}
|
| 205 |
+
cd build
|
| 206 |
+
cmake -DSIMDJSON_DEVELOPER_MODE=ON ..
|
| 207 |
+
cmake --build .
|
| 208 |
+
ctest
|
| 209 |
+
""".format(
|
| 210 |
+
pr=self.pr
|
| 211 |
+
),
|
| 212 |
+
),
|
| 213 |
+
File(
|
| 214 |
+
".",
|
| 215 |
+
"test-run.sh",
|
| 216 |
+
"""#!/bin/bash
|
| 217 |
+
set -e
|
| 218 |
+
|
| 219 |
+
cd /home/{pr.repo}
|
| 220 |
+
git apply --whitespace=nowarn /home/test.patch
|
| 221 |
+
cd build
|
| 222 |
+
cmake -DSIMDJSON_DEVELOPER_MODE=ON ..
|
| 223 |
+
cmake --build .
|
| 224 |
+
ctest
|
| 225 |
+
|
| 226 |
+
""".format(
|
| 227 |
+
pr=self.pr
|
| 228 |
+
),
|
| 229 |
+
),
|
| 230 |
+
File(
|
| 231 |
+
".",
|
| 232 |
+
"fix-run.sh",
|
| 233 |
+
"""#!/bin/bash
|
| 234 |
+
set -e
|
| 235 |
+
|
| 236 |
+
cd /home/{pr.repo}
|
| 237 |
+
git apply --whitespace=nowarn /home/test.patch /home/fix.patch
|
| 238 |
+
cd build
|
| 239 |
+
cmake -DSIMDJSON_DEVELOPER_MODE=ON ..
|
| 240 |
+
cmake --build .
|
| 241 |
+
ctest
|
| 242 |
+
|
| 243 |
+
""".format(
|
| 244 |
+
pr=self.pr
|
| 245 |
+
),
|
| 246 |
+
),
|
| 247 |
+
]
|
| 248 |
+
|
| 249 |
+
def dockerfile(self) -> str:
|
| 250 |
+
image = self.dependency()
|
| 251 |
+
name = image.image_name()
|
| 252 |
+
tag = image.image_tag()
|
| 253 |
+
|
| 254 |
+
copy_commands = ""
|
| 255 |
+
for file in self.files():
|
| 256 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 257 |
+
|
| 258 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 259 |
+
|
| 260 |
+
return f"""FROM {name}:{tag}
|
| 261 |
+
|
| 262 |
+
{self.global_env}
|
| 263 |
+
|
| 264 |
+
{copy_commands}
|
| 265 |
+
|
| 266 |
+
{prepare_commands}
|
| 267 |
+
|
| 268 |
+
{self.clear_env}
|
| 269 |
+
|
| 270 |
+
"""
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
@Instance.register("simdjson", "simdjson")
|
| 274 |
+
class Simdjson(Instance):
|
| 275 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 276 |
+
super().__init__()
|
| 277 |
+
self._pr = pr
|
| 278 |
+
self._config = config
|
| 279 |
+
|
| 280 |
+
@property
|
| 281 |
+
def pr(self) -> PullRequest:
|
| 282 |
+
return self._pr
|
| 283 |
+
|
| 284 |
+
def dependency(self) -> Optional[Image]:
|
| 285 |
+
return SimdjsonImageDefault(self.pr, self._config)
|
| 286 |
+
|
| 287 |
+
def run(self, run_cmd: str = "") -> str:
|
| 288 |
+
if run_cmd:
|
| 289 |
+
return run_cmd
|
| 290 |
+
|
| 291 |
+
return "bash /home/run.sh"
|
| 292 |
+
|
| 293 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 294 |
+
if test_patch_run_cmd:
|
| 295 |
+
return test_patch_run_cmd
|
| 296 |
+
|
| 297 |
+
return "bash /home/test-run.sh"
|
| 298 |
+
|
| 299 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 300 |
+
if fix_patch_run_cmd:
|
| 301 |
+
return fix_patch_run_cmd
|
| 302 |
+
|
| 303 |
+
return "bash /home/fix-run.sh"
|
| 304 |
+
|
| 305 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 306 |
+
passed_tests = set()
|
| 307 |
+
failed_tests = set()
|
| 308 |
+
skipped_tests = set()
|
| 309 |
+
|
| 310 |
+
re_pass_tests = [re.compile(r"^\d+/\d+\s*Test\s*#\d+:\s*(.*?)\s*\.+\s*Passed")]
|
| 311 |
+
re_fail_tests = [
|
| 312 |
+
re.compile(r"^\d+/\d+\s*Test\s*#\d+:\s*(.*?)\s*\.+\s*\*+Failed$")
|
| 313 |
+
]
|
| 314 |
+
|
| 315 |
+
for line in test_log.splitlines():
|
| 316 |
+
line = line.strip()
|
| 317 |
+
if not line:
|
| 318 |
+
continue
|
| 319 |
+
|
| 320 |
+
for re_pass_test in re_pass_tests:
|
| 321 |
+
pass_match = re_pass_test.match(line)
|
| 322 |
+
if pass_match:
|
| 323 |
+
test = pass_match.group(1)
|
| 324 |
+
passed_tests.add(test)
|
| 325 |
+
|
| 326 |
+
for re_fail_test in re_fail_tests:
|
| 327 |
+
fail_match = re_fail_test.match(line)
|
| 328 |
+
if fail_match:
|
| 329 |
+
test = fail_match.group(1)
|
| 330 |
+
failed_tests.add(test)
|
| 331 |
+
|
| 332 |
+
return TestResult(
|
| 333 |
+
passed_count=len(passed_tests),
|
| 334 |
+
failed_count=len(failed_tests),
|
| 335 |
+
skipped_count=len(skipped_tests),
|
| 336 |
+
passed_tests=passed_tests,
|
| 337 |
+
failed_tests=failed_tests,
|
| 338 |
+
skipped_tests=skipped_tests,
|
| 339 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/yhirose/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.eval.harness.repos.cpp.yhirose.cpp_httplib import *
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/cpp/yhirose/cpp_httplib.py
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class ImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "gcc:latest"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 50 |
+
ENV LANG=C.UTF-8
|
| 51 |
+
ENV LC_ALL=C.UTF-8
|
| 52 |
+
RUN apt-get update && apt-get install -y libbrotli-dev libcurl4-openssl-dev
|
| 53 |
+
RUN apt-get install -y clang build-essential
|
| 54 |
+
|
| 55 |
+
{code}
|
| 56 |
+
|
| 57 |
+
{self.clear_env}
|
| 58 |
+
|
| 59 |
+
"""
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
class ImageDefault(Image):
|
| 63 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 64 |
+
self._pr = pr
|
| 65 |
+
self._config = config
|
| 66 |
+
|
| 67 |
+
@property
|
| 68 |
+
def pr(self) -> PullRequest:
|
| 69 |
+
return self._pr
|
| 70 |
+
|
| 71 |
+
@property
|
| 72 |
+
def config(self) -> Config:
|
| 73 |
+
return self._config
|
| 74 |
+
|
| 75 |
+
def dependency(self) -> Image | None:
|
| 76 |
+
return ImageBase(self.pr, self._config)
|
| 77 |
+
|
| 78 |
+
def image_tag(self) -> str:
|
| 79 |
+
return f"pr-{self.pr.number}"
|
| 80 |
+
|
| 81 |
+
def workdir(self) -> str:
|
| 82 |
+
return f"pr-{self.pr.number}"
|
| 83 |
+
|
| 84 |
+
def files(self) -> list[File]:
|
| 85 |
+
return [
|
| 86 |
+
File(
|
| 87 |
+
".",
|
| 88 |
+
"fix.patch",
|
| 89 |
+
f"{self.pr.fix_patch}",
|
| 90 |
+
),
|
| 91 |
+
File(
|
| 92 |
+
".",
|
| 93 |
+
"test.patch",
|
| 94 |
+
f"{self.pr.test_patch}",
|
| 95 |
+
),
|
| 96 |
+
File(
|
| 97 |
+
".",
|
| 98 |
+
"check_git_changes.sh",
|
| 99 |
+
"""#!/bin/bash
|
| 100 |
+
set -e
|
| 101 |
+
|
| 102 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 103 |
+
echo "check_git_changes: Not inside a git repository"
|
| 104 |
+
exit 1
|
| 105 |
+
fi
|
| 106 |
+
|
| 107 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 108 |
+
echo "check_git_changes: Uncommitted changes"
|
| 109 |
+
exit 1
|
| 110 |
+
fi
|
| 111 |
+
|
| 112 |
+
echo "check_git_changes: No uncommitted changes"
|
| 113 |
+
exit 0
|
| 114 |
+
|
| 115 |
+
""".format(
|
| 116 |
+
pr=self.pr
|
| 117 |
+
),
|
| 118 |
+
),
|
| 119 |
+
File(
|
| 120 |
+
".",
|
| 121 |
+
"prepare.sh",
|
| 122 |
+
"""#!/bin/bash
|
| 123 |
+
set -e
|
| 124 |
+
|
| 125 |
+
cd /home/{pr.repo}
|
| 126 |
+
git reset --hard
|
| 127 |
+
bash /home/check_git_changes.sh
|
| 128 |
+
git checkout {pr.base.sha}
|
| 129 |
+
bash /home/check_git_changes.sh
|
| 130 |
+
|
| 131 |
+
""".format(
|
| 132 |
+
pr=self.pr
|
| 133 |
+
),
|
| 134 |
+
),
|
| 135 |
+
File(
|
| 136 |
+
".",
|
| 137 |
+
"run.sh",
|
| 138 |
+
"""#!/bin/bash
|
| 139 |
+
set -e
|
| 140 |
+
|
| 141 |
+
cd /home/{pr.repo}
|
| 142 |
+
cd test
|
| 143 |
+
make
|
| 144 |
+
""".format(
|
| 145 |
+
pr=self.pr
|
| 146 |
+
),
|
| 147 |
+
),
|
| 148 |
+
File(
|
| 149 |
+
".",
|
| 150 |
+
"test-run.sh",
|
| 151 |
+
"""#!/bin/bash
|
| 152 |
+
set -e
|
| 153 |
+
|
| 154 |
+
cd /home/{pr.repo}
|
| 155 |
+
git apply --whitespace=nowarn /home/test.patch
|
| 156 |
+
cd test
|
| 157 |
+
make
|
| 158 |
+
|
| 159 |
+
""".format(
|
| 160 |
+
pr=self.pr
|
| 161 |
+
),
|
| 162 |
+
),
|
| 163 |
+
File(
|
| 164 |
+
".",
|
| 165 |
+
"fix-run.sh",
|
| 166 |
+
"""#!/bin/bash
|
| 167 |
+
set -e
|
| 168 |
+
|
| 169 |
+
cd /home/{pr.repo}
|
| 170 |
+
git apply --whitespace=nowarn /home/test.patch /home/fix.patch
|
| 171 |
+
cd test
|
| 172 |
+
make
|
| 173 |
+
|
| 174 |
+
""".format(
|
| 175 |
+
pr=self.pr
|
| 176 |
+
),
|
| 177 |
+
),
|
| 178 |
+
]
|
| 179 |
+
|
| 180 |
+
def dockerfile(self) -> str:
|
| 181 |
+
image = self.dependency()
|
| 182 |
+
name = image.image_name()
|
| 183 |
+
tag = image.image_tag()
|
| 184 |
+
|
| 185 |
+
copy_commands = ""
|
| 186 |
+
for file in self.files():
|
| 187 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 188 |
+
|
| 189 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 190 |
+
|
| 191 |
+
return f"""FROM {name}:{tag}
|
| 192 |
+
|
| 193 |
+
{self.global_env}
|
| 194 |
+
|
| 195 |
+
{copy_commands}
|
| 196 |
+
|
| 197 |
+
{prepare_commands}
|
| 198 |
+
|
| 199 |
+
{self.clear_env}
|
| 200 |
+
|
| 201 |
+
"""
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
@Instance.register("yhirose", "cpp-httplib")
|
| 205 |
+
class CppHttplib(Instance):
|
| 206 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 207 |
+
super().__init__()
|
| 208 |
+
self._pr = pr
|
| 209 |
+
self._config = config
|
| 210 |
+
|
| 211 |
+
@property
|
| 212 |
+
def pr(self) -> PullRequest:
|
| 213 |
+
return self._pr
|
| 214 |
+
|
| 215 |
+
def dependency(self) -> Optional[Image]:
|
| 216 |
+
return ImageDefault(self.pr, self._config)
|
| 217 |
+
|
| 218 |
+
def run(self, run_cmd: str = "") -> str:
|
| 219 |
+
if run_cmd:
|
| 220 |
+
return run_cmd
|
| 221 |
+
|
| 222 |
+
return "bash /home/run.sh"
|
| 223 |
+
|
| 224 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 225 |
+
if test_patch_run_cmd:
|
| 226 |
+
return test_patch_run_cmd
|
| 227 |
+
|
| 228 |
+
return "bash /home/test-run.sh"
|
| 229 |
+
|
| 230 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 231 |
+
if fix_patch_run_cmd:
|
| 232 |
+
return fix_patch_run_cmd
|
| 233 |
+
|
| 234 |
+
return "bash /home/fix-run.sh"
|
| 235 |
+
|
| 236 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 237 |
+
passed_tests = set()
|
| 238 |
+
failed_tests = set()
|
| 239 |
+
skipped_tests = set()
|
| 240 |
+
|
| 241 |
+
re_passes = [
|
| 242 |
+
re.compile(r"^\[ OK \] (\S+?)( \(.+\))?$"),
|
| 243 |
+
re.compile(r"^\x1b\[0;32m\[ OK \] \x1b\[0m(\S+?)( \(.+\))?$"),
|
| 244 |
+
re.compile(r"^\x1b\[92m---- Passed: (\S+?)\x1b\[0m$"),
|
| 245 |
+
]
|
| 246 |
+
re_fails = [
|
| 247 |
+
re.compile(r"^\[ FAILED \] (\S+?)( \(.+\))?$"),
|
| 248 |
+
re.compile(r"^\x1b\[0;31m\[ FAILED \] \x1b\[0m(\S+?)( \(.+\))?$"),
|
| 249 |
+
re.compile(r"^\x1b\[91m\*\*\*\* FAILED: (\S+?)\x1b\[0m$"),
|
| 250 |
+
]
|
| 251 |
+
|
| 252 |
+
for line in test_log.splitlines():
|
| 253 |
+
line = line.strip()
|
| 254 |
+
if not line:
|
| 255 |
+
continue
|
| 256 |
+
|
| 257 |
+
for re_pass in re_passes:
|
| 258 |
+
pass_match = re_pass.match(line)
|
| 259 |
+
if pass_match:
|
| 260 |
+
test = pass_match.group(1)
|
| 261 |
+
passed_tests.add(test)
|
| 262 |
+
|
| 263 |
+
for re_fail in re_fails:
|
| 264 |
+
fail_match = re_fail.match(line)
|
| 265 |
+
if fail_match:
|
| 266 |
+
test = fail_match.group(1)
|
| 267 |
+
failed_tests.add(test)
|
| 268 |
+
|
| 269 |
+
return TestResult(
|
| 270 |
+
passed_count=len(passed_tests),
|
| 271 |
+
failed_count=len(failed_tests),
|
| 272 |
+
skipped_count=len(skipped_tests),
|
| 273 |
+
passed_tests=passed_tests,
|
| 274 |
+
failed_tests=failed_tests,
|
| 275 |
+
skipped_tests=skipped_tests,
|
| 276 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/beego/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.eval.harness.repos.golang.beego.beego import *
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/beego/beego.py
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class BeegoImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "golang:latest"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
|
| 50 |
+
{code}
|
| 51 |
+
|
| 52 |
+
{self.clear_env}
|
| 53 |
+
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class BeegoImageDefault(Image):
|
| 58 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 59 |
+
self._pr = pr
|
| 60 |
+
self._config = config
|
| 61 |
+
|
| 62 |
+
@property
|
| 63 |
+
def pr(self) -> PullRequest:
|
| 64 |
+
return self._pr
|
| 65 |
+
|
| 66 |
+
@property
|
| 67 |
+
def config(self) -> Config:
|
| 68 |
+
return self._config
|
| 69 |
+
|
| 70 |
+
def dependency(self) -> Image | None:
|
| 71 |
+
return BeegoImageBase(self.pr, self.config)
|
| 72 |
+
|
| 73 |
+
def image_tag(self) -> str:
|
| 74 |
+
return f"pr-{self.pr.number}"
|
| 75 |
+
|
| 76 |
+
def workdir(self) -> str:
|
| 77 |
+
return f"pr-{self.pr.number}"
|
| 78 |
+
|
| 79 |
+
def files(self) -> list[File]:
|
| 80 |
+
return [
|
| 81 |
+
File(
|
| 82 |
+
".",
|
| 83 |
+
"fix.patch",
|
| 84 |
+
f"{self.pr.fix_patch}",
|
| 85 |
+
),
|
| 86 |
+
File(
|
| 87 |
+
".",
|
| 88 |
+
"test.patch",
|
| 89 |
+
f"{self.pr.test_patch}",
|
| 90 |
+
),
|
| 91 |
+
File(
|
| 92 |
+
".",
|
| 93 |
+
"check_git_changes.sh",
|
| 94 |
+
"""#!/bin/bash
|
| 95 |
+
set -e
|
| 96 |
+
|
| 97 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 98 |
+
echo "check_git_changes: Not inside a git repository"
|
| 99 |
+
exit 1
|
| 100 |
+
fi
|
| 101 |
+
|
| 102 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 103 |
+
echo "check_git_changes: Uncommitted changes"
|
| 104 |
+
exit 1
|
| 105 |
+
fi
|
| 106 |
+
|
| 107 |
+
echo "check_git_changes: No uncommitted changes"
|
| 108 |
+
exit 0
|
| 109 |
+
|
| 110 |
+
""".format(
|
| 111 |
+
pr=self.pr
|
| 112 |
+
),
|
| 113 |
+
),
|
| 114 |
+
File(
|
| 115 |
+
".",
|
| 116 |
+
"prepare.sh",
|
| 117 |
+
"""#!/bin/bash
|
| 118 |
+
set -e
|
| 119 |
+
|
| 120 |
+
cd /home/{pr.repo}
|
| 121 |
+
git reset --hard
|
| 122 |
+
bash /home/check_git_changes.sh
|
| 123 |
+
git checkout {pr.base.sha}
|
| 124 |
+
bash /home/check_git_changes.sh
|
| 125 |
+
|
| 126 |
+
go test -v -count=1 ./... || true
|
| 127 |
+
|
| 128 |
+
""".format(
|
| 129 |
+
pr=self.pr
|
| 130 |
+
),
|
| 131 |
+
),
|
| 132 |
+
File(
|
| 133 |
+
".",
|
| 134 |
+
"run.sh",
|
| 135 |
+
"""#!/bin/bash
|
| 136 |
+
set -e
|
| 137 |
+
|
| 138 |
+
cd /home/{pr.repo}
|
| 139 |
+
go test -v -count=1 ./...
|
| 140 |
+
|
| 141 |
+
""".format(
|
| 142 |
+
pr=self.pr
|
| 143 |
+
),
|
| 144 |
+
),
|
| 145 |
+
File(
|
| 146 |
+
".",
|
| 147 |
+
"test-run.sh",
|
| 148 |
+
"""#!/bin/bash
|
| 149 |
+
set -e
|
| 150 |
+
|
| 151 |
+
cd /home/{pr.repo}
|
| 152 |
+
git apply /home/test.patch
|
| 153 |
+
go test -v -count=1 ./...
|
| 154 |
+
|
| 155 |
+
""".format(
|
| 156 |
+
pr=self.pr
|
| 157 |
+
),
|
| 158 |
+
),
|
| 159 |
+
File(
|
| 160 |
+
".",
|
| 161 |
+
"fix-run.sh",
|
| 162 |
+
"""#!/bin/bash
|
| 163 |
+
set -e
|
| 164 |
+
|
| 165 |
+
cd /home/{pr.repo}
|
| 166 |
+
git apply /home/test.patch /home/fix.patch
|
| 167 |
+
go test -v -count=1 ./...
|
| 168 |
+
|
| 169 |
+
""".format(
|
| 170 |
+
pr=self.pr
|
| 171 |
+
),
|
| 172 |
+
),
|
| 173 |
+
]
|
| 174 |
+
|
| 175 |
+
def dockerfile(self) -> str:
|
| 176 |
+
image = self.dependency()
|
| 177 |
+
name = image.image_name()
|
| 178 |
+
tag = image.image_tag()
|
| 179 |
+
|
| 180 |
+
copy_commands = ""
|
| 181 |
+
for file in self.files():
|
| 182 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 183 |
+
|
| 184 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 185 |
+
|
| 186 |
+
return f"""FROM {name}:{tag}
|
| 187 |
+
|
| 188 |
+
{self.global_env}
|
| 189 |
+
|
| 190 |
+
{copy_commands}
|
| 191 |
+
|
| 192 |
+
{prepare_commands}
|
| 193 |
+
|
| 194 |
+
{self.clear_env}
|
| 195 |
+
|
| 196 |
+
"""
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
@Instance.register("beego", "beego")
|
| 200 |
+
class Beego(Instance):
|
| 201 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 202 |
+
super().__init__()
|
| 203 |
+
self._pr = pr
|
| 204 |
+
self._config = config
|
| 205 |
+
|
| 206 |
+
@property
|
| 207 |
+
def pr(self) -> PullRequest:
|
| 208 |
+
return self._pr
|
| 209 |
+
|
| 210 |
+
def dependency(self) -> Optional[Image]:
|
| 211 |
+
return BeegoImageDefault(self.pr, self._config)
|
| 212 |
+
|
| 213 |
+
def run(self, run_cmd: str = "") -> str:
|
| 214 |
+
if run_cmd:
|
| 215 |
+
return run_cmd
|
| 216 |
+
|
| 217 |
+
return "bash /home/run.sh"
|
| 218 |
+
|
| 219 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 220 |
+
if test_patch_run_cmd:
|
| 221 |
+
return test_patch_run_cmd
|
| 222 |
+
|
| 223 |
+
return "bash /home/test-run.sh"
|
| 224 |
+
|
| 225 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 226 |
+
if fix_patch_run_cmd:
|
| 227 |
+
return fix_patch_run_cmd
|
| 228 |
+
|
| 229 |
+
return "bash /home/fix-run.sh"
|
| 230 |
+
|
| 231 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 232 |
+
passed_tests = set()
|
| 233 |
+
failed_tests = set()
|
| 234 |
+
skipped_tests = set()
|
| 235 |
+
|
| 236 |
+
re_pass_tests = [re.compile(r"--- PASS: (\S+)")]
|
| 237 |
+
re_fail_tests = [
|
| 238 |
+
re.compile(r"--- FAIL: (\S+)"),
|
| 239 |
+
re.compile(r"FAIL:?\s?(.+?)\s"),
|
| 240 |
+
]
|
| 241 |
+
re_skip_tests = [re.compile(r"--- SKIP: (\S+)")]
|
| 242 |
+
|
| 243 |
+
def get_base_name(test_name: str) -> str:
|
| 244 |
+
return test_name
|
| 245 |
+
|
| 246 |
+
for line in test_log.splitlines():
|
| 247 |
+
line = line.strip()
|
| 248 |
+
|
| 249 |
+
for re_pass_test in re_pass_tests:
|
| 250 |
+
pass_match = re_pass_test.match(line)
|
| 251 |
+
if pass_match:
|
| 252 |
+
test_name = pass_match.group(1)
|
| 253 |
+
if test_name in failed_tests:
|
| 254 |
+
continue
|
| 255 |
+
if test_name in skipped_tests:
|
| 256 |
+
skipped_tests.remove(test_name)
|
| 257 |
+
passed_tests.add(get_base_name(test_name))
|
| 258 |
+
|
| 259 |
+
for re_fail_test in re_fail_tests:
|
| 260 |
+
fail_match = re_fail_test.match(line)
|
| 261 |
+
if fail_match:
|
| 262 |
+
test_name = fail_match.group(1)
|
| 263 |
+
if test_name in passed_tests:
|
| 264 |
+
passed_tests.remove(test_name)
|
| 265 |
+
if test_name in skipped_tests:
|
| 266 |
+
skipped_tests.remove(test_name)
|
| 267 |
+
failed_tests.add(get_base_name(test_name))
|
| 268 |
+
|
| 269 |
+
for re_skip_test in re_skip_tests:
|
| 270 |
+
skip_match = re_skip_test.match(line)
|
| 271 |
+
if skip_match:
|
| 272 |
+
test_name = skip_match.group(1)
|
| 273 |
+
if test_name in passed_tests:
|
| 274 |
+
continue
|
| 275 |
+
if test_name not in failed_tests:
|
| 276 |
+
continue
|
| 277 |
+
skipped_tests.add(get_base_name(test_name))
|
| 278 |
+
|
| 279 |
+
return TestResult(
|
| 280 |
+
passed_count=len(passed_tests),
|
| 281 |
+
failed_count=len(failed_tests),
|
| 282 |
+
skipped_count=len(skipped_tests),
|
| 283 |
+
passed_tests=passed_tests,
|
| 284 |
+
failed_tests=failed_tests,
|
| 285 |
+
skipped_tests=skipped_tests,
|
| 286 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/caddyserver/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.eval.harness.repos.golang.caddyserver.caddy import *
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/caddyserver/caddy.py
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class CaddyImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "golang:latest"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
|
| 50 |
+
{code}
|
| 51 |
+
|
| 52 |
+
{self.clear_env}
|
| 53 |
+
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class CaddyImageDefault(Image):
|
| 58 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 59 |
+
self._pr = pr
|
| 60 |
+
self._config = config
|
| 61 |
+
|
| 62 |
+
@property
|
| 63 |
+
def pr(self) -> PullRequest:
|
| 64 |
+
return self._pr
|
| 65 |
+
|
| 66 |
+
@property
|
| 67 |
+
def config(self) -> Config:
|
| 68 |
+
return self._config
|
| 69 |
+
|
| 70 |
+
def dependency(self) -> Image | None:
|
| 71 |
+
return CaddyImageBase(self.pr, self.config)
|
| 72 |
+
|
| 73 |
+
def image_tag(self) -> str:
|
| 74 |
+
return f"pr-{self.pr.number}"
|
| 75 |
+
|
| 76 |
+
def workdir(self) -> str:
|
| 77 |
+
return f"pr-{self.pr.number}"
|
| 78 |
+
|
| 79 |
+
def files(self) -> list[File]:
|
| 80 |
+
return [
|
| 81 |
+
File(
|
| 82 |
+
".",
|
| 83 |
+
"fix.patch",
|
| 84 |
+
f"{self.pr.fix_patch}",
|
| 85 |
+
),
|
| 86 |
+
File(
|
| 87 |
+
".",
|
| 88 |
+
"test.patch",
|
| 89 |
+
f"{self.pr.test_patch}",
|
| 90 |
+
),
|
| 91 |
+
File(
|
| 92 |
+
".",
|
| 93 |
+
"check_git_changes.sh",
|
| 94 |
+
"""#!/bin/bash
|
| 95 |
+
set -e
|
| 96 |
+
|
| 97 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 98 |
+
echo "check_git_changes: Not inside a git repository"
|
| 99 |
+
exit 1
|
| 100 |
+
fi
|
| 101 |
+
|
| 102 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 103 |
+
echo "check_git_changes: Uncommitted changes"
|
| 104 |
+
exit 1
|
| 105 |
+
fi
|
| 106 |
+
|
| 107 |
+
echo "check_git_changes: No uncommitted changes"
|
| 108 |
+
exit 0
|
| 109 |
+
|
| 110 |
+
""".format(
|
| 111 |
+
pr=self.pr
|
| 112 |
+
),
|
| 113 |
+
),
|
| 114 |
+
File(
|
| 115 |
+
".",
|
| 116 |
+
"prepare.sh",
|
| 117 |
+
"""#!/bin/bash
|
| 118 |
+
set -e
|
| 119 |
+
|
| 120 |
+
cd /home/{pr.repo}
|
| 121 |
+
git reset --hard
|
| 122 |
+
bash /home/check_git_changes.sh
|
| 123 |
+
git checkout {pr.base.sha}
|
| 124 |
+
bash /home/check_git_changes.sh
|
| 125 |
+
|
| 126 |
+
go test -v -count=1 ./... || true
|
| 127 |
+
|
| 128 |
+
""".format(
|
| 129 |
+
pr=self.pr
|
| 130 |
+
),
|
| 131 |
+
),
|
| 132 |
+
File(
|
| 133 |
+
".",
|
| 134 |
+
"run.sh",
|
| 135 |
+
"""#!/bin/bash
|
| 136 |
+
set -e
|
| 137 |
+
|
| 138 |
+
cd /home/{pr.repo}
|
| 139 |
+
go test -v -count=1 ./...
|
| 140 |
+
|
| 141 |
+
""".format(
|
| 142 |
+
pr=self.pr
|
| 143 |
+
),
|
| 144 |
+
),
|
| 145 |
+
File(
|
| 146 |
+
".",
|
| 147 |
+
"test-run.sh",
|
| 148 |
+
"""#!/bin/bash
|
| 149 |
+
set -e
|
| 150 |
+
|
| 151 |
+
cd /home/{pr.repo}
|
| 152 |
+
git apply /home/test.patch
|
| 153 |
+
go test -v -count=1 ./...
|
| 154 |
+
|
| 155 |
+
""".format(
|
| 156 |
+
pr=self.pr
|
| 157 |
+
),
|
| 158 |
+
),
|
| 159 |
+
File(
|
| 160 |
+
".",
|
| 161 |
+
"fix-run.sh",
|
| 162 |
+
"""#!/bin/bash
|
| 163 |
+
set -e
|
| 164 |
+
|
| 165 |
+
cd /home/{pr.repo}
|
| 166 |
+
git apply /home/test.patch /home/fix.patch
|
| 167 |
+
go test -v -count=1 ./...
|
| 168 |
+
|
| 169 |
+
""".format(
|
| 170 |
+
pr=self.pr
|
| 171 |
+
),
|
| 172 |
+
),
|
| 173 |
+
]
|
| 174 |
+
|
| 175 |
+
def dockerfile(self) -> str:
|
| 176 |
+
image = self.dependency()
|
| 177 |
+
name = image.image_name()
|
| 178 |
+
tag = image.image_tag()
|
| 179 |
+
|
| 180 |
+
copy_commands = ""
|
| 181 |
+
for file in self.files():
|
| 182 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 183 |
+
|
| 184 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 185 |
+
|
| 186 |
+
return f"""FROM {name}:{tag}
|
| 187 |
+
|
| 188 |
+
{self.global_env}
|
| 189 |
+
|
| 190 |
+
{copy_commands}
|
| 191 |
+
|
| 192 |
+
{prepare_commands}
|
| 193 |
+
|
| 194 |
+
{self.clear_env}
|
| 195 |
+
|
| 196 |
+
"""
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
@Instance.register("caddyserver", "caddy")
|
| 200 |
+
class Caddy(Instance):
|
| 201 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 202 |
+
super().__init__()
|
| 203 |
+
self._pr = pr
|
| 204 |
+
self._config = config
|
| 205 |
+
|
| 206 |
+
@property
|
| 207 |
+
def pr(self) -> PullRequest:
|
| 208 |
+
return self._pr
|
| 209 |
+
|
| 210 |
+
def dependency(self) -> Optional[Image]:
|
| 211 |
+
return CaddyImageDefault(self.pr, self._config)
|
| 212 |
+
|
| 213 |
+
def run(self, run_cmd: str = "") -> str:
|
| 214 |
+
if run_cmd:
|
| 215 |
+
return run_cmd
|
| 216 |
+
|
| 217 |
+
return "bash /home/run.sh"
|
| 218 |
+
|
| 219 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 220 |
+
if test_patch_run_cmd:
|
| 221 |
+
return test_patch_run_cmd
|
| 222 |
+
|
| 223 |
+
return "bash /home/test-run.sh"
|
| 224 |
+
|
| 225 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 226 |
+
if fix_patch_run_cmd:
|
| 227 |
+
return fix_patch_run_cmd
|
| 228 |
+
|
| 229 |
+
return "bash /home/fix-run.sh"
|
| 230 |
+
|
| 231 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 232 |
+
passed_tests = set()
|
| 233 |
+
failed_tests = set()
|
| 234 |
+
skipped_tests = set()
|
| 235 |
+
|
| 236 |
+
re_pass_tests = [re.compile(r"--- PASS: (\S+)")]
|
| 237 |
+
re_fail_tests = [
|
| 238 |
+
re.compile(r"--- FAIL: (\S+)"),
|
| 239 |
+
re.compile(r"FAIL:?\s?(.+?)\s"),
|
| 240 |
+
]
|
| 241 |
+
re_skip_tests = [re.compile(r"--- SKIP: (\S+)")]
|
| 242 |
+
|
| 243 |
+
def get_base_name(test_name: str) -> str:
|
| 244 |
+
return test_name
|
| 245 |
+
|
| 246 |
+
for line in test_log.splitlines():
|
| 247 |
+
line = line.strip()
|
| 248 |
+
|
| 249 |
+
for re_pass_test in re_pass_tests:
|
| 250 |
+
pass_match = re_pass_test.match(line)
|
| 251 |
+
if pass_match:
|
| 252 |
+
test_name = pass_match.group(1)
|
| 253 |
+
if test_name in failed_tests:
|
| 254 |
+
continue
|
| 255 |
+
if test_name in skipped_tests:
|
| 256 |
+
skipped_tests.remove(test_name)
|
| 257 |
+
passed_tests.add(get_base_name(test_name))
|
| 258 |
+
|
| 259 |
+
for re_fail_test in re_fail_tests:
|
| 260 |
+
fail_match = re_fail_test.match(line)
|
| 261 |
+
if fail_match:
|
| 262 |
+
test_name = fail_match.group(1)
|
| 263 |
+
if test_name in passed_tests:
|
| 264 |
+
passed_tests.remove(test_name)
|
| 265 |
+
if test_name in skipped_tests:
|
| 266 |
+
skipped_tests.remove(test_name)
|
| 267 |
+
failed_tests.add(get_base_name(test_name))
|
| 268 |
+
|
| 269 |
+
for re_skip_test in re_skip_tests:
|
| 270 |
+
skip_match = re_skip_test.match(line)
|
| 271 |
+
if skip_match:
|
| 272 |
+
test_name = skip_match.group(1)
|
| 273 |
+
if test_name in passed_tests:
|
| 274 |
+
continue
|
| 275 |
+
if test_name not in failed_tests:
|
| 276 |
+
continue
|
| 277 |
+
skipped_tests.add(get_base_name(test_name))
|
| 278 |
+
|
| 279 |
+
return TestResult(
|
| 280 |
+
passed_count=len(passed_tests),
|
| 281 |
+
failed_count=len(failed_tests),
|
| 282 |
+
skipped_count=len(skipped_tests),
|
| 283 |
+
passed_tests=passed_tests,
|
| 284 |
+
failed_tests=failed_tests,
|
| 285 |
+
skipped_tests=skipped_tests,
|
| 286 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/cli/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.eval.harness.repos.golang.cli.cli import *
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/cli/cli.py
ADDED
|
@@ -0,0 +1,286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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class CliImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "golang:latest"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
|
| 50 |
+
{code}
|
| 51 |
+
|
| 52 |
+
{self.clear_env}
|
| 53 |
+
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class CliImageDefault(Image):
|
| 58 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 59 |
+
self._pr = pr
|
| 60 |
+
self._config = config
|
| 61 |
+
|
| 62 |
+
@property
|
| 63 |
+
def pr(self) -> PullRequest:
|
| 64 |
+
return self._pr
|
| 65 |
+
|
| 66 |
+
@property
|
| 67 |
+
def config(self) -> Config:
|
| 68 |
+
return self._config
|
| 69 |
+
|
| 70 |
+
def dependency(self) -> Image | None:
|
| 71 |
+
return CliImageBase(self.pr, self.config)
|
| 72 |
+
|
| 73 |
+
def image_tag(self) -> str:
|
| 74 |
+
return f"pr-{self.pr.number}"
|
| 75 |
+
|
| 76 |
+
def workdir(self) -> str:
|
| 77 |
+
return f"pr-{self.pr.number}"
|
| 78 |
+
|
| 79 |
+
def files(self) -> list[File]:
|
| 80 |
+
return [
|
| 81 |
+
File(
|
| 82 |
+
".",
|
| 83 |
+
"fix.patch",
|
| 84 |
+
f"{self.pr.fix_patch}",
|
| 85 |
+
),
|
| 86 |
+
File(
|
| 87 |
+
".",
|
| 88 |
+
"test.patch",
|
| 89 |
+
f"{self.pr.test_patch}",
|
| 90 |
+
),
|
| 91 |
+
File(
|
| 92 |
+
".",
|
| 93 |
+
"check_git_changes.sh",
|
| 94 |
+
"""#!/bin/bash
|
| 95 |
+
set -e
|
| 96 |
+
|
| 97 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 98 |
+
echo "check_git_changes: Not inside a git repository"
|
| 99 |
+
exit 1
|
| 100 |
+
fi
|
| 101 |
+
|
| 102 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 103 |
+
echo "check_git_changes: Uncommitted changes"
|
| 104 |
+
exit 1
|
| 105 |
+
fi
|
| 106 |
+
|
| 107 |
+
echo "check_git_changes: No uncommitted changes"
|
| 108 |
+
exit 0
|
| 109 |
+
|
| 110 |
+
""".format(
|
| 111 |
+
pr=self.pr
|
| 112 |
+
),
|
| 113 |
+
),
|
| 114 |
+
File(
|
| 115 |
+
".",
|
| 116 |
+
"prepare.sh",
|
| 117 |
+
"""#!/bin/bash
|
| 118 |
+
set -e
|
| 119 |
+
|
| 120 |
+
cd /home/{pr.repo}
|
| 121 |
+
git reset --hard
|
| 122 |
+
bash /home/check_git_changes.sh
|
| 123 |
+
git checkout {pr.base.sha}
|
| 124 |
+
bash /home/check_git_changes.sh
|
| 125 |
+
|
| 126 |
+
go test -v -count=1 ./... || true
|
| 127 |
+
|
| 128 |
+
""".format(
|
| 129 |
+
pr=self.pr
|
| 130 |
+
),
|
| 131 |
+
),
|
| 132 |
+
File(
|
| 133 |
+
".",
|
| 134 |
+
"run.sh",
|
| 135 |
+
"""#!/bin/bash
|
| 136 |
+
set -e
|
| 137 |
+
|
| 138 |
+
cd /home/{pr.repo}
|
| 139 |
+
go test -v -count=1 ./...
|
| 140 |
+
|
| 141 |
+
""".format(
|
| 142 |
+
pr=self.pr
|
| 143 |
+
),
|
| 144 |
+
),
|
| 145 |
+
File(
|
| 146 |
+
".",
|
| 147 |
+
"test-run.sh",
|
| 148 |
+
"""#!/bin/bash
|
| 149 |
+
set -e
|
| 150 |
+
|
| 151 |
+
cd /home/{pr.repo}
|
| 152 |
+
git apply /home/test.patch
|
| 153 |
+
go test -v -count=1 ./...
|
| 154 |
+
|
| 155 |
+
""".format(
|
| 156 |
+
pr=self.pr
|
| 157 |
+
),
|
| 158 |
+
),
|
| 159 |
+
File(
|
| 160 |
+
".",
|
| 161 |
+
"fix-run.sh",
|
| 162 |
+
"""#!/bin/bash
|
| 163 |
+
set -e
|
| 164 |
+
|
| 165 |
+
cd /home/{pr.repo}
|
| 166 |
+
git apply /home/test.patch /home/fix.patch
|
| 167 |
+
go test -v -count=1 ./...
|
| 168 |
+
|
| 169 |
+
""".format(
|
| 170 |
+
pr=self.pr
|
| 171 |
+
),
|
| 172 |
+
),
|
| 173 |
+
]
|
| 174 |
+
|
| 175 |
+
def dockerfile(self) -> str:
|
| 176 |
+
image = self.dependency()
|
| 177 |
+
name = image.image_name()
|
| 178 |
+
tag = image.image_tag()
|
| 179 |
+
|
| 180 |
+
copy_commands = ""
|
| 181 |
+
for file in self.files():
|
| 182 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 183 |
+
|
| 184 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 185 |
+
|
| 186 |
+
return f"""FROM {name}:{tag}
|
| 187 |
+
|
| 188 |
+
{self.global_env}
|
| 189 |
+
|
| 190 |
+
{copy_commands}
|
| 191 |
+
|
| 192 |
+
{prepare_commands}
|
| 193 |
+
|
| 194 |
+
{self.clear_env}
|
| 195 |
+
|
| 196 |
+
"""
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
@Instance.register("cli", "cli")
|
| 200 |
+
class Cli(Instance):
|
| 201 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 202 |
+
super().__init__()
|
| 203 |
+
self._pr = pr
|
| 204 |
+
self._config = config
|
| 205 |
+
|
| 206 |
+
@property
|
| 207 |
+
def pr(self) -> PullRequest:
|
| 208 |
+
return self._pr
|
| 209 |
+
|
| 210 |
+
def dependency(self) -> Optional[Image]:
|
| 211 |
+
return CliImageDefault(self.pr, self._config)
|
| 212 |
+
|
| 213 |
+
def run(self, run_cmd: str = "") -> str:
|
| 214 |
+
if run_cmd:
|
| 215 |
+
return run_cmd
|
| 216 |
+
|
| 217 |
+
return "bash /home/run.sh"
|
| 218 |
+
|
| 219 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 220 |
+
if test_patch_run_cmd:
|
| 221 |
+
return test_patch_run_cmd
|
| 222 |
+
|
| 223 |
+
return "bash /home/test-run.sh"
|
| 224 |
+
|
| 225 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 226 |
+
if fix_patch_run_cmd:
|
| 227 |
+
return fix_patch_run_cmd
|
| 228 |
+
|
| 229 |
+
return "bash /home/fix-run.sh"
|
| 230 |
+
|
| 231 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 232 |
+
passed_tests = set()
|
| 233 |
+
failed_tests = set()
|
| 234 |
+
skipped_tests = set()
|
| 235 |
+
|
| 236 |
+
re_pass_tests = [re.compile(r"--- PASS: (\S+)")]
|
| 237 |
+
re_fail_tests = [
|
| 238 |
+
re.compile(r"--- FAIL: (\S+)"),
|
| 239 |
+
re.compile(r"FAIL:?\s?(.+?)\s"),
|
| 240 |
+
]
|
| 241 |
+
re_skip_tests = [re.compile(r"--- SKIP: (\S+)")]
|
| 242 |
+
|
| 243 |
+
def get_base_name(test_name: str) -> str:
|
| 244 |
+
return test_name
|
| 245 |
+
|
| 246 |
+
for line in test_log.splitlines():
|
| 247 |
+
line = line.strip()
|
| 248 |
+
|
| 249 |
+
for re_pass_test in re_pass_tests:
|
| 250 |
+
pass_match = re_pass_test.match(line)
|
| 251 |
+
if pass_match:
|
| 252 |
+
test_name = pass_match.group(1)
|
| 253 |
+
if test_name in failed_tests:
|
| 254 |
+
continue
|
| 255 |
+
if test_name in skipped_tests:
|
| 256 |
+
skipped_tests.remove(test_name)
|
| 257 |
+
passed_tests.add(get_base_name(test_name))
|
| 258 |
+
|
| 259 |
+
for re_fail_test in re_fail_tests:
|
| 260 |
+
fail_match = re_fail_test.match(line)
|
| 261 |
+
if fail_match:
|
| 262 |
+
test_name = fail_match.group(1)
|
| 263 |
+
if test_name in passed_tests:
|
| 264 |
+
passed_tests.remove(test_name)
|
| 265 |
+
if test_name in skipped_tests:
|
| 266 |
+
skipped_tests.remove(test_name)
|
| 267 |
+
failed_tests.add(get_base_name(test_name))
|
| 268 |
+
|
| 269 |
+
for re_skip_test in re_skip_tests:
|
| 270 |
+
skip_match = re_skip_test.match(line)
|
| 271 |
+
if skip_match:
|
| 272 |
+
test_name = skip_match.group(1)
|
| 273 |
+
if test_name in passed_tests:
|
| 274 |
+
continue
|
| 275 |
+
if test_name not in failed_tests:
|
| 276 |
+
continue
|
| 277 |
+
skipped_tests.add(get_base_name(test_name))
|
| 278 |
+
|
| 279 |
+
return TestResult(
|
| 280 |
+
passed_count=len(passed_tests),
|
| 281 |
+
failed_count=len(failed_tests),
|
| 282 |
+
skipped_count=len(skipped_tests),
|
| 283 |
+
passed_tests=passed_tests,
|
| 284 |
+
failed_tests=failed_tests,
|
| 285 |
+
skipped_tests=skipped_tests,
|
| 286 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/etcd_io/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.eval.harness.repos.golang.etc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|
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class EtcdImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "golang:latest"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
|
| 50 |
+
{code}
|
| 51 |
+
|
| 52 |
+
{self.clear_env}
|
| 53 |
+
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class EtcdImageDefault(Image):
|
| 58 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 59 |
+
self._pr = pr
|
| 60 |
+
self._config = config
|
| 61 |
+
|
| 62 |
+
@property
|
| 63 |
+
def pr(self) -> PullRequest:
|
| 64 |
+
return self._pr
|
| 65 |
+
|
| 66 |
+
@property
|
| 67 |
+
def config(self) -> Config:
|
| 68 |
+
return self._config
|
| 69 |
+
|
| 70 |
+
def dependency(self) -> Image | None:
|
| 71 |
+
return EtcdImageBase(self.pr, self.config)
|
| 72 |
+
|
| 73 |
+
def image_tag(self) -> str:
|
| 74 |
+
return f"pr-{self.pr.number}"
|
| 75 |
+
|
| 76 |
+
def workdir(self) -> str:
|
| 77 |
+
return f"pr-{self.pr.number}"
|
| 78 |
+
|
| 79 |
+
def files(self) -> list[File]:
|
| 80 |
+
return [
|
| 81 |
+
File(
|
| 82 |
+
".",
|
| 83 |
+
"fix.patch",
|
| 84 |
+
f"{self.pr.fix_patch}",
|
| 85 |
+
),
|
| 86 |
+
File(
|
| 87 |
+
".",
|
| 88 |
+
"test.patch",
|
| 89 |
+
f"{self.pr.test_patch}",
|
| 90 |
+
),
|
| 91 |
+
File(
|
| 92 |
+
".",
|
| 93 |
+
"check_git_changes.sh",
|
| 94 |
+
"""#!/bin/bash
|
| 95 |
+
set -e
|
| 96 |
+
|
| 97 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 98 |
+
echo "check_git_changes: Not inside a git repository"
|
| 99 |
+
exit 1
|
| 100 |
+
fi
|
| 101 |
+
|
| 102 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 103 |
+
echo "check_git_changes: Uncommitted changes"
|
| 104 |
+
exit 1
|
| 105 |
+
fi
|
| 106 |
+
|
| 107 |
+
echo "check_git_changes: No uncommitted changes"
|
| 108 |
+
exit 0
|
| 109 |
+
|
| 110 |
+
""".format(
|
| 111 |
+
pr=self.pr
|
| 112 |
+
),
|
| 113 |
+
),
|
| 114 |
+
File(
|
| 115 |
+
".",
|
| 116 |
+
"prepare.sh",
|
| 117 |
+
"""#!/bin/bash
|
| 118 |
+
set -e
|
| 119 |
+
|
| 120 |
+
cd /home/{pr.repo}
|
| 121 |
+
git reset --hard
|
| 122 |
+
bash /home/check_git_changes.sh
|
| 123 |
+
git checkout {pr.base.sha}
|
| 124 |
+
bash /home/check_git_changes.sh
|
| 125 |
+
|
| 126 |
+
bash /home/resolve_go_file.sh /home/{pr.repo}
|
| 127 |
+
go test -v -count=1 ./... || true
|
| 128 |
+
|
| 129 |
+
""".format(
|
| 130 |
+
pr=self.pr
|
| 131 |
+
),
|
| 132 |
+
),
|
| 133 |
+
File(
|
| 134 |
+
".",
|
| 135 |
+
"resolve_go_file.sh",
|
| 136 |
+
"""#!/bin/bash
|
| 137 |
+
|
| 138 |
+
if [ -z "$1" ]; then
|
| 139 |
+
echo "Usage: $0 <repository_path>"
|
| 140 |
+
exit 1
|
| 141 |
+
fi
|
| 142 |
+
|
| 143 |
+
REPO_PATH="$1"
|
| 144 |
+
|
| 145 |
+
find "$REPO_PATH" -type f -name "*.go" | while read -r file; do
|
| 146 |
+
if [[ $(cat "$file") =~ ^[./a-zA-Z0-9_\-]+\.go$ ]]; then
|
| 147 |
+
echo "Checking $file"
|
| 148 |
+
target_path=$(cat "$file")
|
| 149 |
+
abs_target_path=$(realpath -m "$(dirname "$file")/$target_path")
|
| 150 |
+
|
| 151 |
+
if [ -f "$abs_target_path" ]; then
|
| 152 |
+
echo "Replacing $file with content from $abs_target_path"
|
| 153 |
+
cat "$abs_target_path" > "$file"
|
| 154 |
+
else
|
| 155 |
+
echo "Warning: Target file $abs_target_path does not exist for $file"
|
| 156 |
+
fi
|
| 157 |
+
fi
|
| 158 |
+
done
|
| 159 |
+
|
| 160 |
+
echo "Done!"
|
| 161 |
+
|
| 162 |
+
""",
|
| 163 |
+
),
|
| 164 |
+
File(
|
| 165 |
+
".",
|
| 166 |
+
"run.sh",
|
| 167 |
+
"""#!/bin/bash
|
| 168 |
+
set -e
|
| 169 |
+
|
| 170 |
+
cd /home/{pr.repo}
|
| 171 |
+
go test -v -count=1 ./...
|
| 172 |
+
|
| 173 |
+
""".format(
|
| 174 |
+
pr=self.pr
|
| 175 |
+
),
|
| 176 |
+
),
|
| 177 |
+
File(
|
| 178 |
+
".",
|
| 179 |
+
"test-run.sh",
|
| 180 |
+
"""#!/bin/bash
|
| 181 |
+
set -e
|
| 182 |
+
|
| 183 |
+
cd /home/{pr.repo}
|
| 184 |
+
git apply /home/test.patch
|
| 185 |
+
go test -v -count=1 ./...
|
| 186 |
+
|
| 187 |
+
""".format(
|
| 188 |
+
pr=self.pr
|
| 189 |
+
),
|
| 190 |
+
),
|
| 191 |
+
File(
|
| 192 |
+
".",
|
| 193 |
+
"fix-run.sh",
|
| 194 |
+
"""#!/bin/bash
|
| 195 |
+
set -e
|
| 196 |
+
|
| 197 |
+
cd /home/{pr.repo}
|
| 198 |
+
git apply /home/test.patch /home/fix.patch
|
| 199 |
+
go test -v -count=1 ./...
|
| 200 |
+
|
| 201 |
+
""".format(
|
| 202 |
+
pr=self.pr
|
| 203 |
+
),
|
| 204 |
+
),
|
| 205 |
+
]
|
| 206 |
+
|
| 207 |
+
def dockerfile(self) -> str:
|
| 208 |
+
image = self.dependency()
|
| 209 |
+
name = image.image_name()
|
| 210 |
+
tag = image.image_tag()
|
| 211 |
+
|
| 212 |
+
copy_commands = ""
|
| 213 |
+
for file in self.files():
|
| 214 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 215 |
+
|
| 216 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 217 |
+
|
| 218 |
+
return f"""FROM {name}:{tag}
|
| 219 |
+
|
| 220 |
+
{self.global_env}
|
| 221 |
+
|
| 222 |
+
{copy_commands}
|
| 223 |
+
|
| 224 |
+
{prepare_commands}
|
| 225 |
+
|
| 226 |
+
{self.clear_env}
|
| 227 |
+
|
| 228 |
+
"""
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
@Instance.register("etcd-io", "etcd")
|
| 232 |
+
class Etcd(Instance):
|
| 233 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 234 |
+
super().__init__()
|
| 235 |
+
self._pr = pr
|
| 236 |
+
self._config = config
|
| 237 |
+
|
| 238 |
+
@property
|
| 239 |
+
def pr(self) -> PullRequest:
|
| 240 |
+
return self._pr
|
| 241 |
+
|
| 242 |
+
def dependency(self) -> Optional[Image]:
|
| 243 |
+
return EtcdImageDefault(self.pr, self._config)
|
| 244 |
+
|
| 245 |
+
def run(self, run_cmd: str = "") -> str:
|
| 246 |
+
if run_cmd:
|
| 247 |
+
return run_cmd
|
| 248 |
+
|
| 249 |
+
return "bash /home/run.sh"
|
| 250 |
+
|
| 251 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 252 |
+
if test_patch_run_cmd:
|
| 253 |
+
return test_patch_run_cmd
|
| 254 |
+
|
| 255 |
+
return "bash /home/test-run.sh"
|
| 256 |
+
|
| 257 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 258 |
+
if fix_patch_run_cmd:
|
| 259 |
+
return fix_patch_run_cmd
|
| 260 |
+
|
| 261 |
+
return "bash /home/fix-run.sh"
|
| 262 |
+
|
| 263 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 264 |
+
passed_tests = set()
|
| 265 |
+
failed_tests = set()
|
| 266 |
+
skipped_tests = set()
|
| 267 |
+
|
| 268 |
+
re_pass_tests = [re.compile(r"--- PASS: (\S+)")]
|
| 269 |
+
re_fail_tests = [
|
| 270 |
+
re.compile(r"--- FAIL: (\S+)"),
|
| 271 |
+
re.compile(r"FAIL:?\s?(.+?)\s"),
|
| 272 |
+
]
|
| 273 |
+
re_skip_tests = [re.compile(r"--- SKIP: (\S+)")]
|
| 274 |
+
|
| 275 |
+
def get_base_name(test_name: str) -> str:
|
| 276 |
+
index = test_name.rfind("/")
|
| 277 |
+
if index == -1:
|
| 278 |
+
return test_name
|
| 279 |
+
return test_name[:index]
|
| 280 |
+
|
| 281 |
+
for line in test_log.splitlines():
|
| 282 |
+
line = line.strip()
|
| 283 |
+
|
| 284 |
+
for re_pass_test in re_pass_tests:
|
| 285 |
+
pass_match = re_pass_test.match(line)
|
| 286 |
+
if pass_match:
|
| 287 |
+
test_name = pass_match.group(1)
|
| 288 |
+
if test_name in failed_tests:
|
| 289 |
+
continue
|
| 290 |
+
if test_name in skipped_tests:
|
| 291 |
+
skipped_tests.remove(test_name)
|
| 292 |
+
passed_tests.add(get_base_name(test_name))
|
| 293 |
+
|
| 294 |
+
for re_fail_test in re_fail_tests:
|
| 295 |
+
fail_match = re_fail_test.match(line)
|
| 296 |
+
if fail_match:
|
| 297 |
+
test_name = fail_match.group(1)
|
| 298 |
+
if test_name in passed_tests:
|
| 299 |
+
passed_tests.remove(test_name)
|
| 300 |
+
if test_name in skipped_tests:
|
| 301 |
+
skipped_tests.remove(test_name)
|
| 302 |
+
failed_tests.add(get_base_name(test_name))
|
| 303 |
+
|
| 304 |
+
for re_skip_test in re_skip_tests:
|
| 305 |
+
skip_match = re_skip_test.match(line)
|
| 306 |
+
if skip_match:
|
| 307 |
+
test_name = skip_match.group(1)
|
| 308 |
+
if test_name in passed_tests:
|
| 309 |
+
continue
|
| 310 |
+
if test_name not in failed_tests:
|
| 311 |
+
continue
|
| 312 |
+
skipped_tests.add(get_base_name(test_name))
|
| 313 |
+
|
| 314 |
+
return TestResult(
|
| 315 |
+
passed_count=len(passed_tests),
|
| 316 |
+
failed_count=len(failed_tests),
|
| 317 |
+
skipped_count=len(skipped_tests),
|
| 318 |
+
passed_tests=passed_tests,
|
| 319 |
+
failed_tests=failed_tests,
|
| 320 |
+
skipped_tests=skipped_tests,
|
| 321 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/fatedier/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.e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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class FrpImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "golang:latest"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
|
| 50 |
+
{code}
|
| 51 |
+
|
| 52 |
+
{self.clear_env}
|
| 53 |
+
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class FrpImageDefault(Image):
|
| 58 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 59 |
+
self._pr = pr
|
| 60 |
+
self._config = config
|
| 61 |
+
|
| 62 |
+
@property
|
| 63 |
+
def pr(self) -> PullRequest:
|
| 64 |
+
return self._pr
|
| 65 |
+
|
| 66 |
+
@property
|
| 67 |
+
def config(self) -> Config:
|
| 68 |
+
return self._config
|
| 69 |
+
|
| 70 |
+
def dependency(self) -> Image | None:
|
| 71 |
+
return FrpImageBase(self.pr, self.config)
|
| 72 |
+
|
| 73 |
+
def image_tag(self) -> str:
|
| 74 |
+
return f"pr-{self.pr.number}"
|
| 75 |
+
|
| 76 |
+
def workdir(self) -> str:
|
| 77 |
+
return f"pr-{self.pr.number}"
|
| 78 |
+
|
| 79 |
+
def files(self) -> list[File]:
|
| 80 |
+
return [
|
| 81 |
+
File(
|
| 82 |
+
".",
|
| 83 |
+
"fix.patch",
|
| 84 |
+
f"{self.pr.fix_patch}",
|
| 85 |
+
),
|
| 86 |
+
File(
|
| 87 |
+
".",
|
| 88 |
+
"test.patch",
|
| 89 |
+
f"{self.pr.test_patch}",
|
| 90 |
+
),
|
| 91 |
+
File(
|
| 92 |
+
".",
|
| 93 |
+
"check_git_changes.sh",
|
| 94 |
+
"""#!/bin/bash
|
| 95 |
+
set -e
|
| 96 |
+
|
| 97 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 98 |
+
echo "check_git_changes: Not inside a git repository"
|
| 99 |
+
exit 1
|
| 100 |
+
fi
|
| 101 |
+
|
| 102 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 103 |
+
echo "check_git_changes: Uncommitted changes"
|
| 104 |
+
exit 1
|
| 105 |
+
fi
|
| 106 |
+
|
| 107 |
+
echo "check_git_changes: No uncommitted changes"
|
| 108 |
+
exit 0
|
| 109 |
+
|
| 110 |
+
""".format(
|
| 111 |
+
pr=self.pr
|
| 112 |
+
),
|
| 113 |
+
),
|
| 114 |
+
File(
|
| 115 |
+
".",
|
| 116 |
+
"prepare.sh",
|
| 117 |
+
"""#!/bin/bash
|
| 118 |
+
set -e
|
| 119 |
+
|
| 120 |
+
cd /home/{pr.repo}
|
| 121 |
+
git reset --hard
|
| 122 |
+
bash /home/check_git_changes.sh
|
| 123 |
+
git checkout {pr.base.sha}
|
| 124 |
+
bash /home/check_git_changes.sh
|
| 125 |
+
|
| 126 |
+
go test -v -count=1 ./... || true
|
| 127 |
+
|
| 128 |
+
""".format(
|
| 129 |
+
pr=self.pr
|
| 130 |
+
),
|
| 131 |
+
),
|
| 132 |
+
File(
|
| 133 |
+
".",
|
| 134 |
+
"run.sh",
|
| 135 |
+
"""#!/bin/bash
|
| 136 |
+
set -e
|
| 137 |
+
|
| 138 |
+
cd /home/{pr.repo}
|
| 139 |
+
go test -v -count=1 ./...
|
| 140 |
+
|
| 141 |
+
""".format(
|
| 142 |
+
pr=self.pr
|
| 143 |
+
),
|
| 144 |
+
),
|
| 145 |
+
File(
|
| 146 |
+
".",
|
| 147 |
+
"test-run.sh",
|
| 148 |
+
"""#!/bin/bash
|
| 149 |
+
set -e
|
| 150 |
+
|
| 151 |
+
cd /home/{pr.repo}
|
| 152 |
+
git apply /home/test.patch
|
| 153 |
+
go test -v -count=1 ./...
|
| 154 |
+
|
| 155 |
+
""".format(
|
| 156 |
+
pr=self.pr
|
| 157 |
+
),
|
| 158 |
+
),
|
| 159 |
+
File(
|
| 160 |
+
".",
|
| 161 |
+
"fix-run.sh",
|
| 162 |
+
"""#!/bin/bash
|
| 163 |
+
set -e
|
| 164 |
+
|
| 165 |
+
cd /home/{pr.repo}
|
| 166 |
+
git apply /home/test.patch /home/fix.patch
|
| 167 |
+
go test -v -count=1 ./...
|
| 168 |
+
|
| 169 |
+
""".format(
|
| 170 |
+
pr=self.pr
|
| 171 |
+
),
|
| 172 |
+
),
|
| 173 |
+
]
|
| 174 |
+
|
| 175 |
+
def dockerfile(self) -> str:
|
| 176 |
+
image = self.dependency()
|
| 177 |
+
name = image.image_name()
|
| 178 |
+
tag = image.image_tag()
|
| 179 |
+
|
| 180 |
+
copy_commands = ""
|
| 181 |
+
for file in self.files():
|
| 182 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 183 |
+
|
| 184 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 185 |
+
|
| 186 |
+
return f"""FROM {name}:{tag}
|
| 187 |
+
|
| 188 |
+
{self.global_env}
|
| 189 |
+
|
| 190 |
+
{copy_commands}
|
| 191 |
+
|
| 192 |
+
{prepare_commands}
|
| 193 |
+
|
| 194 |
+
{self.clear_env}
|
| 195 |
+
|
| 196 |
+
"""
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
@Instance.register("fatedier", "frp")
|
| 200 |
+
class Frp(Instance):
|
| 201 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 202 |
+
super().__init__()
|
| 203 |
+
self._pr = pr
|
| 204 |
+
self._config = config
|
| 205 |
+
|
| 206 |
+
@property
|
| 207 |
+
def pr(self) -> PullRequest:
|
| 208 |
+
return self._pr
|
| 209 |
+
|
| 210 |
+
def dependency(self) -> Optional[Image]:
|
| 211 |
+
return FrpImageDefault(self.pr, self._config)
|
| 212 |
+
|
| 213 |
+
def run(self, run_cmd: str = "") -> str:
|
| 214 |
+
if run_cmd:
|
| 215 |
+
return run_cmd
|
| 216 |
+
|
| 217 |
+
return "bash /home/run.sh"
|
| 218 |
+
|
| 219 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 220 |
+
if test_patch_run_cmd:
|
| 221 |
+
return test_patch_run_cmd
|
| 222 |
+
|
| 223 |
+
return "bash /home/test-run.sh"
|
| 224 |
+
|
| 225 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 226 |
+
if fix_patch_run_cmd:
|
| 227 |
+
return fix_patch_run_cmd
|
| 228 |
+
|
| 229 |
+
return "bash /home/fix-run.sh"
|
| 230 |
+
|
| 231 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 232 |
+
passed_tests = set()
|
| 233 |
+
failed_tests = set()
|
| 234 |
+
skipped_tests = set()
|
| 235 |
+
|
| 236 |
+
re_pass_tests = [re.compile(r"--- PASS: (\S+)")]
|
| 237 |
+
re_fail_tests = [
|
| 238 |
+
re.compile(r"--- FAIL: (\S+)"),
|
| 239 |
+
re.compile(r"FAIL:?\s?(.+?)\s"),
|
| 240 |
+
]
|
| 241 |
+
re_skip_tests = [re.compile(r"--- SKIP: (\S+)")]
|
| 242 |
+
|
| 243 |
+
def get_base_name(test_name: str) -> str:
|
| 244 |
+
return test_name
|
| 245 |
+
|
| 246 |
+
for line in test_log.splitlines():
|
| 247 |
+
line = line.strip()
|
| 248 |
+
|
| 249 |
+
for re_pass_test in re_pass_tests:
|
| 250 |
+
pass_match = re_pass_test.match(line)
|
| 251 |
+
if pass_match:
|
| 252 |
+
test_name = pass_match.group(1)
|
| 253 |
+
if test_name in failed_tests:
|
| 254 |
+
continue
|
| 255 |
+
if test_name in skipped_tests:
|
| 256 |
+
skipped_tests.remove(test_name)
|
| 257 |
+
passed_tests.add(get_base_name(test_name))
|
| 258 |
+
|
| 259 |
+
for re_fail_test in re_fail_tests:
|
| 260 |
+
fail_match = re_fail_test.match(line)
|
| 261 |
+
if fail_match:
|
| 262 |
+
test_name = fail_match.group(1)
|
| 263 |
+
if test_name in passed_tests:
|
| 264 |
+
passed_tests.remove(test_name)
|
| 265 |
+
if test_name in skipped_tests:
|
| 266 |
+
skipped_tests.remove(test_name)
|
| 267 |
+
failed_tests.add(get_base_name(test_name))
|
| 268 |
+
|
| 269 |
+
for re_skip_test in re_skip_tests:
|
| 270 |
+
skip_match = re_skip_test.match(line)
|
| 271 |
+
if skip_match:
|
| 272 |
+
test_name = skip_match.group(1)
|
| 273 |
+
if test_name in passed_tests:
|
| 274 |
+
continue
|
| 275 |
+
if test_name not in failed_tests:
|
| 276 |
+
continue
|
| 277 |
+
skipped_tests.add(get_base_name(test_name))
|
| 278 |
+
|
| 279 |
+
return TestResult(
|
| 280 |
+
passed_count=len(passed_tests),
|
| 281 |
+
failed_count=len(failed_tests),
|
| 282 |
+
skipped_count=len(skipped_tests),
|
| 283 |
+
passed_tests=passed_tests,
|
| 284 |
+
failed_tests=failed_tests,
|
| 285 |
+
skipped_tests=skipped_tests,
|
| 286 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/gin_gonic/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.eval.harness.repos.golang.gin_gonic.gin import *
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/gin_gonic/gin.py
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class GinImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "golang:latest"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
|
| 50 |
+
{code}
|
| 51 |
+
|
| 52 |
+
{self.clear_env}
|
| 53 |
+
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class GinImageDefault(Image):
|
| 58 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 59 |
+
self._pr = pr
|
| 60 |
+
self._config = config
|
| 61 |
+
|
| 62 |
+
@property
|
| 63 |
+
def pr(self) -> PullRequest:
|
| 64 |
+
return self._pr
|
| 65 |
+
|
| 66 |
+
@property
|
| 67 |
+
def config(self) -> Config:
|
| 68 |
+
return self._config
|
| 69 |
+
|
| 70 |
+
def dependency(self) -> Image | None:
|
| 71 |
+
return GinImageBase(self.pr, self.config)
|
| 72 |
+
|
| 73 |
+
def image_tag(self) -> str:
|
| 74 |
+
return f"pr-{self.pr.number}"
|
| 75 |
+
|
| 76 |
+
def workdir(self) -> str:
|
| 77 |
+
return f"pr-{self.pr.number}"
|
| 78 |
+
|
| 79 |
+
def files(self) -> list[File]:
|
| 80 |
+
return [
|
| 81 |
+
File(
|
| 82 |
+
".",
|
| 83 |
+
"fix.patch",
|
| 84 |
+
f"{self.pr.fix_patch}",
|
| 85 |
+
),
|
| 86 |
+
File(
|
| 87 |
+
".",
|
| 88 |
+
"test.patch",
|
| 89 |
+
f"{self.pr.test_patch}",
|
| 90 |
+
),
|
| 91 |
+
File(
|
| 92 |
+
".",
|
| 93 |
+
"check_git_changes.sh",
|
| 94 |
+
"""#!/bin/bash
|
| 95 |
+
set -e
|
| 96 |
+
|
| 97 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 98 |
+
echo "check_git_changes: Not inside a git repository"
|
| 99 |
+
exit 1
|
| 100 |
+
fi
|
| 101 |
+
|
| 102 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 103 |
+
echo "check_git_changes: Uncommitted changes"
|
| 104 |
+
exit 1
|
| 105 |
+
fi
|
| 106 |
+
|
| 107 |
+
echo "check_git_changes: No uncommitted changes"
|
| 108 |
+
exit 0
|
| 109 |
+
|
| 110 |
+
""".format(
|
| 111 |
+
pr=self.pr
|
| 112 |
+
),
|
| 113 |
+
),
|
| 114 |
+
File(
|
| 115 |
+
".",
|
| 116 |
+
"prepare.sh",
|
| 117 |
+
"""#!/bin/bash
|
| 118 |
+
set -e
|
| 119 |
+
|
| 120 |
+
cd /home/{pr.repo}
|
| 121 |
+
git reset --hard
|
| 122 |
+
bash /home/check_git_changes.sh
|
| 123 |
+
git checkout {pr.base.sha}
|
| 124 |
+
bash /home/check_git_changes.sh
|
| 125 |
+
|
| 126 |
+
go test -v -count=1 ./... || true
|
| 127 |
+
|
| 128 |
+
""".format(
|
| 129 |
+
pr=self.pr
|
| 130 |
+
),
|
| 131 |
+
),
|
| 132 |
+
File(
|
| 133 |
+
".",
|
| 134 |
+
"run.sh",
|
| 135 |
+
"""#!/bin/bash
|
| 136 |
+
set -e
|
| 137 |
+
|
| 138 |
+
cd /home/{pr.repo}
|
| 139 |
+
go test -v -count=1 ./...
|
| 140 |
+
|
| 141 |
+
""".format(
|
| 142 |
+
pr=self.pr
|
| 143 |
+
),
|
| 144 |
+
),
|
| 145 |
+
File(
|
| 146 |
+
".",
|
| 147 |
+
"test-run.sh",
|
| 148 |
+
"""#!/bin/bash
|
| 149 |
+
set -e
|
| 150 |
+
|
| 151 |
+
cd /home/{pr.repo}
|
| 152 |
+
git apply /home/test.patch
|
| 153 |
+
go test -v -count=1 ./...
|
| 154 |
+
|
| 155 |
+
""".format(
|
| 156 |
+
pr=self.pr
|
| 157 |
+
),
|
| 158 |
+
),
|
| 159 |
+
File(
|
| 160 |
+
".",
|
| 161 |
+
"fix-run.sh",
|
| 162 |
+
"""#!/bin/bash
|
| 163 |
+
set -e
|
| 164 |
+
|
| 165 |
+
cd /home/{pr.repo}
|
| 166 |
+
git apply /home/test.patch /home/fix.patch
|
| 167 |
+
go test -v -count=1 ./...
|
| 168 |
+
|
| 169 |
+
""".format(
|
| 170 |
+
pr=self.pr
|
| 171 |
+
),
|
| 172 |
+
),
|
| 173 |
+
]
|
| 174 |
+
|
| 175 |
+
def dockerfile(self) -> str:
|
| 176 |
+
image = self.dependency()
|
| 177 |
+
name = image.image_name()
|
| 178 |
+
tag = image.image_tag()
|
| 179 |
+
|
| 180 |
+
copy_commands = ""
|
| 181 |
+
for file in self.files():
|
| 182 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 183 |
+
|
| 184 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 185 |
+
|
| 186 |
+
return f"""FROM {name}:{tag}
|
| 187 |
+
|
| 188 |
+
{self.global_env}
|
| 189 |
+
|
| 190 |
+
{copy_commands}
|
| 191 |
+
|
| 192 |
+
{prepare_commands}
|
| 193 |
+
|
| 194 |
+
{self.clear_env}
|
| 195 |
+
|
| 196 |
+
"""
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
@Instance.register("gin-gonic", "gin")
|
| 200 |
+
class Gin(Instance):
|
| 201 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 202 |
+
super().__init__()
|
| 203 |
+
self._pr = pr
|
| 204 |
+
self._config = config
|
| 205 |
+
|
| 206 |
+
@property
|
| 207 |
+
def pr(self) -> PullRequest:
|
| 208 |
+
return self._pr
|
| 209 |
+
|
| 210 |
+
def dependency(self) -> Optional[Image]:
|
| 211 |
+
return GinImageDefault(self.pr, self._config)
|
| 212 |
+
|
| 213 |
+
def run(self, run_cmd: str = "") -> str:
|
| 214 |
+
if run_cmd:
|
| 215 |
+
return run_cmd
|
| 216 |
+
|
| 217 |
+
return "bash /home/run.sh"
|
| 218 |
+
|
| 219 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 220 |
+
if test_patch_run_cmd:
|
| 221 |
+
return test_patch_run_cmd
|
| 222 |
+
|
| 223 |
+
return "bash /home/test-run.sh"
|
| 224 |
+
|
| 225 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 226 |
+
if fix_patch_run_cmd:
|
| 227 |
+
return fix_patch_run_cmd
|
| 228 |
+
|
| 229 |
+
return "bash /home/fix-run.sh"
|
| 230 |
+
|
| 231 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 232 |
+
passed_tests = set()
|
| 233 |
+
failed_tests = set()
|
| 234 |
+
skipped_tests = set()
|
| 235 |
+
|
| 236 |
+
re_pass_tests = [re.compile(r"--- PASS: (\S+)")]
|
| 237 |
+
re_fail_tests = [
|
| 238 |
+
re.compile(r"--- FAIL: (\S+)"),
|
| 239 |
+
re.compile(r"FAIL:?\s?(.+?)\s"),
|
| 240 |
+
]
|
| 241 |
+
re_skip_tests = [re.compile(r"--- SKIP: (\S+)")]
|
| 242 |
+
|
| 243 |
+
def get_base_name(test_name: str) -> str:
|
| 244 |
+
index = test_name.rfind("/")
|
| 245 |
+
if index == -1:
|
| 246 |
+
return test_name
|
| 247 |
+
return test_name[:index]
|
| 248 |
+
|
| 249 |
+
for line in test_log.splitlines():
|
| 250 |
+
line = line.strip()
|
| 251 |
+
|
| 252 |
+
for re_pass_test in re_pass_tests:
|
| 253 |
+
pass_match = re_pass_test.match(line)
|
| 254 |
+
if pass_match:
|
| 255 |
+
test_name = pass_match.group(1)
|
| 256 |
+
if test_name in failed_tests:
|
| 257 |
+
continue
|
| 258 |
+
if test_name in skipped_tests:
|
| 259 |
+
skipped_tests.remove(test_name)
|
| 260 |
+
passed_tests.add(get_base_name(test_name))
|
| 261 |
+
|
| 262 |
+
for re_fail_test in re_fail_tests:
|
| 263 |
+
fail_match = re_fail_test.match(line)
|
| 264 |
+
if fail_match:
|
| 265 |
+
test_name = fail_match.group(1)
|
| 266 |
+
if test_name in passed_tests:
|
| 267 |
+
passed_tests.remove(test_name)
|
| 268 |
+
if test_name in skipped_tests:
|
| 269 |
+
skipped_tests.remove(test_name)
|
| 270 |
+
failed_tests.add(get_base_name(test_name))
|
| 271 |
+
|
| 272 |
+
for re_skip_test in re_skip_tests:
|
| 273 |
+
skip_match = re_skip_test.match(line)
|
| 274 |
+
if skip_match:
|
| 275 |
+
test_name = skip_match.group(1)
|
| 276 |
+
if test_name in passed_tests:
|
| 277 |
+
continue
|
| 278 |
+
if test_name not in failed_tests:
|
| 279 |
+
continue
|
| 280 |
+
skipped_tests.add(get_base_name(test_name))
|
| 281 |
+
|
| 282 |
+
return TestResult(
|
| 283 |
+
passed_count=len(passed_tests),
|
| 284 |
+
failed_count=len(failed_tests),
|
| 285 |
+
skipped_count=len(skipped_tests),
|
| 286 |
+
passed_tests=passed_tests,
|
| 287 |
+
failed_tests=failed_tests,
|
| 288 |
+
skipped_tests=skipped_tests,
|
| 289 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/go_gorm/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.eval.harness.repos.golang.go_gorm.gorm import *
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/go_gorm/gorm.py
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class GormImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "golang:latest"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
|
| 50 |
+
{code}
|
| 51 |
+
|
| 52 |
+
{self.clear_env}
|
| 53 |
+
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class GormImageDefault(Image):
|
| 58 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 59 |
+
self._pr = pr
|
| 60 |
+
self._config = config
|
| 61 |
+
|
| 62 |
+
@property
|
| 63 |
+
def pr(self) -> PullRequest:
|
| 64 |
+
return self._pr
|
| 65 |
+
|
| 66 |
+
@property
|
| 67 |
+
def config(self) -> Config:
|
| 68 |
+
return self._config
|
| 69 |
+
|
| 70 |
+
def dependency(self) -> Image | None:
|
| 71 |
+
return GormImageBase(self.pr, self.config)
|
| 72 |
+
|
| 73 |
+
def image_tag(self) -> str:
|
| 74 |
+
return f"pr-{self.pr.number}"
|
| 75 |
+
|
| 76 |
+
def workdir(self) -> str:
|
| 77 |
+
return f"pr-{self.pr.number}"
|
| 78 |
+
|
| 79 |
+
def files(self) -> list[File]:
|
| 80 |
+
return [
|
| 81 |
+
File(
|
| 82 |
+
".",
|
| 83 |
+
"fix.patch",
|
| 84 |
+
f"{self.pr.fix_patch}",
|
| 85 |
+
),
|
| 86 |
+
File(
|
| 87 |
+
".",
|
| 88 |
+
"test.patch",
|
| 89 |
+
f"{self.pr.test_patch}",
|
| 90 |
+
),
|
| 91 |
+
File(
|
| 92 |
+
".",
|
| 93 |
+
"check_git_changes.sh",
|
| 94 |
+
"""#!/bin/bash
|
| 95 |
+
set -e
|
| 96 |
+
|
| 97 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 98 |
+
echo "check_git_changes: Not inside a git repository"
|
| 99 |
+
exit 1
|
| 100 |
+
fi
|
| 101 |
+
|
| 102 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 103 |
+
echo "check_git_changes: Uncommitted changes"
|
| 104 |
+
exit 1
|
| 105 |
+
fi
|
| 106 |
+
|
| 107 |
+
echo "check_git_changes: No uncommitted changes"
|
| 108 |
+
exit 0
|
| 109 |
+
|
| 110 |
+
""".format(
|
| 111 |
+
pr=self.pr
|
| 112 |
+
),
|
| 113 |
+
),
|
| 114 |
+
File(
|
| 115 |
+
".",
|
| 116 |
+
"prepare.sh",
|
| 117 |
+
"""#!/bin/bash
|
| 118 |
+
set -e
|
| 119 |
+
|
| 120 |
+
cd /home/{pr.repo}
|
| 121 |
+
git reset --hard
|
| 122 |
+
bash /home/check_git_changes.sh
|
| 123 |
+
git checkout {pr.base.sha}
|
| 124 |
+
bash /home/check_git_changes.sh
|
| 125 |
+
|
| 126 |
+
go test -v -count=1 ./... || true
|
| 127 |
+
|
| 128 |
+
""".format(
|
| 129 |
+
pr=self.pr
|
| 130 |
+
),
|
| 131 |
+
),
|
| 132 |
+
File(
|
| 133 |
+
".",
|
| 134 |
+
"run.sh",
|
| 135 |
+
"""#!/bin/bash
|
| 136 |
+
set -e
|
| 137 |
+
|
| 138 |
+
cd /home/{pr.repo}
|
| 139 |
+
go test -v -count=1 ./...
|
| 140 |
+
|
| 141 |
+
""".format(
|
| 142 |
+
pr=self.pr
|
| 143 |
+
),
|
| 144 |
+
),
|
| 145 |
+
File(
|
| 146 |
+
".",
|
| 147 |
+
"test-run.sh",
|
| 148 |
+
"""#!/bin/bash
|
| 149 |
+
set -e
|
| 150 |
+
|
| 151 |
+
cd /home/{pr.repo}
|
| 152 |
+
git apply /home/test.patch
|
| 153 |
+
go test -v -count=1 ./...
|
| 154 |
+
|
| 155 |
+
""".format(
|
| 156 |
+
pr=self.pr
|
| 157 |
+
),
|
| 158 |
+
),
|
| 159 |
+
File(
|
| 160 |
+
".",
|
| 161 |
+
"fix-run.sh",
|
| 162 |
+
"""#!/bin/bash
|
| 163 |
+
set -e
|
| 164 |
+
|
| 165 |
+
cd /home/{pr.repo}
|
| 166 |
+
git apply /home/test.patch /home/fix.patch
|
| 167 |
+
go test -v -count=1 ./...
|
| 168 |
+
|
| 169 |
+
""".format(
|
| 170 |
+
pr=self.pr
|
| 171 |
+
),
|
| 172 |
+
),
|
| 173 |
+
]
|
| 174 |
+
|
| 175 |
+
def dockerfile(self) -> str:
|
| 176 |
+
image = self.dependency()
|
| 177 |
+
name = image.image_name()
|
| 178 |
+
tag = image.image_tag()
|
| 179 |
+
|
| 180 |
+
copy_commands = ""
|
| 181 |
+
for file in self.files():
|
| 182 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 183 |
+
|
| 184 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 185 |
+
|
| 186 |
+
return f"""FROM {name}:{tag}
|
| 187 |
+
|
| 188 |
+
{self.global_env}
|
| 189 |
+
|
| 190 |
+
{copy_commands}
|
| 191 |
+
|
| 192 |
+
{prepare_commands}
|
| 193 |
+
|
| 194 |
+
{self.clear_env}
|
| 195 |
+
|
| 196 |
+
"""
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
@Instance.register("go-gorm", "gorm")
|
| 200 |
+
class Gorm(Instance):
|
| 201 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 202 |
+
super().__init__()
|
| 203 |
+
self._pr = pr
|
| 204 |
+
self._config = config
|
| 205 |
+
|
| 206 |
+
@property
|
| 207 |
+
def pr(self) -> PullRequest:
|
| 208 |
+
return self._pr
|
| 209 |
+
|
| 210 |
+
def dependency(self) -> Optional[Image]:
|
| 211 |
+
return GormImageDefault(self.pr, self._config)
|
| 212 |
+
|
| 213 |
+
def run(self, run_cmd: str = "") -> str:
|
| 214 |
+
if run_cmd:
|
| 215 |
+
return run_cmd
|
| 216 |
+
|
| 217 |
+
return "bash /home/run.sh"
|
| 218 |
+
|
| 219 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 220 |
+
if test_patch_run_cmd:
|
| 221 |
+
return test_patch_run_cmd
|
| 222 |
+
|
| 223 |
+
return "bash /home/test-run.sh"
|
| 224 |
+
|
| 225 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 226 |
+
if fix_patch_run_cmd:
|
| 227 |
+
return fix_patch_run_cmd
|
| 228 |
+
|
| 229 |
+
return "bash /home/fix-run.sh"
|
| 230 |
+
|
| 231 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 232 |
+
passed_tests = set()
|
| 233 |
+
failed_tests = set()
|
| 234 |
+
skipped_tests = set()
|
| 235 |
+
|
| 236 |
+
re_pass_tests = [re.compile(r"--- PASS: (\S+)")]
|
| 237 |
+
re_fail_tests = [
|
| 238 |
+
re.compile(r"--- FAIL: (\S+)"),
|
| 239 |
+
re.compile(r"FAIL:?\s?(.+?)\s"),
|
| 240 |
+
]
|
| 241 |
+
re_skip_tests = [re.compile(r"--- SKIP: (\S+)")]
|
| 242 |
+
|
| 243 |
+
def get_base_name(test_name: str) -> str:
|
| 244 |
+
index = test_name.rfind("/")
|
| 245 |
+
if index == -1:
|
| 246 |
+
return test_name
|
| 247 |
+
return test_name[:index]
|
| 248 |
+
|
| 249 |
+
for line in test_log.splitlines():
|
| 250 |
+
line = line.strip()
|
| 251 |
+
|
| 252 |
+
for re_pass_test in re_pass_tests:
|
| 253 |
+
pass_match = re_pass_test.match(line)
|
| 254 |
+
if pass_match:
|
| 255 |
+
test_name = pass_match.group(1)
|
| 256 |
+
if test_name in failed_tests:
|
| 257 |
+
continue
|
| 258 |
+
if test_name in skipped_tests:
|
| 259 |
+
skipped_tests.remove(test_name)
|
| 260 |
+
passed_tests.add(get_base_name(test_name))
|
| 261 |
+
|
| 262 |
+
for re_fail_test in re_fail_tests:
|
| 263 |
+
fail_match = re_fail_test.match(line)
|
| 264 |
+
if fail_match:
|
| 265 |
+
test_name = fail_match.group(1)
|
| 266 |
+
if test_name in passed_tests:
|
| 267 |
+
passed_tests.remove(test_name)
|
| 268 |
+
if test_name in skipped_tests:
|
| 269 |
+
skipped_tests.remove(test_name)
|
| 270 |
+
failed_tests.add(get_base_name(test_name))
|
| 271 |
+
|
| 272 |
+
for re_skip_test in re_skip_tests:
|
| 273 |
+
skip_match = re_skip_test.match(line)
|
| 274 |
+
if skip_match:
|
| 275 |
+
test_name = skip_match.group(1)
|
| 276 |
+
if test_name in passed_tests:
|
| 277 |
+
continue
|
| 278 |
+
if test_name not in failed_tests:
|
| 279 |
+
continue
|
| 280 |
+
skipped_tests.add(get_base_name(test_name))
|
| 281 |
+
|
| 282 |
+
return TestResult(
|
| 283 |
+
passed_count=len(passed_tests),
|
| 284 |
+
failed_count=len(failed_tests),
|
| 285 |
+
skipped_count=len(skipped_tests),
|
| 286 |
+
passed_tests=passed_tests,
|
| 287 |
+
failed_tests=failed_tests,
|
| 288 |
+
skipped_tests=skipped_tests,
|
| 289 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/gohugoio/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.eval.harness.repos.golang.gohugoio.hugo import *
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/gohugoio/hugo.py
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class HugoImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "golang:latest"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
|
| 50 |
+
{code}
|
| 51 |
+
|
| 52 |
+
{self.clear_env}
|
| 53 |
+
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class HugoImageDefault(Image):
|
| 58 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 59 |
+
self._pr = pr
|
| 60 |
+
self._config = config
|
| 61 |
+
|
| 62 |
+
@property
|
| 63 |
+
def pr(self) -> PullRequest:
|
| 64 |
+
return self._pr
|
| 65 |
+
|
| 66 |
+
@property
|
| 67 |
+
def config(self) -> Config:
|
| 68 |
+
return self._config
|
| 69 |
+
|
| 70 |
+
def dependency(self) -> Image | None:
|
| 71 |
+
return HugoImageBase(self.pr, self.config)
|
| 72 |
+
|
| 73 |
+
def image_tag(self) -> str:
|
| 74 |
+
return f"pr-{self.pr.number}"
|
| 75 |
+
|
| 76 |
+
def workdir(self) -> str:
|
| 77 |
+
return f"pr-{self.pr.number}"
|
| 78 |
+
|
| 79 |
+
def files(self) -> list[File]:
|
| 80 |
+
return [
|
| 81 |
+
File(
|
| 82 |
+
".",
|
| 83 |
+
"fix.patch",
|
| 84 |
+
f"{self.pr.fix_patch}",
|
| 85 |
+
),
|
| 86 |
+
File(
|
| 87 |
+
".",
|
| 88 |
+
"test.patch",
|
| 89 |
+
f"{self.pr.test_patch}",
|
| 90 |
+
),
|
| 91 |
+
File(
|
| 92 |
+
".",
|
| 93 |
+
"check_git_changes.sh",
|
| 94 |
+
"""#!/bin/bash
|
| 95 |
+
set -e
|
| 96 |
+
|
| 97 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 98 |
+
echo "check_git_changes: Not inside a git repository"
|
| 99 |
+
exit 1
|
| 100 |
+
fi
|
| 101 |
+
|
| 102 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 103 |
+
echo "check_git_changes: Uncommitted changes"
|
| 104 |
+
exit 1
|
| 105 |
+
fi
|
| 106 |
+
|
| 107 |
+
echo "check_git_changes: No uncommitted changes"
|
| 108 |
+
exit 0
|
| 109 |
+
|
| 110 |
+
""".format(
|
| 111 |
+
pr=self.pr
|
| 112 |
+
),
|
| 113 |
+
),
|
| 114 |
+
File(
|
| 115 |
+
".",
|
| 116 |
+
"prepare.sh",
|
| 117 |
+
"""#!/bin/bash
|
| 118 |
+
set -e
|
| 119 |
+
|
| 120 |
+
cd /home/{pr.repo}
|
| 121 |
+
git reset --hard
|
| 122 |
+
bash /home/check_git_changes.sh
|
| 123 |
+
git checkout {pr.base.sha}
|
| 124 |
+
bash /home/check_git_changes.sh
|
| 125 |
+
|
| 126 |
+
go test -v -count=1 ./... || true
|
| 127 |
+
|
| 128 |
+
""".format(
|
| 129 |
+
pr=self.pr
|
| 130 |
+
),
|
| 131 |
+
),
|
| 132 |
+
File(
|
| 133 |
+
".",
|
| 134 |
+
"run.sh",
|
| 135 |
+
"""#!/bin/bash
|
| 136 |
+
set -e
|
| 137 |
+
|
| 138 |
+
cd /home/{pr.repo}
|
| 139 |
+
go test -v -count=1 ./...
|
| 140 |
+
|
| 141 |
+
""".format(
|
| 142 |
+
pr=self.pr
|
| 143 |
+
),
|
| 144 |
+
),
|
| 145 |
+
File(
|
| 146 |
+
".",
|
| 147 |
+
"test-run.sh",
|
| 148 |
+
"""#!/bin/bash
|
| 149 |
+
set -e
|
| 150 |
+
|
| 151 |
+
cd /home/{pr.repo}
|
| 152 |
+
git apply /home/test.patch
|
| 153 |
+
go test -v -count=1 ./...
|
| 154 |
+
|
| 155 |
+
""".format(
|
| 156 |
+
pr=self.pr
|
| 157 |
+
),
|
| 158 |
+
),
|
| 159 |
+
File(
|
| 160 |
+
".",
|
| 161 |
+
"fix-run.sh",
|
| 162 |
+
"""#!/bin/bash
|
| 163 |
+
set -e
|
| 164 |
+
|
| 165 |
+
cd /home/{pr.repo}
|
| 166 |
+
git apply /home/test.patch /home/fix.patch
|
| 167 |
+
go test -v -count=1 ./...
|
| 168 |
+
|
| 169 |
+
""".format(
|
| 170 |
+
pr=self.pr
|
| 171 |
+
),
|
| 172 |
+
),
|
| 173 |
+
]
|
| 174 |
+
|
| 175 |
+
def dockerfile(self) -> str:
|
| 176 |
+
image = self.dependency()
|
| 177 |
+
name = image.image_name()
|
| 178 |
+
tag = image.image_tag()
|
| 179 |
+
|
| 180 |
+
copy_commands = ""
|
| 181 |
+
for file in self.files():
|
| 182 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 183 |
+
|
| 184 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 185 |
+
|
| 186 |
+
return f"""FROM {name}:{tag}
|
| 187 |
+
|
| 188 |
+
{self.global_env}
|
| 189 |
+
|
| 190 |
+
{copy_commands}
|
| 191 |
+
|
| 192 |
+
{prepare_commands}
|
| 193 |
+
|
| 194 |
+
{self.clear_env}
|
| 195 |
+
|
| 196 |
+
"""
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
@Instance.register("gohugoio", "hugo")
|
| 200 |
+
class Hugo(Instance):
|
| 201 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 202 |
+
super().__init__()
|
| 203 |
+
self._pr = pr
|
| 204 |
+
self._config = config
|
| 205 |
+
|
| 206 |
+
@property
|
| 207 |
+
def pr(self) -> PullRequest:
|
| 208 |
+
return self._pr
|
| 209 |
+
|
| 210 |
+
def dependency(self) -> Optional[Image]:
|
| 211 |
+
return HugoImageDefault(self.pr, self._config)
|
| 212 |
+
|
| 213 |
+
def run(self, run_cmd: str = "") -> str:
|
| 214 |
+
if run_cmd:
|
| 215 |
+
return run_cmd
|
| 216 |
+
|
| 217 |
+
return "bash /home/run.sh"
|
| 218 |
+
|
| 219 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 220 |
+
if test_patch_run_cmd:
|
| 221 |
+
return test_patch_run_cmd
|
| 222 |
+
|
| 223 |
+
return "bash /home/test-run.sh"
|
| 224 |
+
|
| 225 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 226 |
+
if fix_patch_run_cmd:
|
| 227 |
+
return fix_patch_run_cmd
|
| 228 |
+
|
| 229 |
+
return "bash /home/fix-run.sh"
|
| 230 |
+
|
| 231 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 232 |
+
passed_tests = set()
|
| 233 |
+
failed_tests = set()
|
| 234 |
+
skipped_tests = set()
|
| 235 |
+
|
| 236 |
+
re_pass_tests = [re.compile(r"--- PASS: (\S+)")]
|
| 237 |
+
re_fail_tests = [
|
| 238 |
+
re.compile(r"--- FAIL: (\S+)"),
|
| 239 |
+
re.compile(r"FAIL:?\s?(.+?)\s"),
|
| 240 |
+
]
|
| 241 |
+
re_skip_tests = [re.compile(r"--- SKIP: (\S+)")]
|
| 242 |
+
|
| 243 |
+
def get_base_name(test_name: str) -> str:
|
| 244 |
+
return test_name
|
| 245 |
+
|
| 246 |
+
for line in test_log.splitlines():
|
| 247 |
+
line = line.strip()
|
| 248 |
+
|
| 249 |
+
for re_pass_test in re_pass_tests:
|
| 250 |
+
pass_match = re_pass_test.match(line)
|
| 251 |
+
if pass_match:
|
| 252 |
+
test_name = pass_match.group(1)
|
| 253 |
+
if test_name in failed_tests:
|
| 254 |
+
continue
|
| 255 |
+
if test_name in skipped_tests:
|
| 256 |
+
skipped_tests.remove(test_name)
|
| 257 |
+
passed_tests.add(get_base_name(test_name))
|
| 258 |
+
|
| 259 |
+
for re_fail_test in re_fail_tests:
|
| 260 |
+
fail_match = re_fail_test.match(line)
|
| 261 |
+
if fail_match:
|
| 262 |
+
test_name = fail_match.group(1)
|
| 263 |
+
if test_name in passed_tests:
|
| 264 |
+
passed_tests.remove(test_name)
|
| 265 |
+
if test_name in skipped_tests:
|
| 266 |
+
skipped_tests.remove(test_name)
|
| 267 |
+
failed_tests.add(get_base_name(test_name))
|
| 268 |
+
|
| 269 |
+
for re_skip_test in re_skip_tests:
|
| 270 |
+
skip_match = re_skip_test.match(line)
|
| 271 |
+
if skip_match:
|
| 272 |
+
test_name = skip_match.group(1)
|
| 273 |
+
if test_name in passed_tests:
|
| 274 |
+
continue
|
| 275 |
+
if test_name not in failed_tests:
|
| 276 |
+
continue
|
| 277 |
+
skipped_tests.add(get_base_name(test_name))
|
| 278 |
+
|
| 279 |
+
return TestResult(
|
| 280 |
+
passed_count=len(passed_tests),
|
| 281 |
+
failed_count=len(failed_tests),
|
| 282 |
+
skipped_count=len(skipped_tests),
|
| 283 |
+
passed_tests=passed_tests,
|
| 284 |
+
failed_tests=failed_tests,
|
| 285 |
+
skipped_tests=skipped_tests,
|
| 286 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/grpc/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.eval.harness.repos.golang.grpc.grpc_go import *
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/grpc/grpc_go.py
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class GrpcGoImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "golang:latest"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
|
| 50 |
+
{code}
|
| 51 |
+
|
| 52 |
+
{self.clear_env}
|
| 53 |
+
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class GrpcGoImageDefault(Image):
|
| 58 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 59 |
+
self._pr = pr
|
| 60 |
+
self._config = config
|
| 61 |
+
|
| 62 |
+
@property
|
| 63 |
+
def pr(self) -> PullRequest:
|
| 64 |
+
return self._pr
|
| 65 |
+
|
| 66 |
+
@property
|
| 67 |
+
def config(self) -> Config:
|
| 68 |
+
return self._config
|
| 69 |
+
|
| 70 |
+
def dependency(self) -> Image | None:
|
| 71 |
+
return GrpcGoImageBase(self.pr, self.config)
|
| 72 |
+
|
| 73 |
+
def image_tag(self) -> str:
|
| 74 |
+
return f"pr-{self.pr.number}"
|
| 75 |
+
|
| 76 |
+
def workdir(self) -> str:
|
| 77 |
+
return f"pr-{self.pr.number}"
|
| 78 |
+
|
| 79 |
+
def files(self) -> list[File]:
|
| 80 |
+
return [
|
| 81 |
+
File(
|
| 82 |
+
".",
|
| 83 |
+
"fix.patch",
|
| 84 |
+
f"{self.pr.fix_patch}",
|
| 85 |
+
),
|
| 86 |
+
File(
|
| 87 |
+
".",
|
| 88 |
+
"test.patch",
|
| 89 |
+
f"{self.pr.test_patch}",
|
| 90 |
+
),
|
| 91 |
+
File(
|
| 92 |
+
".",
|
| 93 |
+
"check_git_changes.sh",
|
| 94 |
+
"""#!/bin/bash
|
| 95 |
+
set -e
|
| 96 |
+
|
| 97 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 98 |
+
echo "check_git_changes: Not inside a git repository"
|
| 99 |
+
exit 1
|
| 100 |
+
fi
|
| 101 |
+
|
| 102 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 103 |
+
echo "check_git_changes: Uncommitted changes"
|
| 104 |
+
exit 1
|
| 105 |
+
fi
|
| 106 |
+
|
| 107 |
+
echo "check_git_changes: No uncommitted changes"
|
| 108 |
+
exit 0
|
| 109 |
+
|
| 110 |
+
""".format(
|
| 111 |
+
pr=self.pr
|
| 112 |
+
),
|
| 113 |
+
),
|
| 114 |
+
File(
|
| 115 |
+
".",
|
| 116 |
+
"prepare.sh",
|
| 117 |
+
"""#!/bin/bash
|
| 118 |
+
set -e
|
| 119 |
+
|
| 120 |
+
cd /home/{pr.repo}
|
| 121 |
+
git reset --hard
|
| 122 |
+
bash /home/check_git_changes.sh
|
| 123 |
+
git checkout {pr.base.sha}
|
| 124 |
+
bash /home/check_git_changes.sh
|
| 125 |
+
|
| 126 |
+
go test -v -count=1 ./... || true
|
| 127 |
+
|
| 128 |
+
""".format(
|
| 129 |
+
pr=self.pr
|
| 130 |
+
),
|
| 131 |
+
),
|
| 132 |
+
File(
|
| 133 |
+
".",
|
| 134 |
+
"run.sh",
|
| 135 |
+
"""#!/bin/bash
|
| 136 |
+
set -e
|
| 137 |
+
|
| 138 |
+
cd /home/{pr.repo}
|
| 139 |
+
go test -v -count=1 ./...
|
| 140 |
+
|
| 141 |
+
""".format(
|
| 142 |
+
pr=self.pr
|
| 143 |
+
),
|
| 144 |
+
),
|
| 145 |
+
File(
|
| 146 |
+
".",
|
| 147 |
+
"test-run.sh",
|
| 148 |
+
"""#!/bin/bash
|
| 149 |
+
set -e
|
| 150 |
+
|
| 151 |
+
cd /home/{pr.repo}
|
| 152 |
+
git apply /home/test.patch
|
| 153 |
+
go test -v -count=1 ./...
|
| 154 |
+
|
| 155 |
+
""".format(
|
| 156 |
+
pr=self.pr
|
| 157 |
+
),
|
| 158 |
+
),
|
| 159 |
+
File(
|
| 160 |
+
".",
|
| 161 |
+
"fix-run.sh",
|
| 162 |
+
"""#!/bin/bash
|
| 163 |
+
set -e
|
| 164 |
+
|
| 165 |
+
cd /home/{pr.repo}
|
| 166 |
+
git apply /home/test.patch /home/fix.patch
|
| 167 |
+
go test -v -count=1 ./...
|
| 168 |
+
|
| 169 |
+
""".format(
|
| 170 |
+
pr=self.pr
|
| 171 |
+
),
|
| 172 |
+
),
|
| 173 |
+
]
|
| 174 |
+
|
| 175 |
+
def dockerfile(self) -> str:
|
| 176 |
+
image = self.dependency()
|
| 177 |
+
name = image.image_name()
|
| 178 |
+
tag = image.image_tag()
|
| 179 |
+
|
| 180 |
+
copy_commands = ""
|
| 181 |
+
for file in self.files():
|
| 182 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 183 |
+
|
| 184 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 185 |
+
|
| 186 |
+
return f"""FROM {name}:{tag}
|
| 187 |
+
|
| 188 |
+
{self.global_env}
|
| 189 |
+
|
| 190 |
+
{copy_commands}
|
| 191 |
+
|
| 192 |
+
{prepare_commands}
|
| 193 |
+
|
| 194 |
+
{self.clear_env}
|
| 195 |
+
|
| 196 |
+
"""
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
@Instance.register("grpc", "grpc-go")
|
| 200 |
+
class GrpcGo(Instance):
|
| 201 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 202 |
+
super().__init__()
|
| 203 |
+
self._pr = pr
|
| 204 |
+
self._config = config
|
| 205 |
+
|
| 206 |
+
@property
|
| 207 |
+
def pr(self) -> PullRequest:
|
| 208 |
+
return self._pr
|
| 209 |
+
|
| 210 |
+
def dependency(self) -> Optional[Image]:
|
| 211 |
+
return GrpcGoImageDefault(self.pr, self._config)
|
| 212 |
+
|
| 213 |
+
def run(self, run_cmd: str = "") -> str:
|
| 214 |
+
if run_cmd:
|
| 215 |
+
return run_cmd
|
| 216 |
+
|
| 217 |
+
return "bash /home/run.sh"
|
| 218 |
+
|
| 219 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 220 |
+
if test_patch_run_cmd:
|
| 221 |
+
return test_patch_run_cmd
|
| 222 |
+
|
| 223 |
+
return "bash /home/test-run.sh"
|
| 224 |
+
|
| 225 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 226 |
+
if fix_patch_run_cmd:
|
| 227 |
+
return fix_patch_run_cmd
|
| 228 |
+
|
| 229 |
+
return "bash /home/fix-run.sh"
|
| 230 |
+
|
| 231 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 232 |
+
passed_tests = set()
|
| 233 |
+
failed_tests = set()
|
| 234 |
+
skipped_tests = set()
|
| 235 |
+
|
| 236 |
+
re_pass_tests = [re.compile(r"--- PASS: (\S+)")]
|
| 237 |
+
re_fail_tests = [
|
| 238 |
+
re.compile(r"--- FAIL: (\S+)"),
|
| 239 |
+
re.compile(r"FAIL:?\s?(.+?)\s"),
|
| 240 |
+
]
|
| 241 |
+
re_skip_tests = [re.compile(r"--- SKIP: (\S+)")]
|
| 242 |
+
|
| 243 |
+
def get_base_name(test_name: str) -> str:
|
| 244 |
+
index = test_name.rfind("/")
|
| 245 |
+
if index == -1:
|
| 246 |
+
return test_name
|
| 247 |
+
return test_name[:index]
|
| 248 |
+
|
| 249 |
+
for line in test_log.splitlines():
|
| 250 |
+
line = line.strip()
|
| 251 |
+
|
| 252 |
+
for re_pass_test in re_pass_tests:
|
| 253 |
+
pass_match = re_pass_test.match(line)
|
| 254 |
+
if pass_match:
|
| 255 |
+
test_name = pass_match.group(1)
|
| 256 |
+
if test_name in failed_tests:
|
| 257 |
+
continue
|
| 258 |
+
if test_name in skipped_tests:
|
| 259 |
+
skipped_tests.remove(test_name)
|
| 260 |
+
passed_tests.add(get_base_name(test_name))
|
| 261 |
+
|
| 262 |
+
for re_fail_test in re_fail_tests:
|
| 263 |
+
fail_match = re_fail_test.match(line)
|
| 264 |
+
if fail_match:
|
| 265 |
+
test_name = fail_match.group(1)
|
| 266 |
+
if test_name in passed_tests:
|
| 267 |
+
passed_tests.remove(test_name)
|
| 268 |
+
if test_name in skipped_tests:
|
| 269 |
+
skipped_tests.remove(test_name)
|
| 270 |
+
failed_tests.add(get_base_name(test_name))
|
| 271 |
+
|
| 272 |
+
for re_skip_test in re_skip_tests:
|
| 273 |
+
skip_match = re_skip_test.match(line)
|
| 274 |
+
if skip_match:
|
| 275 |
+
test_name = skip_match.group(1)
|
| 276 |
+
if test_name in passed_tests:
|
| 277 |
+
continue
|
| 278 |
+
if test_name not in failed_tests:
|
| 279 |
+
continue
|
| 280 |
+
skipped_tests.add(get_base_name(test_name))
|
| 281 |
+
|
| 282 |
+
return TestResult(
|
| 283 |
+
passed_count=len(passed_tests),
|
| 284 |
+
failed_count=len(failed_tests),
|
| 285 |
+
skipped_count=len(skipped_tests),
|
| 286 |
+
passed_tests=passed_tests,
|
| 287 |
+
failed_tests=failed_tests,
|
| 288 |
+
skipped_tests=skipped_tests,
|
| 289 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/istio/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.eval.harness.repos.golang.istio.istio import *
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/istio/istio.py
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class IstioImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "golang:latest"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
|
| 50 |
+
{code}
|
| 51 |
+
|
| 52 |
+
{self.clear_env}
|
| 53 |
+
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class IstioImageDefault(Image):
|
| 58 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 59 |
+
self._pr = pr
|
| 60 |
+
self._config = config
|
| 61 |
+
|
| 62 |
+
@property
|
| 63 |
+
def pr(self) -> PullRequest:
|
| 64 |
+
return self._pr
|
| 65 |
+
|
| 66 |
+
@property
|
| 67 |
+
def config(self) -> Config:
|
| 68 |
+
return self._config
|
| 69 |
+
|
| 70 |
+
def dependency(self) -> Image | None:
|
| 71 |
+
return IstioImageBase(self.pr, self.config)
|
| 72 |
+
|
| 73 |
+
def image_tag(self) -> str:
|
| 74 |
+
return f"pr-{self.pr.number}"
|
| 75 |
+
|
| 76 |
+
def workdir(self) -> str:
|
| 77 |
+
return f"pr-{self.pr.number}"
|
| 78 |
+
|
| 79 |
+
def files(self) -> list[File]:
|
| 80 |
+
return [
|
| 81 |
+
File(
|
| 82 |
+
".",
|
| 83 |
+
"fix.patch",
|
| 84 |
+
f"{self.pr.fix_patch}",
|
| 85 |
+
),
|
| 86 |
+
File(
|
| 87 |
+
".",
|
| 88 |
+
"test.patch",
|
| 89 |
+
f"{self.pr.test_patch}",
|
| 90 |
+
),
|
| 91 |
+
File(
|
| 92 |
+
".",
|
| 93 |
+
"check_git_changes.sh",
|
| 94 |
+
"""#!/bin/bash
|
| 95 |
+
set -e
|
| 96 |
+
|
| 97 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 98 |
+
echo "check_git_changes: Not inside a git repository"
|
| 99 |
+
exit 1
|
| 100 |
+
fi
|
| 101 |
+
|
| 102 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 103 |
+
echo "check_git_changes: Uncommitted changes"
|
| 104 |
+
exit 1
|
| 105 |
+
fi
|
| 106 |
+
|
| 107 |
+
echo "check_git_changes: No uncommitted changes"
|
| 108 |
+
exit 0
|
| 109 |
+
|
| 110 |
+
""".format(
|
| 111 |
+
pr=self.pr
|
| 112 |
+
),
|
| 113 |
+
),
|
| 114 |
+
File(
|
| 115 |
+
".",
|
| 116 |
+
"prepare.sh",
|
| 117 |
+
"""#!/bin/bash
|
| 118 |
+
set -e
|
| 119 |
+
|
| 120 |
+
cd /home/{pr.repo}
|
| 121 |
+
git reset --hard
|
| 122 |
+
bash /home/check_git_changes.sh
|
| 123 |
+
git checkout {pr.base.sha}
|
| 124 |
+
bash /home/check_git_changes.sh
|
| 125 |
+
|
| 126 |
+
go test -v -count=1 ./... || true
|
| 127 |
+
|
| 128 |
+
""".format(
|
| 129 |
+
pr=self.pr
|
| 130 |
+
),
|
| 131 |
+
),
|
| 132 |
+
File(
|
| 133 |
+
".",
|
| 134 |
+
"run.sh",
|
| 135 |
+
"""#!/bin/bash
|
| 136 |
+
set -e
|
| 137 |
+
|
| 138 |
+
cd /home/{pr.repo}
|
| 139 |
+
go test -v -count=1 ./...
|
| 140 |
+
|
| 141 |
+
""".format(
|
| 142 |
+
pr=self.pr
|
| 143 |
+
),
|
| 144 |
+
),
|
| 145 |
+
File(
|
| 146 |
+
".",
|
| 147 |
+
"test-run.sh",
|
| 148 |
+
"""#!/bin/bash
|
| 149 |
+
set -e
|
| 150 |
+
|
| 151 |
+
cd /home/{pr.repo}
|
| 152 |
+
git apply /home/test.patch
|
| 153 |
+
go test -v -count=1 ./...
|
| 154 |
+
|
| 155 |
+
""".format(
|
| 156 |
+
pr=self.pr
|
| 157 |
+
),
|
| 158 |
+
),
|
| 159 |
+
File(
|
| 160 |
+
".",
|
| 161 |
+
"fix-run.sh",
|
| 162 |
+
"""#!/bin/bash
|
| 163 |
+
set -e
|
| 164 |
+
|
| 165 |
+
cd /home/{pr.repo}
|
| 166 |
+
git apply /home/test.patch /home/fix.patch
|
| 167 |
+
go test -v -count=1 ./...
|
| 168 |
+
|
| 169 |
+
""".format(
|
| 170 |
+
pr=self.pr
|
| 171 |
+
),
|
| 172 |
+
),
|
| 173 |
+
]
|
| 174 |
+
|
| 175 |
+
def dockerfile(self) -> str:
|
| 176 |
+
image = self.dependency()
|
| 177 |
+
name = image.image_name()
|
| 178 |
+
tag = image.image_tag()
|
| 179 |
+
|
| 180 |
+
copy_commands = ""
|
| 181 |
+
for file in self.files():
|
| 182 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 183 |
+
|
| 184 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 185 |
+
|
| 186 |
+
return f"""FROM {name}:{tag}
|
| 187 |
+
|
| 188 |
+
{self.global_env}
|
| 189 |
+
|
| 190 |
+
{copy_commands}
|
| 191 |
+
|
| 192 |
+
{prepare_commands}
|
| 193 |
+
|
| 194 |
+
{self.clear_env}
|
| 195 |
+
|
| 196 |
+
"""
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
@Instance.register("istio", "istio")
|
| 200 |
+
class Istio(Instance):
|
| 201 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 202 |
+
super().__init__()
|
| 203 |
+
self._pr = pr
|
| 204 |
+
self._config = config
|
| 205 |
+
|
| 206 |
+
@property
|
| 207 |
+
def pr(self) -> PullRequest:
|
| 208 |
+
return self._pr
|
| 209 |
+
|
| 210 |
+
def dependency(self) -> Optional[Image]:
|
| 211 |
+
return IstioImageDefault(self.pr, self._config)
|
| 212 |
+
|
| 213 |
+
def run(self, run_cmd: str = "") -> str:
|
| 214 |
+
if run_cmd:
|
| 215 |
+
return run_cmd
|
| 216 |
+
|
| 217 |
+
return "bash /home/run.sh"
|
| 218 |
+
|
| 219 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 220 |
+
if test_patch_run_cmd:
|
| 221 |
+
return test_patch_run_cmd
|
| 222 |
+
|
| 223 |
+
return "bash /home/test-run.sh"
|
| 224 |
+
|
| 225 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 226 |
+
if fix_patch_run_cmd:
|
| 227 |
+
return fix_patch_run_cmd
|
| 228 |
+
|
| 229 |
+
return "bash /home/fix-run.sh"
|
| 230 |
+
|
| 231 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 232 |
+
passed_tests = set()
|
| 233 |
+
failed_tests = set()
|
| 234 |
+
skipped_tests = set()
|
| 235 |
+
|
| 236 |
+
re_pass_tests = [re.compile(r"--- PASS: (\S+)")]
|
| 237 |
+
re_fail_tests = [
|
| 238 |
+
re.compile(r"--- FAIL: (\S+)"),
|
| 239 |
+
re.compile(r"FAIL:?\s?(.+?)\s"),
|
| 240 |
+
]
|
| 241 |
+
re_skip_tests = [re.compile(r"--- SKIP: (\S+)")]
|
| 242 |
+
|
| 243 |
+
def get_base_name(test_name: str) -> str:
|
| 244 |
+
return test_name
|
| 245 |
+
|
| 246 |
+
for line in test_log.splitlines():
|
| 247 |
+
line = line.strip()
|
| 248 |
+
|
| 249 |
+
for re_pass_test in re_pass_tests:
|
| 250 |
+
pass_match = re_pass_test.match(line)
|
| 251 |
+
if pass_match:
|
| 252 |
+
test_name = pass_match.group(1)
|
| 253 |
+
if test_name in failed_tests:
|
| 254 |
+
continue
|
| 255 |
+
if test_name in skipped_tests:
|
| 256 |
+
skipped_tests.remove(test_name)
|
| 257 |
+
passed_tests.add(get_base_name(test_name))
|
| 258 |
+
|
| 259 |
+
for re_fail_test in re_fail_tests:
|
| 260 |
+
fail_match = re_fail_test.match(line)
|
| 261 |
+
if fail_match:
|
| 262 |
+
test_name = fail_match.group(1)
|
| 263 |
+
if test_name in passed_tests:
|
| 264 |
+
passed_tests.remove(test_name)
|
| 265 |
+
if test_name in skipped_tests:
|
| 266 |
+
skipped_tests.remove(test_name)
|
| 267 |
+
failed_tests.add(get_base_name(test_name))
|
| 268 |
+
|
| 269 |
+
for re_skip_test in re_skip_tests:
|
| 270 |
+
skip_match = re_skip_test.match(line)
|
| 271 |
+
if skip_match:
|
| 272 |
+
test_name = skip_match.group(1)
|
| 273 |
+
if test_name in passed_tests:
|
| 274 |
+
continue
|
| 275 |
+
if test_name not in failed_tests:
|
| 276 |
+
continue
|
| 277 |
+
skipped_tests.add(get_base_name(test_name))
|
| 278 |
+
|
| 279 |
+
return TestResult(
|
| 280 |
+
passed_count=len(passed_tests),
|
| 281 |
+
failed_count=len(failed_tests),
|
| 282 |
+
skipped_count=len(skipped_tests),
|
| 283 |
+
passed_tests=passed_tests,
|
| 284 |
+
failed_tests=failed_tests,
|
| 285 |
+
skipped_tests=skipped_tests,
|
| 286 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/jesseduffield/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.eval.harness.repos.golang.jesseduffield.lazygit import *
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/jesseduffield/lazygit.py
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class LazygitImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "golang:latest"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
|
| 50 |
+
{code}
|
| 51 |
+
|
| 52 |
+
{self.clear_env}
|
| 53 |
+
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class LazygitImageDefault(Image):
|
| 58 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 59 |
+
self._pr = pr
|
| 60 |
+
self._config = config
|
| 61 |
+
|
| 62 |
+
@property
|
| 63 |
+
def pr(self) -> PullRequest:
|
| 64 |
+
return self._pr
|
| 65 |
+
|
| 66 |
+
@property
|
| 67 |
+
def config(self) -> Config:
|
| 68 |
+
return self._config
|
| 69 |
+
|
| 70 |
+
def dependency(self) -> Image | None:
|
| 71 |
+
return LazygitImageBase(self.pr, self.config)
|
| 72 |
+
|
| 73 |
+
def image_tag(self) -> str:
|
| 74 |
+
return f"pr-{self.pr.number}"
|
| 75 |
+
|
| 76 |
+
def workdir(self) -> str:
|
| 77 |
+
return f"pr-{self.pr.number}"
|
| 78 |
+
|
| 79 |
+
def files(self) -> list[File]:
|
| 80 |
+
return [
|
| 81 |
+
File(
|
| 82 |
+
".",
|
| 83 |
+
"fix.patch",
|
| 84 |
+
f"{self.pr.fix_patch}",
|
| 85 |
+
),
|
| 86 |
+
File(
|
| 87 |
+
".",
|
| 88 |
+
"test.patch",
|
| 89 |
+
f"{self.pr.test_patch}",
|
| 90 |
+
),
|
| 91 |
+
File(
|
| 92 |
+
".",
|
| 93 |
+
"check_git_changes.sh",
|
| 94 |
+
"""#!/bin/bash
|
| 95 |
+
set -e
|
| 96 |
+
|
| 97 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 98 |
+
echo "check_git_changes: Not inside a git repository"
|
| 99 |
+
exit 1
|
| 100 |
+
fi
|
| 101 |
+
|
| 102 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 103 |
+
echo "check_git_changes: Uncommitted changes"
|
| 104 |
+
exit 1
|
| 105 |
+
fi
|
| 106 |
+
|
| 107 |
+
echo "check_git_changes: No uncommitted changes"
|
| 108 |
+
exit 0
|
| 109 |
+
|
| 110 |
+
""".format(
|
| 111 |
+
pr=self.pr
|
| 112 |
+
),
|
| 113 |
+
),
|
| 114 |
+
File(
|
| 115 |
+
".",
|
| 116 |
+
"prepare.sh",
|
| 117 |
+
"""#!/bin/bash
|
| 118 |
+
set -e
|
| 119 |
+
|
| 120 |
+
cd /home/{pr.repo}
|
| 121 |
+
git reset --hard
|
| 122 |
+
bash /home/check_git_changes.sh
|
| 123 |
+
git checkout {pr.base.sha}
|
| 124 |
+
bash /home/check_git_changes.sh
|
| 125 |
+
|
| 126 |
+
go test -v -count=1 ./... || true
|
| 127 |
+
|
| 128 |
+
""".format(
|
| 129 |
+
pr=self.pr
|
| 130 |
+
),
|
| 131 |
+
),
|
| 132 |
+
File(
|
| 133 |
+
".",
|
| 134 |
+
"run.sh",
|
| 135 |
+
"""#!/bin/bash
|
| 136 |
+
set -e
|
| 137 |
+
|
| 138 |
+
cd /home/{pr.repo}
|
| 139 |
+
go test -v -count=1 ./...
|
| 140 |
+
|
| 141 |
+
""".format(
|
| 142 |
+
pr=self.pr
|
| 143 |
+
),
|
| 144 |
+
),
|
| 145 |
+
File(
|
| 146 |
+
".",
|
| 147 |
+
"test-run.sh",
|
| 148 |
+
"""#!/bin/bash
|
| 149 |
+
set -e
|
| 150 |
+
|
| 151 |
+
cd /home/{pr.repo}
|
| 152 |
+
git apply /home/test.patch
|
| 153 |
+
go test -v -count=1 ./...
|
| 154 |
+
|
| 155 |
+
""".format(
|
| 156 |
+
pr=self.pr
|
| 157 |
+
),
|
| 158 |
+
),
|
| 159 |
+
File(
|
| 160 |
+
".",
|
| 161 |
+
"fix-run.sh",
|
| 162 |
+
"""#!/bin/bash
|
| 163 |
+
set -e
|
| 164 |
+
|
| 165 |
+
cd /home/{pr.repo}
|
| 166 |
+
git apply /home/test.patch /home/fix.patch
|
| 167 |
+
go test -v -count=1 ./...
|
| 168 |
+
|
| 169 |
+
""".format(
|
| 170 |
+
pr=self.pr
|
| 171 |
+
),
|
| 172 |
+
),
|
| 173 |
+
]
|
| 174 |
+
|
| 175 |
+
def dockerfile(self) -> str:
|
| 176 |
+
image = self.dependency()
|
| 177 |
+
name = image.image_name()
|
| 178 |
+
tag = image.image_tag()
|
| 179 |
+
|
| 180 |
+
copy_commands = ""
|
| 181 |
+
for file in self.files():
|
| 182 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 183 |
+
|
| 184 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 185 |
+
|
| 186 |
+
return f"""FROM {name}:{tag}
|
| 187 |
+
|
| 188 |
+
{self.global_env}
|
| 189 |
+
|
| 190 |
+
{copy_commands}
|
| 191 |
+
|
| 192 |
+
{prepare_commands}
|
| 193 |
+
|
| 194 |
+
{self.clear_env}
|
| 195 |
+
|
| 196 |
+
"""
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
@Instance.register("jesseduffield", "lazygit")
|
| 200 |
+
class Lazygit(Instance):
|
| 201 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 202 |
+
super().__init__()
|
| 203 |
+
self._pr = pr
|
| 204 |
+
self._config = config
|
| 205 |
+
|
| 206 |
+
@property
|
| 207 |
+
def pr(self) -> PullRequest:
|
| 208 |
+
return self._pr
|
| 209 |
+
|
| 210 |
+
def dependency(self) -> Optional[Image]:
|
| 211 |
+
return LazygitImageDefault(self.pr, self._config)
|
| 212 |
+
|
| 213 |
+
def run(self, run_cmd: str = "") -> str:
|
| 214 |
+
if run_cmd:
|
| 215 |
+
return run_cmd
|
| 216 |
+
|
| 217 |
+
return "bash /home/run.sh"
|
| 218 |
+
|
| 219 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 220 |
+
if test_patch_run_cmd:
|
| 221 |
+
return test_patch_run_cmd
|
| 222 |
+
|
| 223 |
+
return "bash /home/test-run.sh"
|
| 224 |
+
|
| 225 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 226 |
+
if fix_patch_run_cmd:
|
| 227 |
+
return fix_patch_run_cmd
|
| 228 |
+
|
| 229 |
+
return "bash /home/fix-run.sh"
|
| 230 |
+
|
| 231 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 232 |
+
passed_tests = set()
|
| 233 |
+
failed_tests = set()
|
| 234 |
+
skipped_tests = set()
|
| 235 |
+
|
| 236 |
+
re_pass_tests = [re.compile(r"--- PASS: (\S+)")]
|
| 237 |
+
re_fail_tests = [
|
| 238 |
+
re.compile(r"--- FAIL: (\S+)"),
|
| 239 |
+
re.compile(r"FAIL:?\s?(.+?)\s"),
|
| 240 |
+
]
|
| 241 |
+
re_skip_tests = [re.compile(r"--- SKIP: (\S+)")]
|
| 242 |
+
|
| 243 |
+
def get_base_name(test_name: str) -> str:
|
| 244 |
+
return test_name
|
| 245 |
+
|
| 246 |
+
for line in test_log.splitlines():
|
| 247 |
+
line = line.strip()
|
| 248 |
+
|
| 249 |
+
for re_pass_test in re_pass_tests:
|
| 250 |
+
pass_match = re_pass_test.match(line)
|
| 251 |
+
if pass_match:
|
| 252 |
+
test_name = pass_match.group(1)
|
| 253 |
+
if test_name in failed_tests:
|
| 254 |
+
continue
|
| 255 |
+
if test_name in skipped_tests:
|
| 256 |
+
skipped_tests.remove(test_name)
|
| 257 |
+
passed_tests.add(get_base_name(test_name))
|
| 258 |
+
|
| 259 |
+
for re_fail_test in re_fail_tests:
|
| 260 |
+
fail_match = re_fail_test.match(line)
|
| 261 |
+
if fail_match:
|
| 262 |
+
test_name = fail_match.group(1)
|
| 263 |
+
if test_name in passed_tests:
|
| 264 |
+
passed_tests.remove(test_name)
|
| 265 |
+
if test_name in skipped_tests:
|
| 266 |
+
skipped_tests.remove(test_name)
|
| 267 |
+
failed_tests.add(get_base_name(test_name))
|
| 268 |
+
|
| 269 |
+
for re_skip_test in re_skip_tests:
|
| 270 |
+
skip_match = re_skip_test.match(line)
|
| 271 |
+
if skip_match:
|
| 272 |
+
test_name = skip_match.group(1)
|
| 273 |
+
if test_name in passed_tests:
|
| 274 |
+
continue
|
| 275 |
+
if test_name not in failed_tests:
|
| 276 |
+
continue
|
| 277 |
+
skipped_tests.add(get_base_name(test_name))
|
| 278 |
+
|
| 279 |
+
return TestResult(
|
| 280 |
+
passed_count=len(passed_tests),
|
| 281 |
+
failed_count=len(failed_tests),
|
| 282 |
+
skipped_count=len(skipped_tests),
|
| 283 |
+
passed_tests=passed_tests,
|
| 284 |
+
failed_tests=failed_tests,
|
| 285 |
+
skipped_tests=skipped_tests,
|
| 286 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/junegunn/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.eval.harness.repos.golang.junegunn.fzf import *
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/junegunn/fzf.py
AD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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class FzfImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "golang:latest"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
|
| 50 |
+
{code}
|
| 51 |
+
|
| 52 |
+
{self.clear_env}
|
| 53 |
+
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class FzfImageDefault(Image):
|
| 58 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 59 |
+
self._pr = pr
|
| 60 |
+
self._config = config
|
| 61 |
+
|
| 62 |
+
@property
|
| 63 |
+
def pr(self) -> PullRequest:
|
| 64 |
+
return self._pr
|
| 65 |
+
|
| 66 |
+
@property
|
| 67 |
+
def config(self) -> Config:
|
| 68 |
+
return self._config
|
| 69 |
+
|
| 70 |
+
def dependency(self) -> Image | None:
|
| 71 |
+
return FzfImageBase(self.pr, self.config)
|
| 72 |
+
|
| 73 |
+
def image_tag(self) -> str:
|
| 74 |
+
return f"pr-{self.pr.number}"
|
| 75 |
+
|
| 76 |
+
def workdir(self) -> str:
|
| 77 |
+
return f"pr-{self.pr.number}"
|
| 78 |
+
|
| 79 |
+
def files(self) -> list[File]:
|
| 80 |
+
return [
|
| 81 |
+
File(
|
| 82 |
+
".",
|
| 83 |
+
"fix.patch",
|
| 84 |
+
f"{self.pr.fix_patch}",
|
| 85 |
+
),
|
| 86 |
+
File(
|
| 87 |
+
".",
|
| 88 |
+
"test.patch",
|
| 89 |
+
f"{self.pr.test_patch}",
|
| 90 |
+
),
|
| 91 |
+
File(
|
| 92 |
+
".",
|
| 93 |
+
"check_git_changes.sh",
|
| 94 |
+
"""#!/bin/bash
|
| 95 |
+
set -e
|
| 96 |
+
|
| 97 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 98 |
+
echo "check_git_changes: Not inside a git repository"
|
| 99 |
+
exit 1
|
| 100 |
+
fi
|
| 101 |
+
|
| 102 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 103 |
+
echo "check_git_changes: Uncommitted changes"
|
| 104 |
+
exit 1
|
| 105 |
+
fi
|
| 106 |
+
|
| 107 |
+
echo "check_git_changes: No uncommitted changes"
|
| 108 |
+
exit 0
|
| 109 |
+
|
| 110 |
+
""".format(
|
| 111 |
+
pr=self.pr
|
| 112 |
+
),
|
| 113 |
+
),
|
| 114 |
+
File(
|
| 115 |
+
".",
|
| 116 |
+
"prepare.sh",
|
| 117 |
+
"""#!/bin/bash
|
| 118 |
+
set -e
|
| 119 |
+
|
| 120 |
+
cd /home/{pr.repo}
|
| 121 |
+
git reset --hard
|
| 122 |
+
bash /home/check_git_changes.sh
|
| 123 |
+
git checkout {pr.base.sha}
|
| 124 |
+
bash /home/check_git_changes.sh
|
| 125 |
+
|
| 126 |
+
go test -v -count=1 ./... || true
|
| 127 |
+
|
| 128 |
+
""".format(
|
| 129 |
+
pr=self.pr
|
| 130 |
+
),
|
| 131 |
+
),
|
| 132 |
+
File(
|
| 133 |
+
".",
|
| 134 |
+
"run.sh",
|
| 135 |
+
"""#!/bin/bash
|
| 136 |
+
set -e
|
| 137 |
+
|
| 138 |
+
cd /home/{pr.repo}
|
| 139 |
+
go test -v -count=1 ./...
|
| 140 |
+
|
| 141 |
+
""".format(
|
| 142 |
+
pr=self.pr
|
| 143 |
+
),
|
| 144 |
+
),
|
| 145 |
+
File(
|
| 146 |
+
".",
|
| 147 |
+
"test-run.sh",
|
| 148 |
+
"""#!/bin/bash
|
| 149 |
+
set -e
|
| 150 |
+
|
| 151 |
+
cd /home/{pr.repo}
|
| 152 |
+
git apply /home/test.patch
|
| 153 |
+
go test -v -count=1 ./...
|
| 154 |
+
|
| 155 |
+
""".format(
|
| 156 |
+
pr=self.pr
|
| 157 |
+
),
|
| 158 |
+
),
|
| 159 |
+
File(
|
| 160 |
+
".",
|
| 161 |
+
"fix-run.sh",
|
| 162 |
+
"""#!/bin/bash
|
| 163 |
+
set -e
|
| 164 |
+
|
| 165 |
+
cd /home/{pr.repo}
|
| 166 |
+
git apply /home/test.patch /home/fix.patch
|
| 167 |
+
go test -v -count=1 ./...
|
| 168 |
+
|
| 169 |
+
""".format(
|
| 170 |
+
pr=self.pr
|
| 171 |
+
),
|
| 172 |
+
),
|
| 173 |
+
]
|
| 174 |
+
|
| 175 |
+
def dockerfile(self) -> str:
|
| 176 |
+
image = self.dependency()
|
| 177 |
+
name = image.image_name()
|
| 178 |
+
tag = image.image_tag()
|
| 179 |
+
|
| 180 |
+
copy_commands = ""
|
| 181 |
+
for file in self.files():
|
| 182 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 183 |
+
|
| 184 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 185 |
+
|
| 186 |
+
return f"""FROM {name}:{tag}
|
| 187 |
+
|
| 188 |
+
{self.global_env}
|
| 189 |
+
|
| 190 |
+
{copy_commands}
|
| 191 |
+
|
| 192 |
+
{prepare_commands}
|
| 193 |
+
|
| 194 |
+
{self.clear_env}
|
| 195 |
+
|
| 196 |
+
"""
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
@Instance.register("junegunn", "fzf")
|
| 200 |
+
class Fzf(Instance):
|
| 201 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 202 |
+
super().__init__()
|
| 203 |
+
self._pr = pr
|
| 204 |
+
self._config = config
|
| 205 |
+
|
| 206 |
+
@property
|
| 207 |
+
def pr(self) -> PullRequest:
|
| 208 |
+
return self._pr
|
| 209 |
+
|
| 210 |
+
def dependency(self) -> Optional[Image]:
|
| 211 |
+
return FzfImageDefault(self.pr, self._config)
|
| 212 |
+
|
| 213 |
+
def run(self, run_cmd: str = "") -> str:
|
| 214 |
+
if run_cmd:
|
| 215 |
+
return run_cmd
|
| 216 |
+
|
| 217 |
+
return "bash /home/run.sh"
|
| 218 |
+
|
| 219 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 220 |
+
if test_patch_run_cmd:
|
| 221 |
+
return test_patch_run_cmd
|
| 222 |
+
|
| 223 |
+
return "bash /home/test-run.sh"
|
| 224 |
+
|
| 225 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 226 |
+
if fix_patch_run_cmd:
|
| 227 |
+
return fix_patch_run_cmd
|
| 228 |
+
|
| 229 |
+
return "bash /home/fix-run.sh"
|
| 230 |
+
|
| 231 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 232 |
+
passed_tests = set()
|
| 233 |
+
failed_tests = set()
|
| 234 |
+
skipped_tests = set()
|
| 235 |
+
|
| 236 |
+
re_pass_tests = [re.compile(r"--- PASS: (\S+)")]
|
| 237 |
+
re_fail_tests = [
|
| 238 |
+
re.compile(r"--- FAIL: (\S+)"),
|
| 239 |
+
re.compile(r"FAIL:?\s?(.+?)\s"),
|
| 240 |
+
]
|
| 241 |
+
re_skip_tests = [re.compile(r"--- SKIP: (\S+)")]
|
| 242 |
+
|
| 243 |
+
def get_base_name(test_name: str) -> str:
|
| 244 |
+
return test_name
|
| 245 |
+
|
| 246 |
+
for line in test_log.splitlines():
|
| 247 |
+
line = line.strip()
|
| 248 |
+
|
| 249 |
+
for re_pass_test in re_pass_tests:
|
| 250 |
+
pass_match = re_pass_test.match(line)
|
| 251 |
+
if pass_match:
|
| 252 |
+
test_name = pass_match.group(1)
|
| 253 |
+
if test_name in failed_tests:
|
| 254 |
+
continue
|
| 255 |
+
if test_name in skipped_tests:
|
| 256 |
+
skipped_tests.remove(test_name)
|
| 257 |
+
passed_tests.add(get_base_name(test_name))
|
| 258 |
+
|
| 259 |
+
for re_fail_test in re_fail_tests:
|
| 260 |
+
fail_match = re_fail_test.match(line)
|
| 261 |
+
if fail_match:
|
| 262 |
+
test_name = fail_match.group(1)
|
| 263 |
+
if test_name in passed_tests:
|
| 264 |
+
passed_tests.remove(test_name)
|
| 265 |
+
if test_name in skipped_tests:
|
| 266 |
+
skipped_tests.remove(test_name)
|
| 267 |
+
failed_tests.add(get_base_name(test_name))
|
| 268 |
+
|
| 269 |
+
for re_skip_test in re_skip_tests:
|
| 270 |
+
skip_match = re_skip_test.match(line)
|
| 271 |
+
if skip_match:
|
| 272 |
+
test_name = skip_match.group(1)
|
| 273 |
+
if test_name in passed_tests:
|
| 274 |
+
continue
|
| 275 |
+
if test_name not in failed_tests:
|
| 276 |
+
continue
|
| 277 |
+
skipped_tests.add(get_base_name(test_name))
|
| 278 |
+
|
| 279 |
+
return TestResult(
|
| 280 |
+
passed_count=len(passed_tests),
|
| 281 |
+
failed_count=len(failed_tests),
|
| 282 |
+
skipped_count=len(skipped_tests),
|
| 283 |
+
passed_tests=passed_tests,
|
| 284 |
+
failed_tests=failed_tests,
|
| 285 |
+
skipped_tests=skipped_tests,
|
| 286 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/labstack/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class EchoImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "golang:latest"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
|
| 50 |
+
{code}
|
| 51 |
+
|
| 52 |
+
{self.clear_env}
|
| 53 |
+
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class EchoImageDefault(Image):
|
| 58 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 59 |
+
self._pr = pr
|
| 60 |
+
self._config = config
|
| 61 |
+
|
| 62 |
+
@property
|
| 63 |
+
def pr(self) -> PullRequest:
|
| 64 |
+
return self._pr
|
| 65 |
+
|
| 66 |
+
@property
|
| 67 |
+
def config(self) -> Config:
|
| 68 |
+
return self._config
|
| 69 |
+
|
| 70 |
+
def dependency(self) -> Image | None:
|
| 71 |
+
return EchoImageBase(self.pr, self.config)
|
| 72 |
+
|
| 73 |
+
def image_tag(self) -> str:
|
| 74 |
+
return f"pr-{self.pr.number}"
|
| 75 |
+
|
| 76 |
+
def workdir(self) -> str:
|
| 77 |
+
return f"pr-{self.pr.number}"
|
| 78 |
+
|
| 79 |
+
def files(self) -> list[File]:
|
| 80 |
+
return [
|
| 81 |
+
File(
|
| 82 |
+
".",
|
| 83 |
+
"fix.patch",
|
| 84 |
+
f"{self.pr.fix_patch}",
|
| 85 |
+
),
|
| 86 |
+
File(
|
| 87 |
+
".",
|
| 88 |
+
"test.patch",
|
| 89 |
+
f"{self.pr.test_patch}",
|
| 90 |
+
),
|
| 91 |
+
File(
|
| 92 |
+
".",
|
| 93 |
+
"check_git_changes.sh",
|
| 94 |
+
"""#!/bin/bash
|
| 95 |
+
set -e
|
| 96 |
+
|
| 97 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 98 |
+
echo "check_git_changes: Not inside a git repository"
|
| 99 |
+
exit 1
|
| 100 |
+
fi
|
| 101 |
+
|
| 102 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 103 |
+
echo "check_git_changes: Uncommitted changes"
|
| 104 |
+
exit 1
|
| 105 |
+
fi
|
| 106 |
+
|
| 107 |
+
echo "check_git_changes: No uncommitted changes"
|
| 108 |
+
exit 0
|
| 109 |
+
|
| 110 |
+
""".format(
|
| 111 |
+
pr=self.pr
|
| 112 |
+
),
|
| 113 |
+
),
|
| 114 |
+
File(
|
| 115 |
+
".",
|
| 116 |
+
"prepare.sh",
|
| 117 |
+
"""#!/bin/bash
|
| 118 |
+
set -e
|
| 119 |
+
|
| 120 |
+
cd /home/{pr.repo}
|
| 121 |
+
git reset --hard
|
| 122 |
+
bash /home/check_git_changes.sh
|
| 123 |
+
git checkout {pr.base.sha}
|
| 124 |
+
bash /home/check_git_changes.sh
|
| 125 |
+
|
| 126 |
+
go test -v -count=1 ./... || true
|
| 127 |
+
|
| 128 |
+
""".format(
|
| 129 |
+
pr=self.pr
|
| 130 |
+
),
|
| 131 |
+
),
|
| 132 |
+
File(
|
| 133 |
+
".",
|
| 134 |
+
"run.sh",
|
| 135 |
+
"""#!/bin/bash
|
| 136 |
+
set -e
|
| 137 |
+
|
| 138 |
+
cd /home/{pr.repo}
|
| 139 |
+
go test -v -count=1 ./...
|
| 140 |
+
|
| 141 |
+
""".format(
|
| 142 |
+
pr=self.pr
|
| 143 |
+
),
|
| 144 |
+
),
|
| 145 |
+
File(
|
| 146 |
+
".",
|
| 147 |
+
"test-run.sh",
|
| 148 |
+
"""#!/bin/bash
|
| 149 |
+
set -e
|
| 150 |
+
|
| 151 |
+
cd /home/{pr.repo}
|
| 152 |
+
git apply /home/test.patch
|
| 153 |
+
go test -v -count=1 ./...
|
| 154 |
+
|
| 155 |
+
""".format(
|
| 156 |
+
pr=self.pr
|
| 157 |
+
),
|
| 158 |
+
),
|
| 159 |
+
File(
|
| 160 |
+
".",
|
| 161 |
+
"fix-run.sh",
|
| 162 |
+
"""#!/bin/bash
|
| 163 |
+
set -e
|
| 164 |
+
|
| 165 |
+
cd /home/{pr.repo}
|
| 166 |
+
git apply /home/test.patch /home/fix.patch
|
| 167 |
+
go test -v -count=1 ./...
|
| 168 |
+
|
| 169 |
+
""".format(
|
| 170 |
+
pr=self.pr
|
| 171 |
+
),
|
| 172 |
+
),
|
| 173 |
+
]
|
| 174 |
+
|
| 175 |
+
def dockerfile(self) -> str:
|
| 176 |
+
image = self.dependency()
|
| 177 |
+
name = image.image_name()
|
| 178 |
+
tag = image.image_tag()
|
| 179 |
+
|
| 180 |
+
copy_commands = ""
|
| 181 |
+
for file in self.files():
|
| 182 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 183 |
+
|
| 184 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 185 |
+
|
| 186 |
+
return f"""FROM {name}:{tag}
|
| 187 |
+
|
| 188 |
+
{self.global_env}
|
| 189 |
+
|
| 190 |
+
{copy_commands}
|
| 191 |
+
|
| 192 |
+
{prepare_commands}
|
| 193 |
+
|
| 194 |
+
{self.clear_env}
|
| 195 |
+
|
| 196 |
+
"""
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
@Instance.register("labstack", "echo")
|
| 200 |
+
class Echo(Instance):
|
| 201 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 202 |
+
super().__init__()
|
| 203 |
+
self._pr = pr
|
| 204 |
+
self._config = config
|
| 205 |
+
|
| 206 |
+
@property
|
| 207 |
+
def pr(self) -> PullRequest:
|
| 208 |
+
return self._pr
|
| 209 |
+
|
| 210 |
+
def dependency(self) -> Optional[Image]:
|
| 211 |
+
return EchoImageDefault(self.pr, self._config)
|
| 212 |
+
|
| 213 |
+
def run(self, run_cmd: str = "") -> str:
|
| 214 |
+
if run_cmd:
|
| 215 |
+
return run_cmd
|
| 216 |
+
|
| 217 |
+
return "bash /home/run.sh"
|
| 218 |
+
|
| 219 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 220 |
+
if test_patch_run_cmd:
|
| 221 |
+
return test_patch_run_cmd
|
| 222 |
+
|
| 223 |
+
return "bash /home/test-run.sh"
|
| 224 |
+
|
| 225 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 226 |
+
if fix_patch_run_cmd:
|
| 227 |
+
return fix_patch_run_cmd
|
| 228 |
+
|
| 229 |
+
return "bash /home/fix-run.sh"
|
| 230 |
+
|
| 231 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 232 |
+
passed_tests = set()
|
| 233 |
+
failed_tests = set()
|
| 234 |
+
skipped_tests = set()
|
| 235 |
+
|
| 236 |
+
re_pass_tests = [re.compile(r"--- PASS: (\S+)")]
|
| 237 |
+
re_fail_tests = [
|
| 238 |
+
re.compile(r"--- FAIL: (\S+)"),
|
| 239 |
+
re.compile(r"FAIL:?\s?(.+?)\s"),
|
| 240 |
+
]
|
| 241 |
+
re_skip_tests = [re.compile(r"--- SKIP: (\S+)")]
|
| 242 |
+
|
| 243 |
+
def get_base_name(test_name: str) -> str:
|
| 244 |
+
return test_name
|
| 245 |
+
|
| 246 |
+
for line in test_log.splitlines():
|
| 247 |
+
line = line.strip()
|
| 248 |
+
|
| 249 |
+
for re_pass_test in re_pass_tests:
|
| 250 |
+
pass_match = re_pass_test.match(line)
|
| 251 |
+
if pass_match:
|
| 252 |
+
test_name = pass_match.group(1)
|
| 253 |
+
if test_name in failed_tests:
|
| 254 |
+
continue
|
| 255 |
+
if test_name in skipped_tests:
|
| 256 |
+
skipped_tests.remove(test_name)
|
| 257 |
+
passed_tests.add(get_base_name(test_name))
|
| 258 |
+
|
| 259 |
+
for re_fail_test in re_fail_tests:
|
| 260 |
+
fail_match = re_fail_test.match(line)
|
| 261 |
+
if fail_match:
|
| 262 |
+
test_name = fail_match.group(1)
|
| 263 |
+
if test_name in passed_tests:
|
| 264 |
+
passed_tests.remove(test_name)
|
| 265 |
+
if test_name in skipped_tests:
|
| 266 |
+
skipped_tests.remove(test_name)
|
| 267 |
+
failed_tests.add(get_base_name(test_name))
|
| 268 |
+
|
| 269 |
+
for re_skip_test in re_skip_tests:
|
| 270 |
+
skip_match = re_skip_test.match(line)
|
| 271 |
+
if skip_match:
|
| 272 |
+
test_name = skip_match.group(1)
|
| 273 |
+
if test_name in passed_tests:
|
| 274 |
+
continue
|
| 275 |
+
if test_name not in failed_tests:
|
| 276 |
+
continue
|
| 277 |
+
skipped_tests.add(get_base_name(test_name))
|
| 278 |
+
|
| 279 |
+
return TestResult(
|
| 280 |
+
passed_count=len(passed_tests),
|
| 281 |
+
failed_count=len(failed_tests),
|
| 282 |
+
skipped_count=len(skipped_tests),
|
| 283 |
+
passed_tests=passed_tests,
|
| 284 |
+
failed_tests=failed_tests,
|
| 285 |
+
skipped_tests=skipped_tests,
|
| 286 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/nektos/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.eval.harness.repos.golang.nektos.act import *
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/nektos/act.py
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class ActImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "golang:latest"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
|
| 50 |
+
{code}
|
| 51 |
+
|
| 52 |
+
{self.clear_env}
|
| 53 |
+
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class ActImageDefault(Image):
|
| 58 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 59 |
+
self._pr = pr
|
| 60 |
+
self._config = config
|
| 61 |
+
|
| 62 |
+
@property
|
| 63 |
+
def pr(self) -> PullRequest:
|
| 64 |
+
return self._pr
|
| 65 |
+
|
| 66 |
+
@property
|
| 67 |
+
def config(self) -> Config:
|
| 68 |
+
return self._config
|
| 69 |
+
|
| 70 |
+
def dependency(self) -> Image | None:
|
| 71 |
+
return ActImageBase(self.pr, self.config)
|
| 72 |
+
|
| 73 |
+
def image_tag(self) -> str:
|
| 74 |
+
return f"pr-{self.pr.number}"
|
| 75 |
+
|
| 76 |
+
def workdir(self) -> str:
|
| 77 |
+
return f"pr-{self.pr.number}"
|
| 78 |
+
|
| 79 |
+
def files(self) -> list[File]:
|
| 80 |
+
return [
|
| 81 |
+
File(
|
| 82 |
+
".",
|
| 83 |
+
"fix.patch",
|
| 84 |
+
f"{self.pr.fix_patch}",
|
| 85 |
+
),
|
| 86 |
+
File(
|
| 87 |
+
".",
|
| 88 |
+
"test.patch",
|
| 89 |
+
f"{self.pr.test_patch}",
|
| 90 |
+
),
|
| 91 |
+
File(
|
| 92 |
+
".",
|
| 93 |
+
"check_git_changes.sh",
|
| 94 |
+
"""#!/bin/bash
|
| 95 |
+
set -e
|
| 96 |
+
|
| 97 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 98 |
+
echo "check_git_changes: Not inside a git repository"
|
| 99 |
+
exit 1
|
| 100 |
+
fi
|
| 101 |
+
|
| 102 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 103 |
+
echo "check_git_changes: Uncommitted changes"
|
| 104 |
+
exit 1
|
| 105 |
+
fi
|
| 106 |
+
|
| 107 |
+
echo "check_git_changes: No uncommitted changes"
|
| 108 |
+
exit 0
|
| 109 |
+
|
| 110 |
+
""".format(
|
| 111 |
+
pr=self.pr
|
| 112 |
+
),
|
| 113 |
+
),
|
| 114 |
+
File(
|
| 115 |
+
".",
|
| 116 |
+
"prepare.sh",
|
| 117 |
+
"""#!/bin/bash
|
| 118 |
+
set -e
|
| 119 |
+
|
| 120 |
+
cd /home/{pr.repo}
|
| 121 |
+
git reset --hard
|
| 122 |
+
bash /home/check_git_changes.sh
|
| 123 |
+
git checkout {pr.base.sha}
|
| 124 |
+
bash /home/check_git_changes.sh
|
| 125 |
+
|
| 126 |
+
go test -v -count=1 ./... || true
|
| 127 |
+
|
| 128 |
+
""".format(
|
| 129 |
+
pr=self.pr
|
| 130 |
+
),
|
| 131 |
+
),
|
| 132 |
+
File(
|
| 133 |
+
".",
|
| 134 |
+
"run.sh",
|
| 135 |
+
"""#!/bin/bash
|
| 136 |
+
set -e
|
| 137 |
+
|
| 138 |
+
cd /home/{pr.repo}
|
| 139 |
+
go test -v -count=1 ./...
|
| 140 |
+
|
| 141 |
+
""".format(
|
| 142 |
+
pr=self.pr
|
| 143 |
+
),
|
| 144 |
+
),
|
| 145 |
+
File(
|
| 146 |
+
".",
|
| 147 |
+
"test-run.sh",
|
| 148 |
+
"""#!/bin/bash
|
| 149 |
+
set -e
|
| 150 |
+
|
| 151 |
+
cd /home/{pr.repo}
|
| 152 |
+
git apply /home/test.patch
|
| 153 |
+
go test -v -count=1 ./...
|
| 154 |
+
|
| 155 |
+
""".format(
|
| 156 |
+
pr=self.pr
|
| 157 |
+
),
|
| 158 |
+
),
|
| 159 |
+
File(
|
| 160 |
+
".",
|
| 161 |
+
"fix-run.sh",
|
| 162 |
+
"""#!/bin/bash
|
| 163 |
+
set -e
|
| 164 |
+
|
| 165 |
+
cd /home/{pr.repo}
|
| 166 |
+
git apply /home/test.patch /home/fix.patch
|
| 167 |
+
go test -v -count=1 ./...
|
| 168 |
+
|
| 169 |
+
""".format(
|
| 170 |
+
pr=self.pr
|
| 171 |
+
),
|
| 172 |
+
),
|
| 173 |
+
]
|
| 174 |
+
|
| 175 |
+
def dockerfile(self) -> str:
|
| 176 |
+
image = self.dependency()
|
| 177 |
+
name = image.image_name()
|
| 178 |
+
tag = image.image_tag()
|
| 179 |
+
|
| 180 |
+
copy_commands = ""
|
| 181 |
+
for file in self.files():
|
| 182 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 183 |
+
|
| 184 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 185 |
+
|
| 186 |
+
return f"""FROM {name}:{tag}
|
| 187 |
+
|
| 188 |
+
{self.global_env}
|
| 189 |
+
|
| 190 |
+
{copy_commands}
|
| 191 |
+
|
| 192 |
+
{prepare_commands}
|
| 193 |
+
|
| 194 |
+
{self.clear_env}
|
| 195 |
+
|
| 196 |
+
"""
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
@Instance.register("nektos", "act")
|
| 200 |
+
class Act(Instance):
|
| 201 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 202 |
+
super().__init__()
|
| 203 |
+
self._pr = pr
|
| 204 |
+
self._config = config
|
| 205 |
+
|
| 206 |
+
@property
|
| 207 |
+
def pr(self) -> PullRequest:
|
| 208 |
+
return self._pr
|
| 209 |
+
|
| 210 |
+
def dependency(self) -> Optional[Image]:
|
| 211 |
+
return ActImageDefault(self.pr, self._config)
|
| 212 |
+
|
| 213 |
+
def run(self, run_cmd: str = "") -> str:
|
| 214 |
+
if run_cmd:
|
| 215 |
+
return run_cmd
|
| 216 |
+
|
| 217 |
+
return "bash /home/run.sh"
|
| 218 |
+
|
| 219 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 220 |
+
if test_patch_run_cmd:
|
| 221 |
+
return test_patch_run_cmd
|
| 222 |
+
|
| 223 |
+
return "bash /home/test-run.sh"
|
| 224 |
+
|
| 225 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 226 |
+
if fix_patch_run_cmd:
|
| 227 |
+
return fix_patch_run_cmd
|
| 228 |
+
|
| 229 |
+
return "bash /home/fix-run.sh"
|
| 230 |
+
|
| 231 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 232 |
+
passed_tests = set()
|
| 233 |
+
failed_tests = set()
|
| 234 |
+
skipped_tests = set()
|
| 235 |
+
|
| 236 |
+
re_pass_tests = [re.compile(r"--- PASS: (\S+)")]
|
| 237 |
+
re_fail_tests = [
|
| 238 |
+
re.compile(r"--- FAIL: (\S+)"),
|
| 239 |
+
re.compile(r"FAIL:?\s?(.+?)\s"),
|
| 240 |
+
]
|
| 241 |
+
re_skip_tests = [re.compile(r"--- SKIP: (\S+)")]
|
| 242 |
+
|
| 243 |
+
def get_base_name(test_name: str) -> str:
|
| 244 |
+
return test_name
|
| 245 |
+
|
| 246 |
+
for line in test_log.splitlines():
|
| 247 |
+
line = line.strip()
|
| 248 |
+
|
| 249 |
+
for re_pass_test in re_pass_tests:
|
| 250 |
+
pass_match = re_pass_test.match(line)
|
| 251 |
+
if pass_match:
|
| 252 |
+
test_name = pass_match.group(1)
|
| 253 |
+
if test_name in failed_tests:
|
| 254 |
+
continue
|
| 255 |
+
if test_name in skipped_tests:
|
| 256 |
+
skipped_tests.remove(test_name)
|
| 257 |
+
passed_tests.add(get_base_name(test_name))
|
| 258 |
+
|
| 259 |
+
for re_fail_test in re_fail_tests:
|
| 260 |
+
fail_match = re_fail_test.match(line)
|
| 261 |
+
if fail_match:
|
| 262 |
+
test_name = fail_match.group(1)
|
| 263 |
+
if test_name in passed_tests:
|
| 264 |
+
passed_tests.remove(test_name)
|
| 265 |
+
if test_name in skipped_tests:
|
| 266 |
+
skipped_tests.remove(test_name)
|
| 267 |
+
failed_tests.add(get_base_name(test_name))
|
| 268 |
+
|
| 269 |
+
for re_skip_test in re_skip_tests:
|
| 270 |
+
skip_match = re_skip_test.match(line)
|
| 271 |
+
if skip_match:
|
| 272 |
+
test_name = skip_match.group(1)
|
| 273 |
+
if test_name in passed_tests:
|
| 274 |
+
continue
|
| 275 |
+
if test_name not in failed_tests:
|
| 276 |
+
continue
|
| 277 |
+
skipped_tests.add(get_base_name(test_name))
|
| 278 |
+
|
| 279 |
+
return TestResult(
|
| 280 |
+
passed_count=len(passed_tests),
|
| 281 |
+
failed_count=len(failed_tests),
|
| 282 |
+
skipped_count=len(skipped_tests),
|
| 283 |
+
passed_tests=passed_tests,
|
| 284 |
+
failed_tests=failed_tests,
|
| 285 |
+
skipped_tests=skipped_tests,
|
| 286 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/prometheus/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.eval.harness.repos.golang.prometheus.prometheus import *
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/prometheus/prometheus.py
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class PrometheusImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "golang:latest"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
|
| 50 |
+
{code}
|
| 51 |
+
|
| 52 |
+
{self.clear_env}
|
| 53 |
+
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class PrometheusImageDefault(Image):
|
| 58 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 59 |
+
self._pr = pr
|
| 60 |
+
self._config = config
|
| 61 |
+
|
| 62 |
+
@property
|
| 63 |
+
def pr(self) -> PullRequest:
|
| 64 |
+
return self._pr
|
| 65 |
+
|
| 66 |
+
@property
|
| 67 |
+
def config(self) -> Config:
|
| 68 |
+
return self._config
|
| 69 |
+
|
| 70 |
+
def dependency(self) -> Image | None:
|
| 71 |
+
return PrometheusImageBase(self.pr, self.config)
|
| 72 |
+
|
| 73 |
+
def image_tag(self) -> str:
|
| 74 |
+
return f"pr-{self.pr.number}"
|
| 75 |
+
|
| 76 |
+
def workdir(self) -> str:
|
| 77 |
+
return f"pr-{self.pr.number}"
|
| 78 |
+
|
| 79 |
+
def files(self) -> list[File]:
|
| 80 |
+
return [
|
| 81 |
+
File(
|
| 82 |
+
".",
|
| 83 |
+
"fix.patch",
|
| 84 |
+
f"{self.pr.fix_patch}",
|
| 85 |
+
),
|
| 86 |
+
File(
|
| 87 |
+
".",
|
| 88 |
+
"test.patch",
|
| 89 |
+
f"{self.pr.test_patch}",
|
| 90 |
+
),
|
| 91 |
+
File(
|
| 92 |
+
".",
|
| 93 |
+
"check_git_changes.sh",
|
| 94 |
+
"""#!/bin/bash
|
| 95 |
+
set -e
|
| 96 |
+
|
| 97 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 98 |
+
echo "check_git_changes: Not inside a git repository"
|
| 99 |
+
exit 1
|
| 100 |
+
fi
|
| 101 |
+
|
| 102 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 103 |
+
echo "check_git_changes: Uncommitted changes"
|
| 104 |
+
exit 1
|
| 105 |
+
fi
|
| 106 |
+
|
| 107 |
+
echo "check_git_changes: No uncommitted changes"
|
| 108 |
+
exit 0
|
| 109 |
+
|
| 110 |
+
""".format(
|
| 111 |
+
pr=self.pr
|
| 112 |
+
),
|
| 113 |
+
),
|
| 114 |
+
File(
|
| 115 |
+
".",
|
| 116 |
+
"prepare.sh",
|
| 117 |
+
"""#!/bin/bash
|
| 118 |
+
set -e
|
| 119 |
+
|
| 120 |
+
cd /home/{pr.repo}
|
| 121 |
+
git reset --hard
|
| 122 |
+
bash /home/check_git_changes.sh
|
| 123 |
+
git checkout {pr.base.sha}
|
| 124 |
+
bash /home/check_git_changes.sh
|
| 125 |
+
|
| 126 |
+
go test -v -count=1 ./... || true
|
| 127 |
+
|
| 128 |
+
""".format(
|
| 129 |
+
pr=self.pr
|
| 130 |
+
),
|
| 131 |
+
),
|
| 132 |
+
File(
|
| 133 |
+
".",
|
| 134 |
+
"run.sh",
|
| 135 |
+
"""#!/bin/bash
|
| 136 |
+
set -e
|
| 137 |
+
|
| 138 |
+
cd /home/{pr.repo}
|
| 139 |
+
go test -v -count=1 ./...
|
| 140 |
+
|
| 141 |
+
""".format(
|
| 142 |
+
pr=self.pr
|
| 143 |
+
),
|
| 144 |
+
),
|
| 145 |
+
File(
|
| 146 |
+
".",
|
| 147 |
+
"test-run.sh",
|
| 148 |
+
"""#!/bin/bash
|
| 149 |
+
set -e
|
| 150 |
+
|
| 151 |
+
cd /home/{pr.repo}
|
| 152 |
+
git apply /home/test.patch
|
| 153 |
+
go test -v -count=1 ./...
|
| 154 |
+
|
| 155 |
+
""".format(
|
| 156 |
+
pr=self.pr
|
| 157 |
+
),
|
| 158 |
+
),
|
| 159 |
+
File(
|
| 160 |
+
".",
|
| 161 |
+
"fix-run.sh",
|
| 162 |
+
"""#!/bin/bash
|
| 163 |
+
set -e
|
| 164 |
+
|
| 165 |
+
cd /home/{pr.repo}
|
| 166 |
+
git apply /home/test.patch /home/fix.patch
|
| 167 |
+
go test -v -count=1 ./...
|
| 168 |
+
|
| 169 |
+
""".format(
|
| 170 |
+
pr=self.pr
|
| 171 |
+
),
|
| 172 |
+
),
|
| 173 |
+
]
|
| 174 |
+
|
| 175 |
+
def dockerfile(self) -> str:
|
| 176 |
+
image = self.dependency()
|
| 177 |
+
name = image.image_name()
|
| 178 |
+
tag = image.image_tag()
|
| 179 |
+
|
| 180 |
+
copy_commands = ""
|
| 181 |
+
for file in self.files():
|
| 182 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 183 |
+
|
| 184 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 185 |
+
|
| 186 |
+
return f"""FROM {name}:{tag}
|
| 187 |
+
|
| 188 |
+
{self.global_env}
|
| 189 |
+
|
| 190 |
+
{copy_commands}
|
| 191 |
+
|
| 192 |
+
{prepare_commands}
|
| 193 |
+
|
| 194 |
+
{self.clear_env}
|
| 195 |
+
|
| 196 |
+
"""
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
@Instance.register("prometheus", "prometheus")
|
| 200 |
+
class Prometheus(Instance):
|
| 201 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 202 |
+
super().__init__()
|
| 203 |
+
self._pr = pr
|
| 204 |
+
self._config = config
|
| 205 |
+
|
| 206 |
+
@property
|
| 207 |
+
def pr(self) -> PullRequest:
|
| 208 |
+
return self._pr
|
| 209 |
+
|
| 210 |
+
def dependency(self) -> Optional[Image]:
|
| 211 |
+
return PrometheusImageDefault(self.pr, self._config)
|
| 212 |
+
|
| 213 |
+
def run(self, run_cmd: str = "") -> str:
|
| 214 |
+
if run_cmd:
|
| 215 |
+
return run_cmd
|
| 216 |
+
|
| 217 |
+
return "bash /home/run.sh"
|
| 218 |
+
|
| 219 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 220 |
+
if test_patch_run_cmd:
|
| 221 |
+
return test_patch_run_cmd
|
| 222 |
+
|
| 223 |
+
return "bash /home/test-run.sh"
|
| 224 |
+
|
| 225 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 226 |
+
if fix_patch_run_cmd:
|
| 227 |
+
return fix_patch_run_cmd
|
| 228 |
+
|
| 229 |
+
return "bash /home/fix-run.sh"
|
| 230 |
+
|
| 231 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 232 |
+
passed_tests = set()
|
| 233 |
+
failed_tests = set()
|
| 234 |
+
skipped_tests = set()
|
| 235 |
+
|
| 236 |
+
re_pass_tests = [re.compile(r"--- PASS: (\S+)")]
|
| 237 |
+
re_fail_tests = [
|
| 238 |
+
re.compile(r"--- FAIL: (\S+)"),
|
| 239 |
+
re.compile(r"FAIL:?\s?(.+?)\s"),
|
| 240 |
+
]
|
| 241 |
+
re_skip_tests = [re.compile(r"--- SKIP: (\S+)")]
|
| 242 |
+
|
| 243 |
+
def get_base_name(test_name: str) -> str:
|
| 244 |
+
return test_name
|
| 245 |
+
|
| 246 |
+
for line in test_log.splitlines():
|
| 247 |
+
line = line.strip()
|
| 248 |
+
|
| 249 |
+
for re_pass_test in re_pass_tests:
|
| 250 |
+
pass_match = re_pass_test.match(line)
|
| 251 |
+
if pass_match:
|
| 252 |
+
test_name = pass_match.group(1)
|
| 253 |
+
if test_name in failed_tests:
|
| 254 |
+
continue
|
| 255 |
+
if test_name in skipped_tests:
|
| 256 |
+
skipped_tests.remove(test_name)
|
| 257 |
+
passed_tests.add(get_base_name(test_name))
|
| 258 |
+
|
| 259 |
+
for re_fail_test in re_fail_tests:
|
| 260 |
+
fail_match = re_fail_test.match(line)
|
| 261 |
+
if fail_match:
|
| 262 |
+
test_name = fail_match.group(1)
|
| 263 |
+
if test_name in passed_tests:
|
| 264 |
+
passed_tests.remove(test_name)
|
| 265 |
+
if test_name in skipped_tests:
|
| 266 |
+
skipped_tests.remove(test_name)
|
| 267 |
+
failed_tests.add(get_base_name(test_name))
|
| 268 |
+
|
| 269 |
+
for re_skip_test in re_skip_tests:
|
| 270 |
+
skip_match = re_skip_test.match(line)
|
| 271 |
+
if skip_match:
|
| 272 |
+
test_name = skip_match.group(1)
|
| 273 |
+
if test_name in passed_tests:
|
| 274 |
+
continue
|
| 275 |
+
if test_name not in failed_tests:
|
| 276 |
+
continue
|
| 277 |
+
skipped_tests.add(get_base_name(test_name))
|
| 278 |
+
|
| 279 |
+
return TestResult(
|
| 280 |
+
passed_count=len(passed_tests),
|
| 281 |
+
failed_count=len(failed_tests),
|
| 282 |
+
skipped_count=len(skipped_tests),
|
| 283 |
+
passed_tests=passed_tests,
|
| 284 |
+
failed_tests=failed_tests,
|
| 285 |
+
skipped_tests=skipped_tests,
|
| 286 |
+
)
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/syncthing/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from livebench.agentic_code_runner.eval.harness.repos.golang.syncthing.syncthing import *
|
SPFsmartGATE/LIVE/TMP/LiveBench/livebench/agentic_code_runner/eval/harness/repos/golang/syncthing/syncthing.py
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from typing import Optional, Union
|
| 3 |
+
|
| 4 |
+
from livebench.agentic_code_runner.eval.harness.image import Config, File, Image
|
| 5 |
+
from livebench.agentic_code_runner.eval.harness.instance import Instance, TestResult
|
| 6 |
+
from livebench.agentic_code_runner.eval.harness.pull_request import PullRequest
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class SyncthingImageBase(Image):
|
| 10 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 11 |
+
self._pr = pr
|
| 12 |
+
self._config = config
|
| 13 |
+
|
| 14 |
+
@property
|
| 15 |
+
def pr(self) -> PullRequest:
|
| 16 |
+
return self._pr
|
| 17 |
+
|
| 18 |
+
@property
|
| 19 |
+
def config(self) -> Config:
|
| 20 |
+
return self._config
|
| 21 |
+
|
| 22 |
+
def dependency(self) -> Union[str, "Image"]:
|
| 23 |
+
return "golang:latest"
|
| 24 |
+
|
| 25 |
+
def image_tag(self) -> str:
|
| 26 |
+
return "base"
|
| 27 |
+
|
| 28 |
+
def workdir(self) -> str:
|
| 29 |
+
return "base"
|
| 30 |
+
|
| 31 |
+
def files(self) -> list[File]:
|
| 32 |
+
return []
|
| 33 |
+
|
| 34 |
+
def dockerfile(self) -> str:
|
| 35 |
+
image_name = self.dependency()
|
| 36 |
+
if isinstance(image_name, Image):
|
| 37 |
+
image_name = image_name.image_full_name()
|
| 38 |
+
|
| 39 |
+
if self.config.need_clone:
|
| 40 |
+
code = f"RUN git clone https://github.com/{self.pr.org}/{self.pr.repo}.git /home/{self.pr.repo}"
|
| 41 |
+
else:
|
| 42 |
+
code = f"COPY {self.pr.repo} /home/{self.pr.repo}"
|
| 43 |
+
|
| 44 |
+
return f"""FROM {image_name}
|
| 45 |
+
|
| 46 |
+
{self.global_env}
|
| 47 |
+
|
| 48 |
+
WORKDIR /home/
|
| 49 |
+
|
| 50 |
+
{code}
|
| 51 |
+
|
| 52 |
+
{self.clear_env}
|
| 53 |
+
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class SyncthingImageDefault(Image):
|
| 58 |
+
def __init__(self, pr: PullRequest, config: Config):
|
| 59 |
+
self._pr = pr
|
| 60 |
+
self._config = config
|
| 61 |
+
|
| 62 |
+
@property
|
| 63 |
+
def pr(self) -> PullRequest:
|
| 64 |
+
return self._pr
|
| 65 |
+
|
| 66 |
+
@property
|
| 67 |
+
def config(self) -> Config:
|
| 68 |
+
return self._config
|
| 69 |
+
|
| 70 |
+
def dependency(self) -> Image | None:
|
| 71 |
+
return SyncthingImageBase(self.pr, self.config)
|
| 72 |
+
|
| 73 |
+
def image_tag(self) -> str:
|
| 74 |
+
return f"pr-{self.pr.number}"
|
| 75 |
+
|
| 76 |
+
def workdir(self) -> str:
|
| 77 |
+
return f"pr-{self.pr.number}"
|
| 78 |
+
|
| 79 |
+
def files(self) -> list[File]:
|
| 80 |
+
return [
|
| 81 |
+
File(
|
| 82 |
+
".",
|
| 83 |
+
"fix.patch",
|
| 84 |
+
f"{self.pr.fix_patch}",
|
| 85 |
+
),
|
| 86 |
+
File(
|
| 87 |
+
".",
|
| 88 |
+
"test.patch",
|
| 89 |
+
f"{self.pr.test_patch}",
|
| 90 |
+
),
|
| 91 |
+
File(
|
| 92 |
+
".",
|
| 93 |
+
"check_git_changes.sh",
|
| 94 |
+
"""#!/bin/bash
|
| 95 |
+
set -e
|
| 96 |
+
|
| 97 |
+
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
| 98 |
+
echo "check_git_changes: Not inside a git repository"
|
| 99 |
+
exit 1
|
| 100 |
+
fi
|
| 101 |
+
|
| 102 |
+
if [[ -n $(git status --porcelain) ]]; then
|
| 103 |
+
echo "check_git_changes: Uncommitted changes"
|
| 104 |
+
exit 1
|
| 105 |
+
fi
|
| 106 |
+
|
| 107 |
+
echo "check_git_changes: No uncommitted changes"
|
| 108 |
+
exit 0
|
| 109 |
+
|
| 110 |
+
""".format(
|
| 111 |
+
pr=self.pr
|
| 112 |
+
),
|
| 113 |
+
),
|
| 114 |
+
File(
|
| 115 |
+
".",
|
| 116 |
+
"prepare.sh",
|
| 117 |
+
"""#!/bin/bash
|
| 118 |
+
set -e
|
| 119 |
+
|
| 120 |
+
cd /home/{pr.repo}
|
| 121 |
+
git reset --hard
|
| 122 |
+
bash /home/check_git_changes.sh
|
| 123 |
+
git checkout {pr.base.sha}
|
| 124 |
+
bash /home/check_git_changes.sh
|
| 125 |
+
|
| 126 |
+
go test -v -count=1 ./... || true
|
| 127 |
+
|
| 128 |
+
""".format(
|
| 129 |
+
pr=self.pr
|
| 130 |
+
),
|
| 131 |
+
),
|
| 132 |
+
File(
|
| 133 |
+
".",
|
| 134 |
+
"run.sh",
|
| 135 |
+
"""#!/bin/bash
|
| 136 |
+
set -e
|
| 137 |
+
|
| 138 |
+
cd /home/{pr.repo}
|
| 139 |
+
go test -v -count=1 ./...
|
| 140 |
+
|
| 141 |
+
""".format(
|
| 142 |
+
pr=self.pr
|
| 143 |
+
),
|
| 144 |
+
),
|
| 145 |
+
File(
|
| 146 |
+
".",
|
| 147 |
+
"test-run.sh",
|
| 148 |
+
"""#!/bin/bash
|
| 149 |
+
set -e
|
| 150 |
+
|
| 151 |
+
cd /home/{pr.repo}
|
| 152 |
+
git apply /home/test.patch
|
| 153 |
+
go test -v -count=1 ./...
|
| 154 |
+
|
| 155 |
+
""".format(
|
| 156 |
+
pr=self.pr
|
| 157 |
+
),
|
| 158 |
+
),
|
| 159 |
+
File(
|
| 160 |
+
".",
|
| 161 |
+
"fix-run.sh",
|
| 162 |
+
"""#!/bin/bash
|
| 163 |
+
set -e
|
| 164 |
+
|
| 165 |
+
cd /home/{pr.repo}
|
| 166 |
+
git apply /home/test.patch /home/fix.patch
|
| 167 |
+
go test -v -count=1 ./...
|
| 168 |
+
|
| 169 |
+
""".format(
|
| 170 |
+
pr=self.pr
|
| 171 |
+
),
|
| 172 |
+
),
|
| 173 |
+
]
|
| 174 |
+
|
| 175 |
+
def dockerfile(self) -> str:
|
| 176 |
+
image = self.dependency()
|
| 177 |
+
name = image.image_name()
|
| 178 |
+
tag = image.image_tag()
|
| 179 |
+
|
| 180 |
+
copy_commands = ""
|
| 181 |
+
for file in self.files():
|
| 182 |
+
copy_commands += f"COPY {file.name} /home/\n"
|
| 183 |
+
|
| 184 |
+
prepare_commands = "RUN bash /home/prepare.sh"
|
| 185 |
+
|
| 186 |
+
return f"""FROM {name}:{tag}
|
| 187 |
+
|
| 188 |
+
{self.global_env}
|
| 189 |
+
|
| 190 |
+
{copy_commands}
|
| 191 |
+
|
| 192 |
+
{prepare_commands}
|
| 193 |
+
|
| 194 |
+
{self.clear_env}
|
| 195 |
+
|
| 196 |
+
"""
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
@Instance.register("syncthing", "syncthing")
|
| 200 |
+
class Syncthing(Instance):
|
| 201 |
+
def __init__(self, pr: PullRequest, config: Config, *args, **kwargs):
|
| 202 |
+
super().__init__()
|
| 203 |
+
self._pr = pr
|
| 204 |
+
self._config = config
|
| 205 |
+
|
| 206 |
+
@property
|
| 207 |
+
def pr(self) -> PullRequest:
|
| 208 |
+
return self._pr
|
| 209 |
+
|
| 210 |
+
def dependency(self) -> Optional[Image]:
|
| 211 |
+
return SyncthingImageDefault(self.pr, self._config)
|
| 212 |
+
|
| 213 |
+
def run(self, run_cmd: str = "") -> str:
|
| 214 |
+
if run_cmd:
|
| 215 |
+
return run_cmd
|
| 216 |
+
|
| 217 |
+
return "bash /home/run.sh"
|
| 218 |
+
|
| 219 |
+
def test_patch_run(self, test_patch_run_cmd: str = "") -> str:
|
| 220 |
+
if test_patch_run_cmd:
|
| 221 |
+
return test_patch_run_cmd
|
| 222 |
+
|
| 223 |
+
return "bash /home/test-run.sh"
|
| 224 |
+
|
| 225 |
+
def fix_patch_run(self, fix_patch_run_cmd: str = "") -> str:
|
| 226 |
+
if fix_patch_run_cmd:
|
| 227 |
+
return fix_patch_run_cmd
|
| 228 |
+
|
| 229 |
+
return "bash /home/fix-run.sh"
|
| 230 |
+
|
| 231 |
+
def parse_log(self, test_log: str) -> TestResult:
|
| 232 |
+
passed_tests = set()
|
| 233 |
+
failed_tests = set()
|
| 234 |
+
skipped_tests = set()
|
| 235 |
+
|
| 236 |
+
re_pass_tests = [re.compile(r"--- PASS: (\S+)")]
|
| 237 |
+
re_fail_tests = [
|
| 238 |
+
re.compile(r"--- FAIL: (\S+)"),
|
| 239 |
+
re.compile(r"FAIL:?\s?(.+?)\s"),
|
| 240 |
+
]
|
| 241 |
+
re_skip_tests = [re.compile(r"--- SKIP: (\S+)")]
|
| 242 |
+
|
| 243 |
+
def get_base_name(test_name: str) -> str:
|
| 244 |
+
return test_name
|
| 245 |
+
|
| 246 |
+
for line in test_log.splitlines():
|
| 247 |
+
line = line.strip()
|
| 248 |
+
|
| 249 |
+
for re_pass_test in re_pass_tests:
|
| 250 |
+
pass_match = re_pass_test.match(line)
|
| 251 |
+
if pass_match:
|
| 252 |
+
test_name = pass_match.group(1)
|
| 253 |
+
if test_name in failed_tests:
|
| 254 |
+
continue
|
| 255 |
+
if test_name in skipped_tests:
|
| 256 |
+
skipped_tests.remove(test_name)
|
| 257 |
+
passed_tests.add(get_base_name(test_name))
|
| 258 |
+
|
| 259 |
+
for re_fail_test in re_fail_tests:
|
| 260 |
+
fail_match = re_fail_test.match(line)
|
| 261 |
+
if fail_match:
|
| 262 |
+
test_name = fail_match.group(1)
|
| 263 |
+
if test_name in passed_tests:
|
| 264 |
+
passed_tests.remove(test_name)
|
| 265 |
+
if test_name in skipped_tests:
|
| 266 |
+
skipped_tests.remove(test_name)
|
| 267 |
+
failed_tests.add(get_base_name(test_name))
|
| 268 |
+
|
| 269 |
+
for re_skip_test in re_skip_tests:
|
| 270 |
+
skip_match = re_skip_test.match(line)
|
| 271 |
+
if skip_match:
|
| 272 |
+
test_name = skip_match.group(1)
|
| 273 |
+
if test_name in passed_tests:
|
| 274 |
+
continue
|
| 275 |
+
if test_name not in failed_tests:
|
| 276 |
+
continue
|
| 277 |
+
skipped_tests.add(get_base_name(test_name))
|
| 278 |
+
|
| 279 |
+
return TestResult(
|
| 280 |
+
passed_count=len(passed_tests),
|
| 281 |
+
failed_count=len(failed_tests),
|
| 282 |
+
skipped_count=len(skipped_tests),
|
| 283 |
+
passed_tests=passed_tests,
|
| 284 |
+
failed_tests=failed_tests,
|
| 285 |
+
skipped_tests=skipped_tests,
|
| 286 |
+
)
|