Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit fc8c7259 authored by Pierre Aubert's avatar Pierre Aubert
Browse files

Add test

parent 2fd89fb6
Pipeline #130371 passed with stages
in 4 minutes and 35 seconds
......@@ -4,6 +4,13 @@ add_test(NAME TestFileGeneratorSource
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
configure_file(scriptTest.sh ${CMAKE_CURRENT_BINARY_DIR}/scriptTest.sh @ONLY)
add_test(NAME TestFileGeneratorSourceWrongWright
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/scriptTest.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_test(NAME TestFileGeneratorClass
COMMAND ${FILE_GENERATOR_PROGRAM} class -n Shadok
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
......@@ -38,3 +45,12 @@ add_test(NAME TestFileGeneratorClassConfigDataStreamNested
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_test(NAME TestFileGeneratorClassWrongConfig
COMMAND ${FILE_GENERATOR_PROGRAM} class -c someInexistingConfigFile.pdata
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
set_tests_properties(TestFileGeneratorClassWrongConfig PROPERTIES WILL_FAIL true)
#!/bin/bash
mkdir -p testDir
chmod a-w testDir
cd testDir
@FILE_GENERATOR_PROGRAM@ source -n test_source_fail
......@@ -15,8 +15,6 @@
#include "saveClassConfig.h"
#include "parserClassConfig.h"
using namespace std;
///Create the OptionParser of this program
/** @return OptionParser of this program
*/
......@@ -42,8 +40,9 @@ OptionParser createOptionParser(){
///Class creator
/** @param classMode : set of argument passe in the class mode
* @return true on success, false otherwise
*/
void createClass(const OptionMode & classMode){
bool createClass(const OptionMode & classMode){
std::string className(""), classConfig(""), templatedef("");
classMode.getValue(className, "name");
......@@ -58,7 +57,7 @@ void createClass(const OptionMode & classMode){
}
if(!saveParserClassConfig(className, classConfig, enableDataStream)){
std::cerr << "createClass : can't save file '"<<className<<"'[.h or .cpp]" << std::endl;
return;
return false;
}
}else{
PClassGenerator generator;
......@@ -67,18 +66,22 @@ void createClass(const OptionMode & classMode){
if(!generator.saveFileImplDef(className)){
std::cerr << "createClass : can't save file '"<<className<<"'[.h or .cpp]" << std::endl;
return false;
}
}
return true;
}
///Create header and source file name
/** @param sourceMode : arguments passed in the source mode of the
/** @param sourceMode : arguments passed in the source mode
* @return true on success, false otherwise
*/
void createHeaderSource(const OptionMode & sourceMode){
bool createHeaderSource(const OptionMode & sourceMode){
std::string headerName("header");
sourceMode.getValue(headerName, "name");
std::string baseHeaderName(eraseExtension(headerName));
saveHeaderSourceFile(baseHeaderName + ".h", baseHeaderName + ".cpp");
return true;
}
int main(int argc, char** argv){
......@@ -87,14 +90,14 @@ int main(int argc, char** argv){
const OptionMode & classMode = parser.getMode("class");
const OptionMode & sourceMode = parser.getMode("source");
bool b(true);
if(classMode.isParsed()){ //We are using the class mode
createClass(classMode);
b &= createClass(classMode);
}
if(sourceMode.isParsed()){ //We are using the source mode
createHeaderSource(sourceMode);
b &= createHeaderSource(sourceMode);
}
return 0;
return b - 1;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment