Skip to content

Commit

Permalink
Merge pull request #113 from marehr/travis_upgrade
Browse files Browse the repository at this point in the history
travis: Use g++-7 direcly from packages (and fix ubuntu 16.04 problems)
  • Loading branch information
rrahn authored Feb 26, 2018
2 parents f25a4fd + 5ba7526 commit b9eb19c
Show file tree
Hide file tree
Showing 5 changed files with 394 additions and 58 deletions.
47 changes: 26 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,42 @@ language: cpp
git:
submodules: true

env:
global:
- GCC_VERSION="20170319"

cache:
apt: true
ccache: true
directories:
- $HOME/debs

before_install:
- export GCC_PATH=/home/travis/gcc-7-$GCC_VERSION
- export PATH=$GCC_PATH/bin/:$PATH
- export LD_LIBRARY_PATH=$GCC_PATH/lib64/:$LD_LIBRARY_PATH
- echo $GCC_VERSION
- echo $GCC_PATH
- echo $PATH
- echo $LD_LIBRARY_PATH
- wget -nc -P $HOME/debs http://ftp.seqan.de/contribs/g++-7_"${GCC_VERSION}"_amd64.deb

linux-gcc-7: &linux-gcc-7
os: linux
compiler: 'g++-7'
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-7']
before_install:
- export CC="gcc-7" CXX="g++-7"

# https://docs.travis-ci.com/user/languages/c/#gcc-on-linux
matrix:
include:
- << : *linux-gcc-7
env:
- BUILD=test
- BUILD_TYPE=Release
- << : *linux-gcc-7
env:
- BUILD=test
- BUILD_TYPE=Debug

install:
- dpkg -x $HOME/debs/g++-7_"${GCC_VERSION}"_amd64.deb $HOME
- mv $HOME/home/travis/* $HOME
- ccache --version
- g++ -v
- $CXX -v
- cmake --version

before_script:
- mkdir ../seqan3-build
- cd ../seqan3-build
- cmake ../seqan3/test
- make googletest -j
- cmake ../seqan3/${BUILD} -DCMAKE_BUILD_TYPE=${BUILD_TYPE}
- make googletest

script:
- make -k
Expand Down
8 changes: 3 additions & 5 deletions include/seqan3/range/container/concatenated_sequences.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ template <typename inner_type,
//!\endcond
class concatenated_sequences
{
static_assert(!detail::sequence_concept_modified_by_const_iterator_bug<inner_type>,
"KNOWN BUG: inner_type = std::basic_string<> is not working "
"for the ubuntu::ppa version of gcc7, because of a faulty STL version. ");
protected:
//!\privatesection
//!\brief Where the concatenation is stored.
Expand Down Expand Up @@ -1319,8 +1322,3 @@ class concatenated_sequences
};

} // namespace seqan3

#ifndef NDEBUG
static_assert(seqan3::reservable_sequence_concept<seqan3::concatenated_sequences<std::string>>);
static_assert(seqan3::forward_range_concept<seqan3::concatenated_sequences<std::string>>);
#endif
129 changes: 97 additions & 32 deletions include/seqan3/range/container/concept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,87 @@

#include <initializer_list>

// remove if sequence_concept_modified_by_const_iterator_bug vanished from travis
#include <string>

// TODO:
// * merge sequence_concept_modified_by_const_iterator back into
// sequence_concept
// * remove is_basic_string
// * fix test cases
// * remove #include <string> in this file
// once the ubuntu::ppa [1] of g++-7 has a newer update than
// 7.2.0-1ubuntu1~16.04 (2017-08-20)
//
// [1] https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test?field.series_filter=xenial
namespace seqan3::detail
{
//!\privatesection

//!\brief Returns whether `basic_string_t` is of type `std::basic_string<value_t, traits_t, allocator_t>`.
//!\attention Will be deleted once seqan3::detail::sequence_concept_modified_by_const_iterator_bug is fixed.
template <typename basic_string_t>
struct is_basic_string : std::false_type
{};

//!\brief Returns whether `basic_string_t` is of type `std::basic_string<value_t, traits_t, allocator_t>`.
//!\attention Will be deleted once seqan3::detail::sequence_concept_modified_by_const_iterator_bug is fixed.
template <typename value_t, typename traits_t, typename allocator_t>
struct is_basic_string<std::basic_string<value_t, traits_t, allocator_t>> : std::true_type
{};

//!\brief Shorthand of seqan3::detail::is_basic_string
//!\attention Will be deleted once seqan3::detail::sequence_concept_modified_by_const_iterator_bug is fixed.
template <typename basic_string_t>
constexpr bool is_basic_string_v = is_basic_string<basic_string_t>::value;

/*!\interface seqan3::detail::sequence_concept_modified_by_const_iterator <>
* \brief Checks whether insert and erase can be used with const_iterator
*
* \attention This will be merged back into sequence_concept once
* seqan3::detail::sequence_concept_modified_by_const_iterator_bug is fixed.
*/
//!\cond
template <typename type>
concept bool sequence_concept_modified_by_const_iterator = requires (type val, type val2)
{
{ val.insert(val.cbegin(), val2.front()) } -> typename type::iterator;
{ val.insert(val.cbegin(), typename type::value_type{}) } -> typename type::iterator;
{ val.insert(val.cbegin(), typename type::size_type{}, typename type::value_type{})} -> typename type::iterator;
{ val.insert(val.cbegin(), val2.begin(), val2.end()) } -> typename type::iterator;
requires is_basic_string_v<type> || requires(type val)
{
// TODO this function is not defined on strings (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83328)
{ val.insert(val.cbegin(), std::initializer_list<typename type::value_type>{}) } -> typename type::iterator;
};
{ val.erase(val.cbegin()) } -> typename type::iterator;
{ val.erase(val.cbegin(), val.cend()) } -> typename type::iterator;

{ val.insert(val.begin(), typename type::size_type{}, typename type::value_type{}) } -> typename type::iterator;
{ val.insert(val.begin(), val2.begin(), val2.end()) } -> typename type::iterator;
};
//!\endcond

/*!\brief Workaround for a ubuntu/travis-ci exclusive bug with g++-7.2.
*
* seqan3::detail::sequence_concept_modified_by_const_iterator <std::string> is
* known to work, but ubuntu::ppa (<18.04)/travis-ci has a version of g++-7.2
* where a bug in the STL prevents this concept to be true.
*
* \attention This workaround can be removed if
* `/test/range/container/container_concept_test.cpp` is not failing on
* ubuntu::ppa (<18.04)/travis-ci anymore. \n
* Probably when the ppa version of gcc7 is newer than `7.2.0-1ubuntu1~16.04` (2017-08-20)
* \sa https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test?field.series_filter=xenial
*/
template<typename string_t = std::string>
constexpr bool sequence_concept_modified_by_const_iterator_bug =
is_basic_string_v<string_t> && !sequence_concept_modified_by_const_iterator<string_t>;

//!\publicsection

} // seqan3::detail

namespace seqan3
{

Expand Down Expand Up @@ -127,15 +208,22 @@ concept bool sequence_concept = requires (type val, type val2)

// modify container
//TODO: how do you model this?
// { val.emplace(typename type::const_iterator{}, ? } -> typename type::iterator;
{ val.insert(val.cbegin(), val2.front()) } -> typename type::iterator;
{ val.insert(val.cbegin(), typename type::value_type{}) } -> typename type::iterator;
{ val.insert(val.cbegin(), typename type::size_type{}, typename type::value_type{})} -> typename type::iterator;
{ val.insert(val.cbegin(), val2.begin(), val2.end()) } -> typename type::iterator;
//TODO this fails on std::string, although it should work
// { val.insert(val.cbegin(), std::initializer_list<typename type::value_type>{}) } -> typename type::iterator;
{ val.erase(val.cbegin()) } -> typename type::iterator;
{ val.erase(val.cbegin(), val.cend()) } -> typename type::iterator;
// { val.emplace(typename type::const_iterator{}, ? } -> typename type::iterator;

{ val.insert(val.begin(), val2.front()) } -> typename type::iterator;
{ val.insert(val.begin(), typename type::value_type{}) } -> typename type::iterator;
// because of a travis bug we can't assume typename type::iterator as return type
{ val.insert(val.begin(), typename type::size_type{}, typename type::value_type{}) };
{ val.insert(val.begin(), val2.begin(), val2.end()) };
//TODO should return type::iterator on strings (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83328)
{ val.insert(val.begin(), std::initializer_list<typename type::value_type>{}) };
{ val.erase(val.begin()) } -> typename type::iterator;
{ val.erase(val.begin(), val.end()) } -> typename type::iterator;

// workaround a travis bug where insert/erase can't take a const iterator, e.g. cbegin()
requires detail::sequence_concept_modified_by_const_iterator_bug<type> ||
detail::sequence_concept_modified_by_const_iterator<type>;

{ val.push_back(val.front()) } -> void;
{ val.push_back(typename type::value_type{}) } -> void;
{ val.pop_back() } -> void;
Expand Down Expand Up @@ -202,26 +290,3 @@ concept bool reservable_sequence_concept = requires (type val)
//!\}

} // namespace seqan3

#ifndef NDEBUG
/* Check the STL containers */

#include <vector>
#include <array>
#include <list>
#include <forward_list>
#include <deque>
#include <string>

static_assert(seqan3::container_concept<std::array<char, 2>>);
static_assert(seqan3::sequence_concept<std::list<char>>);
static_assert(seqan3::random_access_sequence_concept<std::vector<char>>);
static_assert(seqan3::random_access_sequence_concept<std::deque<char>>);
static_assert(seqan3::random_access_sequence_concept<std::string>);

/* Check the SDSL containers */
//TODO

/* Check our containers */
//TODO
#endif
1 change: 1 addition & 0 deletions test/range/container/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
seqan3_test(container_concept_test.cpp)
seqan3_test(container_of_container_test.cpp)
Loading

0 comments on commit b9eb19c

Please sign in to comment.