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"}) 
    printf(1, "%s: testing...", {slug}) 
    sequence cmd = build_commandline({"cp",join_path({solution_dir, ".meta", "example.ex"}),join_path({"/tmp",slug & ".ex"})}) 
    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}) 
    atom fh = open(outfile, "r") 
    sequence data = read_lines(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) 
        end if 
    end for 
    fh = open(results_file,"w") 
    if failure = 0 then 
        write_file(fh, "{version: 1, status: \"pass\"}") 
        write_file(fh, sprintf("{version: 1, status: \"fail\", message: \"%s\"}", {find_replace("\"",failmsg,"\\\"")})) 
    end if 
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") 
    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


Quick Links

User menu

Not signed in.

Misc Menu