Re: Grinding to a halt

new topic     » goto parent     » topic index » view thread      » older message » newer message

So along with the track code there's also a separate repo for the test runner. Part of the process of getting the former going is the test runner which I've represented in my own fork as

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 

This will only ever run in Linux.

So (and here's where things get hazy for me) the with the tests folder is that it contains samples of what happens when a running Euphoria program hits certain problems in the running of eutest tests. Deliberately damaged instances of the code being test are created so as to be able to generate and capture what happens when

  • all tests fail
  • there's nothing to test (unsure about this)
  • there is a partial fail of tests
  • all tests pass
  • there's a syntax error in the code (in the code or the test?)

Somehow all this gets used by Exercism in their CI/CD.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu