Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,4 @@ script:
- bin/fetch-configlet
- bin/configlet lint .
- bin/check-configlet-fmt.sh
- cmake -G Ninja
- ninja
- bin/check-exercises.sh
54 changes: 4 additions & 50 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,56 +20,10 @@ endfunction()

option(EXERCISM_RUN_ALL_TESTS "Run all Exercism tests" On)

foreach(exercise
hello-world
bob
word-count
hamming
anagram
food-chain
beer-song
nucleotide-count
rna-transcription
phone-number
grade-school
robot-name
leap
etl
space-age
grains
gigasecond
triangle
clock
raindrops
difference-of-squares
roman-numerals
nth-prime
sieve
binary
sum-of-multiples
series
prime-factors
pascals-triangle
trinary
crypto-square
scrabble-score
hexadecimal
say
meetup
queen-attack
allergies
atbash-cipher
bracket-push
all-your-base
pangram
binary-search-tree
robot-simulator
binary-search
isogram
reverse-string
acronym
luhn
)
file(GLOB exercise_list ${CMAKE_CURRENT_SOURCE_DIR}/exercises/*)

foreach(exercise_dir ${exercise_list})
get_filename_component(exercise ${exercise_dir} NAME)
travis_fixup(${exercise} ${alt_exercise_tree})
add_subdirectory(${alt_exercise_tree}/${exercise})
endforeach()
31 changes: 31 additions & 0 deletions bin/check-exercises.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
#
# Runs tests only if the current Pull Request has modified a test or the root
# CMakeLists.txt, or if we are running on the master branch.

# Fail if any command fails
set -e

repo=$(cd "$(dirname "$0")/.." && pwd)

# Configure all the tests.
cmake -G Ninja "$repo"
echo ""

if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
echo "This is not a Pull Request, running all tests."
cmake --build "$repo"
elif git diff --name-only master | grep "^CMakeLists.txt"; then
echo "This PR changes the root CMakeLists.txt."
echo "Running a single test and then all tests."
cmake --build "$repo" -- test_hello-world
cmake --build "$repo"
else
tests="$(git diff --name-only master | grep "^exercises/" | cut -d '/' -f2 | sed 's/.*/test_&/' | uniq | tr '\n' ' ')"
if [ ${#tests} -ne 0 ]; then
echo "Running only tests that have changed."
cmake --build "$repo" -- $tests
else
echo "No tests changed."
fi
fi