58 lines
1.5 KiB
Plaintext
58 lines
1.5 KiB
Plaintext
|
#!/bin/bash
|
||
|
#xcrypted
|
||
|
# Auteur: Pascal Anelli
|
||
|
# Modified: 01 02 2021
|
||
|
# Session 3
|
||
|
|
||
|
source ${LIBSH}/libeval.sh
|
||
|
|
||
|
#-----------------------------------------
|
||
|
rep=~/Sequence4/A44
|
||
|
challenge=C44Q3
|
||
|
scriptname=csvtohtml.sh
|
||
|
exo=$rep/$scriptname
|
||
|
ref="/tmp/c443"
|
||
|
sample=/tmp/sample.html
|
||
|
#---------------------------------
|
||
|
mkfiledata $ref
|
||
|
mkfilehtml $ref
|
||
|
|
||
|
# Debut
|
||
|
firstcheck
|
||
|
|
||
|
# 1 working
|
||
|
$exo ${ref}.csv 1>|$sample 2>/dev/null
|
||
|
step $(vraifaux $?) "Le script fonctionne " true
|
||
|
|
||
|
# 2 display
|
||
|
[ -s "$sample" ]
|
||
|
step $(vraifaux $?) "Le resultat est affiche " true
|
||
|
|
||
|
# 3 accuracy
|
||
|
output=$(diff -i -t -b -w -B -q $sample ${ref}.html)
|
||
|
[ -z "$output" ]
|
||
|
step $(vraifaux $?) "Le resultat en html est celui qui est attendu "
|
||
|
|
||
|
# 4 argument missing
|
||
|
$exo &>/dev/null
|
||
|
[ $? -eq 1 ]
|
||
|
step $(vraifaux $?) "Le script retourne le code 1 en cas d'absence d'argument"
|
||
|
|
||
|
# 5 message usage
|
||
|
$exo 2>&1 | grep -q -i "Usage" &>/dev/null
|
||
|
step $(vraifaux $?) "Le script affiche l'usage en cas d'absence d'argument. "
|
||
|
|
||
|
# 6 while
|
||
|
grep -q while $exo 2>/dev/null
|
||
|
step $(vraifaux $?) "Le script lit le fichier ligne par ligne avec un while. "
|
||
|
|
||
|
# 7 utilisation du for
|
||
|
grep -q -e "^[[:blank:]]*for[[:blank:]]*((" $exo 2>/dev/null
|
||
|
step $(vraifaux $?) "Le script utilise une boucle for (( )) "
|
||
|
#-------------------------------------
|
||
|
# Fin
|
||
|
status "${challenge}_$res"
|
||
|
exit 0
|
||
|
|
||
|
# listcode = [ '000', 'df7', 'c7b', '197', '7a4', '894', '08a', '037' ]
|