Merge branch 'main' of gitlab.emi.u-bordeaux.fr:pt2/teams-s4/tm07/lightup-07c
This commit is contained in:
commit
2d9a48dfc1
6 files changed
+101
-57
No files matched your search
+2
-1
@@ -1,3 +1,4 @@
|
||||
build/
|
||||
.vscode/
|
||||
*.txt
|
||||
*.txt
|
||||
!CMakeLists.txt
|
||||
+35
-18
@@ -13,35 +13,44 @@ build-job: # This job runs in the build stage, which runs first.
|
||||
script:
|
||||
- mkdir -p build
|
||||
- cd build
|
||||
- cmake -DCMAKE_BUILD_TYPE=DEBUG ..
|
||||
- make VERBOSE=ON -j 4 | tee ../build.log
|
||||
- cmake -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/c99-gcc ..
|
||||
- make VERBOSE=ON -j 18 | tee ./build.log
|
||||
artifacts:
|
||||
expire_in: 10 minutes
|
||||
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
|
||||
paths:
|
||||
- build/
|
||||
- build.log
|
||||
|
||||
test-v1-job: # This job runs in the test stage.
|
||||
dependencies:
|
||||
- build-job
|
||||
needs:
|
||||
- job: build-job
|
||||
artifacts: false
|
||||
stage: test # It only starts when the job in the build stage completes successfully.
|
||||
script:
|
||||
- mkdir -p build
|
||||
- cd build
|
||||
- echo "building project"
|
||||
- cmake -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/c99-gcc ..
|
||||
- make VERBOSE=ON -j 18 | tee ./build.log
|
||||
- echo "Running tests V1..."
|
||||
- ctest -R v1 | tee ../test-v1-job.log
|
||||
artifacts:
|
||||
expire_in: 10 minutes
|
||||
paths:
|
||||
- build/
|
||||
- test-v2-job.log
|
||||
- test-v1-job.log
|
||||
|
||||
test-v2-job: # This job runs in the test stage.
|
||||
dependencies:
|
||||
- build-job
|
||||
needs:
|
||||
- job: build-job
|
||||
artifacts: false
|
||||
stage: test # It only starts when the job in the build stage completes successfully.
|
||||
script:
|
||||
- mkdir -p build
|
||||
- cd build
|
||||
- echo "building project"
|
||||
- cmake -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/c99-gcc ..
|
||||
- make VERBOSE=ON -j 18 | tee ./build.log
|
||||
- echo "Running tests V2..."
|
||||
- ctest -R v2 | tee ../test-v2-job.log
|
||||
artifacts:
|
||||
@@ -53,19 +62,27 @@ test-v2-job: # This job runs in the test stage.
|
||||
### coverage
|
||||
coverage-job:
|
||||
stage: coverage
|
||||
dependencies:
|
||||
- test-v1-job
|
||||
- test-v2-job
|
||||
needs:
|
||||
- job: test-v1-job
|
||||
artifacts: false
|
||||
- job: test-v2-job
|
||||
artifacts: false
|
||||
script:
|
||||
- mkdir -p build
|
||||
- cd build
|
||||
- make ExperimentalCoverage | tee ../coverage.log
|
||||
- echo "building project"
|
||||
- cmake -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/c99-gcc ..
|
||||
- make VERBOSE=ON -j 18
|
||||
- ctest -R v1
|
||||
- ctest -R v2
|
||||
- make ExperimentalCoverage
|
||||
- gcovr --xml-pretty --exclude-unreachable-branches --print-summary -o coverage.xml --root ${CI_PROJECT_DIR}
|
||||
coverage: /^\s*lines:\s*\d+.\d+\%/
|
||||
artifacts:
|
||||
expire_in: 10 minutes
|
||||
paths:
|
||||
- build/
|
||||
- coverage.log
|
||||
only:
|
||||
- coverage
|
||||
name: ${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}
|
||||
expire_in: 2 days
|
||||
reports:
|
||||
cobertura: build/coverage.xml
|
||||
|
||||
### cleanup project for security issues
|
||||
cleanup:
|
||||
|
||||
+27
-19
@@ -1,34 +1,37 @@
|
||||
#version minimale de cmake nécessaire
|
||||
cmake_minimum_required(VERSION 2.6...3.13)
|
||||
|
||||
enable_testing()
|
||||
|
||||
#nom du projet
|
||||
project (game_text)
|
||||
project ("Lightup" C)
|
||||
|
||||
# enable testing
|
||||
enable_testing()
|
||||
include(CTest)
|
||||
|
||||
#positionne la variable
|
||||
set(CMAKE_C_FLAGS "-std=c99 -g -Wall -Wextra -Wpedantic -Werror")
|
||||
set(CMAKE_C_FLAGS "-std=c99 -Wall -pthread -Wextra -Wunused-parameter -Wpedantic -Werror")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-g --coverage") # use CMake option: -DCMAKE_BUILD_TYPE=DEBUG
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") # use CMake option: -DCMAKE_BUILD_TYPE=RELEASE
|
||||
|
||||
#définit le nom du programme ainsi que
|
||||
#ses sources
|
||||
############################# SRC #############################
|
||||
|
||||
# game_text
|
||||
add_executable(game_text game_text.c)
|
||||
add_executable(game_test game_test.c)
|
||||
|
||||
#add_executable(history_test history_test.c)
|
||||
|
||||
#les dépendances sont calculées automatiquement
|
||||
target_link_libraries(game_text game)
|
||||
|
||||
# game tests
|
||||
add_executable(game_test game_test.c)
|
||||
target_link_libraries(game_test game)
|
||||
|
||||
#target_link_libraries(history_test game)
|
||||
|
||||
#Libraries
|
||||
# libgame
|
||||
add_library (game game.c game_aux.c game_ext.c game_private.c history.c game_tools.c game_examples.c)
|
||||
|
||||
# Tests
|
||||
# history tests
|
||||
#add_executable(history_test history_test.c)
|
||||
#target_link_libraries(history_test game)
|
||||
|
||||
# V1
|
||||
|
||||
############################# TEST V1 #############################
|
||||
|
||||
add_test(test_thoguet_game_new_v1 ./game_test game_new)
|
||||
add_test(test_thoguet_game_default_v1 ./game_test game_default)
|
||||
@@ -46,7 +49,8 @@ add_test(test_thperrier_game_is_blank_v1 ./game_test game_is_blank)
|
||||
add_test(test_thperrier_game_new_empty_v1 ./game_test game_new_empty)
|
||||
add_test(test_game_equal_v1 ./game_test equal)
|
||||
|
||||
# V2
|
||||
|
||||
############################# TEST V2 #############################
|
||||
|
||||
add_test(test_thoguet_game_get_square_v2 ./game_test game_get_square)
|
||||
add_test(test_thoguet_game_restart_v2 ./game_test game_restart)
|
||||
@@ -66,11 +70,15 @@ add_test(test_nnunes_game_nb_cols_v2 ./game_test game_nb_cols)
|
||||
add_test(test_nnunes_game_is_wrapping_v2 ./game_test game_is_wrapping)
|
||||
add_test(test_thoguet_game_print_v2 ./game_test game_print)
|
||||
|
||||
# V3
|
||||
|
||||
############################# TEST V3 #############################
|
||||
|
||||
add_test(test_thoguet_game_save_v3 ./game_test game_save)
|
||||
add_test(test_mfatih_game_load_v3 ./game_test game_load)
|
||||
#Tests HISTORY
|
||||
|
||||
|
||||
############################# TEST HISTORY #############################
|
||||
|
||||
# add_test(test_history_history_alloc ./history_test history_alloc)
|
||||
# add_test(test_history_create_empty ./history_test history_create_empty)
|
||||
# add_test(test_history_delete_entire_history ./history_test history_delete_entire_history)
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
# lightup-07c
|
||||
# README
|
||||
[](https://gitlab.emi.u-bordeaux.fr/pt2/teams-s4/tm07/lightup-07c/-/commits/main)
|
||||
[](https://gitlab.emi.u-bordeaux.fr/pt2/teams-s4/tm07/lightup-07c/-/commits/main)
|
||||
[](https://gitlab.emi.u-bordeaux.fr/pt2/teams-s4/tm07/lightup-07c/-/commits/main)
|
||||
[](https://gitlab.emi.u-bordeaux.fr/pt2/teams-s4/tm07/lightup-07c/-/commits/main)
|
||||
|
||||
|
||||
## lightup-07c
|
||||
|
||||
Projet Techno
|
||||
|
||||
|
||||
+29
-17
@@ -4,9 +4,13 @@
|
||||
#include "game.h"
|
||||
#include "game_aux.h"
|
||||
#include "game_ext.h"
|
||||
#include "game_tools.h"
|
||||
|
||||
#define NBCHARERR 4
|
||||
#define CHAR0ASCII 48
|
||||
#define GAME_PRINT_PLUS_LINE(g) \
|
||||
printf("--------------------------------------------------\n"); \
|
||||
game_print(g);
|
||||
|
||||
/**
|
||||
* @brief Edit the stringError with all errors of g
|
||||
@@ -59,7 +63,7 @@ void checkPlayMove(game g, square s) {
|
||||
game_play_move(g, i, j, s);
|
||||
else
|
||||
printf("Coordonnées invalide.\n");
|
||||
game_print(g);
|
||||
GAME_PRINT_PLUS_LINE(g);
|
||||
return;
|
||||
}
|
||||
printf("Commande inconnue.\n");
|
||||
@@ -75,31 +79,38 @@ void printhelp(void) {
|
||||
printf("l <i> <j> : Place une ampoule (*) à la position (<i>,<j>).\n");
|
||||
printf("m <i> <j> : Place une marque (-) à la position (<i>,<j>).\n");
|
||||
printf("b <i> <j> : Place une case vide ( ) à la position (<i>,<j>).\n");
|
||||
printf("w <n> : Sauvegardez votre partie au nom <n>.\n");
|
||||
}
|
||||
|
||||
void usage(char* argv[]) {
|
||||
printf("Usage : %s => Joue la partie par défaut\n", argv[0]);
|
||||
printf("Usage : %s => Joue la partie par défaut\n", argv[0]);
|
||||
printf(" %s <filename> => Charge la partie sur le fichier <filename>\n", argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
game g;
|
||||
if (argc == 1)
|
||||
if (argc == 1) {
|
||||
// Create new game
|
||||
g = game_default();
|
||||
else
|
||||
} else if (argc == 2) {
|
||||
char* gameFile = argv[1];
|
||||
g = game_load(gameFile);
|
||||
} else {
|
||||
usage(argv);
|
||||
}
|
||||
// init string for errors
|
||||
char stringError[game_nb_rows(g) * game_nb_cols(g) * NBCHARERR];
|
||||
char c;
|
||||
char* fileSave = (char*)malloc(sizeof(char) * 20);
|
||||
// print game
|
||||
game_print(g);
|
||||
GAME_PRINT_PLUS_LINE(g);
|
||||
// test if game is over
|
||||
while (!game_is_over(g)) {
|
||||
// print errors
|
||||
if (checkerrors(g, stringError))
|
||||
printf("Il y a un problème case(s): %s\n", stringError);
|
||||
printf("Entrez une commande (h pour afficher l'aide): ");
|
||||
printf("\nIl y a un problème case(s): %s\n", stringError);
|
||||
printf("\nEntrez une commande (h pour afficher l'aide): ");
|
||||
// scan the first command without args
|
||||
if (scanf(" %c", &c)) {
|
||||
switch (c) {
|
||||
@@ -108,25 +119,20 @@ int main(int argc, char* argv[]) {
|
||||
break;
|
||||
case 'r':
|
||||
game_restart(g);
|
||||
printf("Partie réinitialisé avec succes !\n");
|
||||
game_print(g);
|
||||
printf("\nPartie réinitialisé avec succes !\n");
|
||||
GAME_PRINT_PLUS_LINE(g);
|
||||
break;
|
||||
case 'q':
|
||||
printf("Solution: \n");
|
||||
game solution = game_default_solution();
|
||||
game_print(solution);
|
||||
game_delete(solution);
|
||||
game_delete(g);
|
||||
printf("shame\n");
|
||||
printf("shame on you :o\n");
|
||||
return EXIT_SUCCESS;
|
||||
break;
|
||||
case 'z':
|
||||
game_undo(g);
|
||||
game_print(g);
|
||||
GAME_PRINT_PLUS_LINE(g);
|
||||
break;
|
||||
case 'y':
|
||||
game_redo(g);
|
||||
game_print(g);
|
||||
GAME_PRINT_PLUS_LINE(g);
|
||||
break;
|
||||
case 'l':
|
||||
checkPlayMove(g, S_LIGHTBULB);
|
||||
@@ -137,6 +143,12 @@ int main(int argc, char* argv[]) {
|
||||
case 'b':
|
||||
checkPlayMove(g, S_BLANK);
|
||||
break;
|
||||
case 'w':
|
||||
scanf(" %s", fileSave);
|
||||
game_save(g, fileSave);
|
||||
printf("Partie sauvegardée au nom %s\n", fileSave);
|
||||
GAME_PRINT_PLUS_LINE(g);
|
||||
break;
|
||||
default:
|
||||
printf("Commande inconnue.\n");
|
||||
}
|
||||
|
||||
@@ -58,7 +58,6 @@ game game_load(char* filename) {
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
game_print(g1);
|
||||
return g1;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user