From 50c5aaae219079df8a21efc31b37fb5190a03218 Mon Sep 17 00:00:00 2001 From: Jukka Aho Date: Sat, 4 Jul 2015 20:08:03 +0300 Subject: [PATCH] functional testing --- Makefile | 2 +- docs/build_notebooks.jl | 46 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 docs/build_notebooks.jl diff --git a/Makefile b/Makefile index 0c4d82b..d4f2ee3 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ copyreadme: # convert notebooks to md files convert_notebooks: - cd docs/tutorials && runipy --kernel=julia-0.4 2015-07-04-hello-world-functional-tests-part-2.ipynb /tmp/2015-07-04-hello-world-functional-tests-part-2.ipynb && ipython nbconvert /tmp/2015-07-04-hello-world-functional-tests-part-2.ipynb --to=rst + julia docs/build_notebooks.jl #coverage_report: # julia -e 'Pkg.test("JuliaFEM"; coverage=true); cd(Pkg.dir("JuliaFEM")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())' diff --git a/docs/build_notebooks.jl b/docs/build_notebooks.jl new file mode 100644 index 0000000..9c66247 --- /dev/null +++ b/docs/build_notebooks.jl @@ -0,0 +1,46 @@ +cd(dirname(@__FILE__)) do + +results = Dict[] +for ipynb in readdir("tutorials") + tic() + if !endswith(ipynb, "ipynb") + continue + end + runtime = 0 + status = 1 + println("Running notebook tutorials/$ipynb") + try + run(`runipy -o tutorials/$ipynb --kernel=julia-0.4 --port=0`) + runtime = toc() + status = 0 + catch + println("did not work") + end + run(`ipython nbconvert tutorials/$ipynb --to rst --output=tutorials/$(ipynb[1:end-6])`) + println("took $runtime seconds") + push!(results, Dict("filename" => ipynb, "status" => status, "runtime" => runtime)) +end + +function write_login_markdown(preamble, results, footer,filename="tutorials/README.md") + open(filename, "w") do f + write(f, preamble) + for (index, each) in enumerate(results) + write(f, """|$(index)|$(each["filename"])|$(round(each["runtime"], 2))|$(each["status"])| +""") + end + write(f, footer) + end +end + + +preamble = """##Notebooks + +| id | Notebook | Runtime | Status| +|----|----------|---------|-------| +""" +footer = """ +""" + +write_login_markdown(preamble, results, footer) + +end \ No newline at end of file