Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

downloading, unpacking, deleting #3

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
tests/*/results.json
*.cmd
17 changes: 12 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
FROM alpine:3.17

# install packages required to run the tests
RUN apk add --no-cache jq coreutils
FROM ubuntu:bionic-20230308
LABEL maintainer="Greg Haberek <[email protected]> and Bruce Axtens <[email protected]>"
ADD https://github.com/OpenEuphoria/euphoria/releases/download/4.1.0/euphoria-4.1.0-Linux-x64-57179171dbed.tar.gz /tmp
ENV PATH=/usr/local/euphoria-4.1.0-Linux-x64/bin:$PATH
RUN apt-get update && \
apt-get install jq coreutils -y && \
apt-get purge --auto-remove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
tar xzvf /tmp/euphoria-4.1.0-Linux-x64-57179171dbed.tar.gz -C /usr/local

WORKDIR /opt/test-runner
COPY . .
ENTRYPOINT ["/opt/test-runner/bin/run.sh"]
#ENTRYPOINT ["/opt/test-runner/bin/run.sh"]
ENTRYPOINT ["eui /opt/test-runner/bin/run.ex"]
53 changes: 53 additions & 0 deletions bin/run.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
include std/filesys.e
include std/cmdline.e
include std/io.e
include std/sequence.e
include std/search.e

procedure process(sequence slug, sequence soln_folder, sequence outp_folder)
sequence solution_dir=canonical_path(soln_folder)
sequence output_dir=canonical_path(outp_folder)
sequence results_file=join_path({output_dir, "/results.json"})

create_directory(output_dir)
printf(1, "%s: testing...", {slug})
sequence cmd = build_commandline({"cp",join_path({solution_dir, ".meta", "example.ex"}),join_path({"/tmp",slug & ".ex"})})
system(cmd,2)
cmd = build_commandline({"cp", join_path({solution_dir,"t_" & slug & ".e"}),"/tmp"})
system(cmd, 2)
sequence outfile = join_path({"/tmp","t_" & slug & ".out"})
cmd = build_commandline({"eutest",join_path({"/tmp","t_" & slug & ".e"}),">", outfile})
system(cmd,2)

atom fh = open(outfile, "r")
sequence data = read_lines(fh)
close(fh)

atom failure = 0
sequence failmsg = ""

for i = 1 to length(data) do
integer result = match(" failed:", data[i])
if result then
failure = i
failmsg = slice(data[i],11)
break
end if
end for

fh = open(results_file,"w")
if failure = 0 then
write_file(fh, "{version: 1, status: \"pass\"}")
else
write_file(fh, sprintf("{version: 1, status: \"fail\", message: \"%s\"}", {find_replace("\"",failmsg,"\\\"")}))
end if
close(fh)
puts(1,"done\n")
end procedure

sequence cmdline = command_line()
if (length(cmdline) < 5) then
puts(1, "usage: eui ./bin/run.ex exercise-slug path/to/solution/folder/ path/to/output/directory/\n")
else
process(cmdline[3], cmdline[4], cmdline[5])
end if