Is there a better way to require file from relative path in lua

My directory structure looks like this:

|-- ball.lua
|-- entity.lua
|-- test
    `-- ball_test.lua

I'm using the following code in test/ball_test.lua to require ball.lua from the parent directory:

package.path = package.path .. ";../entity.lua"
require("entity")
package.path = package.path .. ";../ball.lua"
require("ball")

entity.lua is a dependency of ball.lua. So I require("entity") first otherwise I get a module 'entity.lua' not found error. This seems like a hack, what's a better way to do this?


Solution 1:

package.path = package.path .. ";../?.lua"

will work for both.