From 352d3b9e07b8b080843c00f54c1c455682eb4392 Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Fri, 12 Apr 2019 17:30:20 -0700 Subject: [PATCH 1/7] Adding partial build support. --- .travis.yml | 3 +-- bin/check-exercises.sh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100755 bin/check-exercises.sh diff --git a/.travis.yml b/.travis.yml index cb3a966e..469d8e3a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,5 +49,4 @@ install: script: - bin/fetch-configlet - bin/configlet lint . - - cmake -G Ninja - - ninja + - bin/check-exercises.sh diff --git a/bin/check-exercises.sh b/bin/check-exercises.sh new file mode 100755 index 00000000..f3c760ef --- /dev/null +++ b/bin/check-exercises.sh @@ -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_&/' | 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 From d69bb4e754fe17ea1d796e0d7b2d1f04d8e59c59 Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Sat, 13 Apr 2019 11:20:26 -0700 Subject: [PATCH 2/7] DO NOT MERGE: Touching hamming and leap. --- exercises/hamming/tmp.txt | 0 exercises/leap/tmp.txt | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 exercises/hamming/tmp.txt create mode 100644 exercises/leap/tmp.txt diff --git a/exercises/hamming/tmp.txt b/exercises/hamming/tmp.txt new file mode 100644 index 00000000..e69de29b diff --git a/exercises/leap/tmp.txt b/exercises/leap/tmp.txt new file mode 100644 index 00000000..e69de29b From a89f3a71e796182559cfccd89d180dae445122ad Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Sat, 13 Apr 2019 11:21:14 -0700 Subject: [PATCH 3/7] Revert "DO NOT MERGE: Touching hamming and leap." This reverts commit d69bb4e754fe17ea1d796e0d7b2d1f04d8e59c59. --- exercises/hamming/tmp.txt | 0 exercises/leap/tmp.txt | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 exercises/hamming/tmp.txt delete mode 100644 exercises/leap/tmp.txt diff --git a/exercises/hamming/tmp.txt b/exercises/hamming/tmp.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/exercises/leap/tmp.txt b/exercises/leap/tmp.txt deleted file mode 100644 index e69de29b..00000000 From 72ffa5c4ce0004742f0aec173ec35592ae8d5e27 Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Sat, 13 Apr 2019 11:31:15 -0700 Subject: [PATCH 4/7] DO NOT MERGE: Creating failing test in one exercise. --- exercises/acronym/acronym_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/acronym/acronym_test.cpp b/exercises/acronym/acronym_test.cpp index 19457839..229a9296 100644 --- a/exercises/acronym/acronym_test.cpp +++ b/exercises/acronym/acronym_test.cpp @@ -10,7 +10,7 @@ BOOST_AUTO_TEST_CASE(basic) const string expected{"PNG"}; - BOOST_TEST(expected == actual); + BOOST_TEST(expected != actual); } #if defined(EXERCISM_RUN_ALL_TESTS) From 52b1c57c67db94db6eb5dfde1fcee550ad13356c Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Sat, 13 Apr 2019 11:31:56 -0700 Subject: [PATCH 5/7] Revert "DO NOT MERGE: Creating failing test in one exercise." This reverts commit 72ffa5c4ce0004742f0aec173ec35592ae8d5e27. --- exercises/acronym/acronym_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/acronym/acronym_test.cpp b/exercises/acronym/acronym_test.cpp index 229a9296..19457839 100644 --- a/exercises/acronym/acronym_test.cpp +++ b/exercises/acronym/acronym_test.cpp @@ -10,7 +10,7 @@ BOOST_AUTO_TEST_CASE(basic) const string expected{"PNG"}; - BOOST_TEST(expected != actual); + BOOST_TEST(expected == actual); } #if defined(EXERCISM_RUN_ALL_TESTS) From 3fb68bdf7b3402f14ed19d208ae2575f20221da8 Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Sat, 13 Apr 2019 11:32:05 -0700 Subject: [PATCH 6/7] CMake: Detecting exercise list from directory. --- CMakeLists.txt | 54 ++++---------------------------------------------- 1 file changed, 4 insertions(+), 50 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e6ed66dd..594faac9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() From a4b901b642e0a7ae199ccc33dbac565372390e9a Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Sat, 20 Apr 2019 06:39:32 -0700 Subject: [PATCH 7/7] Cleaning up pipeline. --- bin/check-exercises.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/check-exercises.sh b/bin/check-exercises.sh index f3c760ef..a89cdacd 100755 --- a/bin/check-exercises.sh +++ b/bin/check-exercises.sh @@ -21,7 +21,7 @@ elif git diff --name-only master | grep "^CMakeLists.txt"; then cmake --build "$repo" -- test_hello-world cmake --build "$repo" else - tests="$(git diff --name-only master | grep "exercises/" | cut -d '/' -f2 | sed 's/.*/test_&/' | tr '\n' ' ')" + 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