mooc/filesystem/usr/evalp1/evalQ441

72 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
#xcrypted
# Auteur: Pascal Anelli
# Session 4
# 21 decembre 2022
source ${LIBSH}/libeval.sh
#-----------------------------------------
rep=~/Sequence4/A44
challenge=C44Q1
scriptname=blankline.sh
exo=$rep/$scriptname
sample="/usr/script/data/c442.txt"
#sample="./c442.txt"
#---------------------------------
# Debut
firstcheck
# 1 working
$exo "$sample" &>/dev/null
step $(vraifaux $?) "Le script fonctionne " true
# 2 lines added
number=$($exo "$sample" 2>/dev/null | wc -l)
[ "$number" -gt 4 ]
step $(vraifaux $?) "Des lignes sont ajoutees "
# 3 The good number of blank lines is added
number=$($exo "$sample" 2>/dev/null | egrep -c "^$")
[ "$number" -eq 3 ]
step $(vraifaux $?) "Le bon nombre de lignes vides a ete ajoute "
# 4 Last line is not empty
$exo "$sample" 2>/dev/null | tail -1 | egrep -c "^$" &>/dev/null
[ $? -eq 1 ]
step $(vraifaux $?) "La dernière ligne n'est pas vide "
# 5 while
grep -q while $exo 2>/dev/null
step $(vraifaux $?) "Le script utilise la bonne boucle "
# 6 tests etendu
grep -q ' \[ .* \]' $exo 2>/dev/null
[ $? -eq 1 ]
step $(vraifaux $?) "Le script utilise uniquement des tests etendus "
#==================
# check argument
# 7 exit status
$exo &>/dev/null
[ $? -eq 1 ]
step $(vraifaux $?) "Le script retourne le code 1 en cas d'absence d'argument"
# 8 usage message
$exo 2>&1 | grep -q "Usage" &>/dev/null
step $(vraifaux $?) "Le script affiche l'usage en cas d'absence d'argument "
#--------------------------------
# Fin
status "${challenge}_$res"
exit 0
# listcode = [ '000', '738', '4c8', '988', '629', '10b', 'f6d', '25e', '9aa' ]