Requiring love modules for unit testing
Posted: Sun May 01, 2016 9:45 pm
Hey everyone, I'm currently trying to write unit tests for my LÖVE project using the busted framework to alleviate debugging. However, as my code does make use of calls to LÖVE functions (e.g., love.graphics.getWidth()), I want to add LÖVE modules as dependencies. Reading viewtopic.php?t=81552 and asking around on the IRC (2016-04-30) brought me to writing this at the top of my test.lua
And when I run the test in busted, I get the error
which is, as far as I can tell, an exception thrown by Shader.cpp. I'm not very familiar with LÖVE's internals yet, but is there something else I can add to my test.lua so I can get it to work?
I was also advised to merely call love.boot() like so
but running that in busted just brings up Super Toast informing me I have no game.
I'm not deadset on using busted or anything, but I suppose that as long as I'd rather not use another main.lua or something to run my tests I'm going to need to do something like this? I'm all ears for suggestions.
Code: Select all
package.preload.love = package.loadlib('/usr/lib64/liblove.so.0', 'luaopen_love')
require 'love'
require 'love.filesystem'
love.filesystem.init(arg[-1]) -- also tested with arg[0], same error below
require 'love.window'
love.window.setMode(0,0,{})
require 'love.graphics'
Code: Select all
test.lua:12: Cannot create shader: no source code!
which is, as far as I can tell, an exception thrown by Shader.cpp. I'm not very familiar with LÖVE's internals yet, but is there something else I can add to my test.lua so I can get it to work?
I was also advised to merely call love.boot() like so
Code: Select all
package.preload.love = package.loadlib('usr/lib64/liblove.so.0', 'luaopen_love')
require 'love'
require('love.boot')()
I'm not deadset on using busted or anything, but I suppose that as long as I'd rather not use another main.lua or something to run my tests I'm going to need to do something like this? I'm all ears for suggestions.