From 6fafad63a4850f5ad852f418b75649720a47e58f Mon Sep 17 00:00:00 2001 From: Jukka Aho Date: Fri, 27 Jan 2017 09:12:12 +0200 Subject: [PATCH] Fix FactCheck dependencies (issue #80) - Remove some obsolete tests related to Field. - Fixed a test checking is header information found from source files (was using FactCheck and commented out). - Add header information for all files (was missing from materials_plasticity.jl) --- src/materials_plasticity.jl | 3 ++ test/runtests.jl | 43 ++++++++++-------------- test/test_types.jl | 65 ------------------------------------- 3 files changed, 20 insertions(+), 91 deletions(-) diff --git a/src/materials_plasticity.jl b/src/materials_plasticity.jl index 8da27b9..9ab0379 100644 --- a/src/materials_plasticity.jl +++ b/src/materials_plasticity.jl @@ -1,3 +1,6 @@ +# This file is a part of JuliaFEM. +# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md + using ForwardDiff """ diff --git a/test/runtests.jl b/test/runtests.jl index 4a45d5e..17fe4b0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -8,7 +8,6 @@ function run_tests(; verbose=true) maybe_test_files = readdir(Pkg.dir("JuliaFEM")*"/test") is_test_file(fn) = startswith(fn, "test_") & endswith(fn, ".jl") test_files = filter(is_test_file, maybe_test_files) - #test_files = ["test_nodal_constraints.jl"] verbose && info("Test files:") for (i, test_file) in enumerate(test_files) @@ -33,7 +32,8 @@ end run_tests() #= -facts("Testing if somebody used print, println(), @sprint in src directory") do + +@testset "Testing if somebody used print, println(), @sprint in src directory" begin # TODO: make better reqular expression. Currently it will match all print words lines_with_print = Dict() src_dir = joinpath(Pkg.dir("JuliaFEM"),"src") @@ -47,10 +47,10 @@ facts("Testing if somebody used print, println(), @sprint in src directory") do end close(fil) end - @fact lines_with_print => isempty "Instead of println() use Logging.jl package" + @test length(lines_with_print) == 0 end -facts("Testing if we have non ascii characters in the src files") do +@testset "Testing if we have non ascii characters in the src files" begin # TODO: we should allow Greeck letters in documentation. Thus this test should skip docstrings lines_with_non_ascii = [] src_dir = joinpath(Pkg.dir("JuliaFEM"),"src") @@ -64,10 +64,12 @@ facts("Testing if we have non ascii characters in the src files") do end close(fil) end - @fact lines_with_non_ascii => isempty "non ascii charecters found in src -> test is failing" + @test length(lines_with_non_ascii) == 0 # non ascii charecters found in src -> test is failing end -facts("Looking the [src,test] folders *.jl files header information") do +=# + +@testset "Looking the [src,test] folders *.jl files header information" begin files_no_license = [] pkg_dir = Pkg.dir("JuliaFEM") dirs = ["test";"src"] @@ -75,7 +77,7 @@ facts("Looking the [src,test] folders *.jl files header information") do for file_name in readdir(joinpath(pkg_dir,folder)) if file_name[end-2:end] == ".jl" fil = open(joinpath(pkg_dir,folder,file_name),"r") - head = readall(fil) + head = readstring(fil) else continue end @@ -97,26 +99,15 @@ facts("Looking the [src,test] folders *.jl files header information") do # License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md """ - @fact files_no_license => isempty out_str -end -#= -test_files = readdir(Pkg.dir("JuliaFEM")*"/test") -for test_file in test_files - Logging.info("checking is $test_file is real test file") - if (startswith(test_file, "test_")) & (endswith(test_file, ".jl")) - Logging.info("Running tests from file $test_file") - include(test_file) + if length(files_no_license) != 0 + info(out_str) end + + for line in files_no_license + info(line) + end + + @test length(files_no_license) == 0 end -=# - -# Keep this at the end of this file (include statements above this) -@Logging.configure(level=DEBUG) -@debug("Let's print the summary of the tests") -for dic in FactCheck.getstats() - @debug(dic[1], ": ",dic[2]) -end -=# - diff --git a/test/test_types.jl b/test/test_types.jl index 1d28d31..d48f606 100644 --- a/test/test_types.jl +++ b/test/test_types.jl @@ -4,68 +4,3 @@ using JuliaFEM using JuliaFEM.Testing -#= TODO: Fix test - -facts("test interpolation of fields") do - - # interpolation of field in spatial domain - N = Basis((xi) -> [0.5*(1.0-xi[1]), 0.5*(1.0+xi[1])]) - u = Field(0.0, [0.0, 1.0]) - @fact interpolate(N, u, [0.0]) --> 0.5 - - # interpolation of fieldset in time domain - u1 = Field(0.0, [0.0, 1.0]) - u2 = Field(1.0, [1.0, 2.0]) - u = FieldSet("displacement", [u1, u2]) - @fact interpolate(u, 0.5).values --> [0.5, 1.5] - @fact interpolate(u, 0.5).time --> 0.5 - - # interpolation of fieldset is defined for every time value: - u1 = Field(0.0, [0.0, 0.0]) - u2 = Field(1.0, [1.0, 2.0]) - u3 = Field(2.0, [0.5, 1.5]) - u = FieldSet("displacement", [u1, u2, u3]) - @fact interpolate(u, -1.0).values --> [0.0, 0.0] # "out of range -" -> first known value - @fact interpolate(u, 0.0).values --> [0.0, 0.0] - @fact interpolate(u, 1.0).values --> [1.0, 2.0] - @fact interpolate(u, 2.0).values --> [0.5, 1.5] - @fact interpolate(u, 3.0).values --> [0.5, 1.5] # "out of range +" -> last known value - @fact interpolate(u, 0.5).values --> [0.5, 1.0] - @fact interpolate(u, 1.5).values --> [0.75, 1.75] - # use Inf to get very first or last value of field - @fact interpolate(u, -Inf).values --> [0.0, 0.0] - @fact interpolate(u, +Inf).values --> [0.5, 1.5] - - # multidimensional interpolation with and without derivatives - h(xi) = [ - (1-xi[1])*(1-xi[2])/4 - (1+xi[1])*(1-xi[2])/4 - (1+xi[1])*(1+xi[2])/4 - (1-xi[1])*(1+xi[2])/4] - dh(xi) = [ - -(1-xi[2])/4.0 -(1-xi[1])/4.0 - (1-xi[2])/4.0 -(1+xi[1])/4.0 - (1+xi[2])/4.0 (1+xi[1])/4.0 - -(1+xi[2])/4.0 (1-xi[1])/4.0] - N = Basis(h, dh) - - X = Field(0.0, Vector[[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]]) - - # get midpoint of field in spatial domain - @fact interpolate(N, X, [0.0, 0.0]) --> [0.5, 0.5] - - # interpolate of scalar field -> scalar - H = Field(0.0, 6.0) - @fact interpolate(N, H, [0.0, 0.0]) --> 6.0 - - # multiplying scalar field with a vector -> vector - # this is actually not so good idea... - #h(xi) = [1/2*(1-xi[1]), 1/2*(1+xi[1])] - #dh(xi) = [-1/2 1/2]' - #N = Basis(h, dh) - #f = Field(0.0, 100.0) - #@fact interpolate(N, f, [0.0]) --> [50.0, 50.0] - -end - -=#