Loading...
Searching...
No Matches
LuaPluginLoader_impl.h
Go to the documentation of this file.
/*
* Robot Testing Framework
*
* Copyright (C) 2015-2019 Istituto Italiano di Tecnologia (IIT)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ROBOTTESTINGFRAMEWORK_LUAPLUGINLOADER_IMPL_H
#define ROBOTTESTINGFRAMEWORK_LUAPLUGINLOADER_IMPL_H
#include <robottestingframework/TestCase.h>
#include <lua.hpp>
#include <lualib.h>
#include <string>
namespace robottestingframework {
namespace plugin {
class LuaPluginLoaderImpl : public robottestingframework::TestCase
{
public:
LuaPluginLoaderImpl();
~LuaPluginLoaderImpl() override;
TestCase* open(const std::string filename);
void close();
std::string getLastError();
std::string getFileName();
void setTestName(const std::string name);
bool setup(int argc, char** argv) override;
void tearDown() override;
void run() override;
private:
bool getLocalFunction(const char* name);
bool registerExtraFunctions(void);
std::string extractFileName(const std::string& path);
// lua accessible functions
static int setName(lua_State* L);
static int assertError(lua_State* L);
static int assertFail(lua_State* L);
static int testReport(lua_State* L);
static int testFail(lua_State* L);
static int testCheck(lua_State* L);
static int getTestEnvironment(lua_State* L);
private:
lua_State* L;
std::string filename;
std::string error;
#if LUA_VERSION_NUM > 501
static const struct luaL_Reg luaPluginLib[];
#else
static const struct luaL_reg luaPluginLib[];
#endif
};
} // namespace robottestingframework
} // namespace plugin
#endif // ROBOTTESTINGFRAMEWORK_LUAPLUGINLOADER_IMPL_H
TestCase.h
robottestingframework::TestCase
The base class to implememnt a test case.
Definition TestCase.h:42
robottestingframework::plugin::LuaPluginLoaderImpl
The LuaPluginLoaderImpl loads an test case plug-in and gives the direct access to the TestCase.
Definition LuaPluginLoader_impl.h:39
robottestingframework::plugin::LuaPluginLoaderImpl::close
void close()
close Unloads the plugin and deletes any allocated memory.
robottestingframework::plugin::LuaPluginLoaderImpl::extractFileName
std::string extractFileName(const std::string &path)
robottestingframework::plugin::LuaPluginLoaderImpl::filename
std::string filename
Definition LuaPluginLoader_impl.h:106
robottestingframework::plugin::LuaPluginLoaderImpl::assertFail
static int assertFail(lua_State *L)
robottestingframework::plugin::LuaPluginLoaderImpl::getLocalFunction
bool getLocalFunction(const char *name)
robottestingframework::plugin::LuaPluginLoaderImpl::testReport
static int testReport(lua_State *L)
robottestingframework::plugin::LuaPluginLoaderImpl::registerExtraFunctions
bool registerExtraFunctions(void)
robottestingframework::plugin::LuaPluginLoaderImpl::L
lua_State * L
Definition LuaPluginLoader_impl.h:105
robottestingframework::plugin::LuaPluginLoaderImpl::setName
static int setName(lua_State *L)
robottestingframework::plugin::LuaPluginLoaderImpl::error
std::string error
Definition LuaPluginLoader_impl.h:107
robottestingframework::plugin::LuaPluginLoaderImpl::getLastError
std::string getLastError()
getLastError gets the last error if any.
robottestingframework::plugin::LuaPluginLoaderImpl::testCheck
static int testCheck(lua_State *L)
robottestingframework::plugin::LuaPluginLoaderImpl::tearDown
void tearDown() override
tearDown is called after the test run
robottestingframework::plugin::LuaPluginLoaderImpl::assertError
static int assertError(lua_State *L)
robottestingframework::plugin::LuaPluginLoaderImpl::open
TestCase * open(const std::string filename)
open Loads a test case plugin
robottestingframework::plugin::LuaPluginLoaderImpl::luaPluginLib
static const struct luaL_reg luaPluginLib[]
Definition LuaPluginLoader_impl.h:111
robottestingframework::plugin::LuaPluginLoaderImpl::getFileName
std::string getFileName()
getFileName returns the loaded script file name
robottestingframework::plugin::LuaPluginLoaderImpl::setTestName
void setTestName(const std::string name)
setTestName set the test case name
robottestingframework::plugin::LuaPluginLoaderImpl::getTestEnvironment
static int getTestEnvironment(lua_State *L)
robottestingframework::plugin::LuaPluginLoaderImpl::testFail
static int testFail(lua_State *L)
robottestingframework::plugin::LuaPluginLoaderImpl::~LuaPluginLoaderImpl
~LuaPluginLoaderImpl() override
LuaPluginLoaderImpl destructor.
robottestingframework::plugin::LuaPluginLoaderImpl::LuaPluginLoaderImpl
LuaPluginLoaderImpl()
LuaPluginLoaderImpl constructor.
robottestingframework::plugin::LuaPluginLoaderImpl::run
void run() override
run is called by the TestCase class if setup is successfull;
robottestingframework::plugin::LuaPluginLoaderImpl::setup
bool setup(int argc, char **argv) override
setup is called before the test run.
robottestingframework
Definition Arguments.h:25