Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Docker-in-Docker (DinD) capabilities of public runners deactivated.
More info
Open sidebar
CTA-LAPP
PHOENIX_LIBS
PhoenixFileGenerator
Commits
fc8c7259
Commit
fc8c7259
authored
Aug 01, 2021
by
Pierre Aubert
Browse files
Add test
parent
2fd89fb6
Pipeline
#130371
passed with stages
in 4 minutes and 35 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
10 deletions
+39
-10
TESTS/TEST_FILE_GENERATOR/CMakeLists.txt
TESTS/TEST_FILE_GENERATOR/CMakeLists.txt
+16
-0
TESTS/TEST_FILE_GENERATOR/scriptTest.sh
TESTS/TEST_FILE_GENERATOR/scriptTest.sh
+10
-0
src/main.cpp
src/main.cpp
+13
-10
No files found.
TESTS/TEST_FILE_GENERATOR/CMakeLists.txt
View file @
fc8c7259
...
...
@@ -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
)
TESTS/TEST_FILE_GENERATOR/scriptTest.sh
0 → 100755
View file @
fc8c7259
#!/bin/bash
mkdir
-p
testDir
chmod
a-w testDir
cd
testDir
@FILE_GENERATOR_PROGRAM@
source
-n
test_source_fail
src/main.cpp
View file @
fc8c7259
...
...
@@ -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
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment