Skip to content

Commit 7480ee3

Browse files
committed
Add threads and timeout configuration options.
1 parent ea3cb79 commit 7480ee3

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/it/larger/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363
<configuration>
6464
<image>larger-hone:local</image>
6565
<rules>none</rules>
66+
<threads>1</threads>
67+
<timeout>10</timeout>
6668
</configuration>
6769
<executions>
6870
<execution>

src/main/resources/org/eolang/hone/scaffolding/rewrite.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function rewrite {
5656
for rule in "${rules[@]}"; do
5757
m=$(basename "${rule}" .yml)
5858
pos=$(( pos + 1 ))
59-
t="${pho}.${pos}"
59+
t="${pho}.$(printf '%002d' "${pos}")"
6060
phino rewrite "${phinopts[@]}" --max-cycles "${HONE_MAX_CYCLES}" --max-depth "${HONE_MAX_DEPTH}" --sweet --rule "${rule}" "${pho}" > "${t}"
6161
if cmp -s "${pho}" "${t}"; then
6262
verbose " No changes made by '${m}' to $(basename "${t}")"
@@ -98,7 +98,7 @@ function rewrite_with_timeout {
9898
start=$(date '+%s.%N')
9999
if ! timeout "${HONE_TIMEOUT}" "${0}" rewrite "$@"; then
100100
sec=$(perl -E "say int($(date '+%s.%N') - ${start})")
101-
if [ "${sec}" == 0 ]; then
101+
if [ "${sec}" -eq 0 ]; then
102102
echo "Failure in ${idx} $(basename "${xi}") ($(du -sh "${xi}" | cut -f1))"
103103
exit 1
104104
fi
@@ -181,8 +181,9 @@ mkdir -p "${PARALLEL_HOME}"
181181
parallel --record-env
182182
echo "Starting to rewrite ${total} file(s) in ${threads} thread(s)..."
183183
start=$(date '+%s.%N')
184-
parallel --retries=0 "--joblog=${TARGET}/hone-tasks.log" --will-cite \
184+
parallel --retries=0 "--joblog=${PARALLEL_HOME}/tasks.log" --will-cite \
185185
"--max-procs=${threads}" \
186-
--env _ \
186+
"--tmpdir=${PARALLEL_HOME}/tmp" \
187+
--env _ --plain \
187188
--halt-on-error=now,fail=1 --halt=now,fail=1 < "${tasks}"
188189
echo "Finished rewriting ${total} file(s) in $(perl -E "say int($(date '+%s.%N') - ${start})") seconds"

0 commit comments

Comments
 (0)