diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2017-03-13 15:38:23 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2017-03-13 15:38:23 -0400 |
| commit | f687e914e07094b1eef11d84dab2e069a9298df5 (patch) | |
| tree | d74600b3afebd028689baa1c306432fac5030f9f /test/glum_spec.lua | |
| parent | f96040eb138efdc8f13521bade5bf8bd299bb9fb (diff) | |
| download | glum-f687e914e07094b1eef11d84dab2e069a9298df5.tar.gz glum-f687e914e07094b1eef11d84dab2e069a9298df5.tar.bz2 glum-f687e914e07094b1eef11d84dab2e069a9298df5.zip | |
Started updateing unit tests
Diffstat (limited to 'test/glum_spec.lua')
| -rw-r--r-- | test/glum_spec.lua | 71 |
1 files changed, 45 insertions, 26 deletions
diff --git a/test/glum_spec.lua b/test/glum_spec.lua index e4c5749..3cee0ab 100644 --- a/test/glum_spec.lua +++ b/test/glum_spec.lua @@ -1,31 +1,50 @@ +--Tests glum to make sure it works correctly! + +--Come config stuff, you can edit this to your likeing +local config = { + lscmd = "ls -a \"%s\"", -- List directory contents command + ignoredirs = {".",".."} -- List of directories that appear in the above command that we should ignore +} + local tests = {} +describe("Finding tests",function() + --A function that looks for files in a directory, you might need to rewrite this for windows + local function scan_paths(path,tbl) + local pfile = io.popen(string.format(config.lscmd,path)) + local pdata = pfile:read("*all") + for filename in string.gmatch(pdata,"[^\n]+") do + if filename:find("%.lua$") then --It's a file, include it on the path + tbl[path .. "/" .. filename] = true + else + local shouldignore = false + + for k,v in pairs(config.ignoredirs) do + if filename == v then + shouldignore = true + break + end + end + + if not shouldignore then + scan_paths(path .. "/" .. filename,tbl) + end + end + end + end + + local t = {} + scan_paths("./tests",t) + tests = t +end) -describe("Initializeing tests",function() - local testnames = { - {"forinloop.lua", "forin loops"}, - {"fornumloop.lua","fornum loops"}, - {"invoke.lua","invokes"}, - {"call.lua","calls"}, - {"string.lua","strings"}, - } - for k,v in pairs(testnames) do - local file = io.open("./tests/"..v[1],"r") - tests[v[2]] = file:read("*a") - end +local glum +describe("Finding GLuM",function() + glum = dofile("../src/glum.lua") end) -describe("GLuM should", function() - local glum - it("initialize without error",function() - glum = dofile("../src/glum.lua") - end) - describe("output non-erroring minified code for",function() - for k,v in pairs(tests) do - it(k,function() - local miniftxt = glum.minify(v) - local minified = loadstring(miniftxt) - assert.has_no.errors(minified) - end) - end - end) +describe("GLuM", function() + for k,v in pairs(tests) do + local testcode = loadstring(v) + testcode() + end end) |
