Changeset 2929


Ignore:
Timestamp:
Dec 26, 2012, 2:32:57 AM (9 years ago)
Author:
Peter
Message:

add EXIT_SKIP macro. make test compile also --without-samtools

Location:
branches/0.10-stable/test
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/0.10-stable/test/Suite.h

    r2649 r2929  
    2525
    2626#define YAT_TEST_PROLOGUE "\n=== " << __func__ << " ===\n"
     27
     28// used to tell automake that test should be skipped
     29#define EXIT_SKIP 77
    2730
    2831#include <yat/utility/VectorMutable.h>
  • branches/0.10-stable/test/bam_iterator.cc

    r2895 r2929  
    2020#include "Suite.h"
    2121
     22#ifdef HAVE_LIBBAM
    2223#include "yat/omic/BamFile.h"
    2324#include "yat/omic/BamRead.h"
    2425#include "yat/omic/BamReadIterator.h"
    2526#include "yat/omic/BamWriteIterator.h"
     27#endif
    2628
    2729#include <algorithm>
    2830#include <cassert>
    2931#include <fstream>
    30 #include <iostream>
    3132#include <string>
    3233
    3334using namespace theplu::yat;
     35
     36void test1(test::Suite& suite);
     37
     38int main(int argc, char* argv[])
     39{
     40  test::Suite suite(argc, argv);
     41#ifndef HAVE_LIBBAM
     42  suite.out() << "no libbam\n";
     43  return EXIT_SKIP;
     44#endif
     45#ifndef HAVE_SAMTOOLS
     46  suite.out() << "no samtools\n";
     47  return EXIT_SKIP;
     48#endif
     49  test1(suite);
     50  return suite.return_value();
     51}
     52
     53#ifdef HAVE_LIBBAM
    3454using namespace omic;
    3555
     
    7999};
    80100
    81 int main(int argc, char* argv[])
     101
     102void test1(test::Suite& suite)
    82103{
    83 #ifndef HAVE_SAMTOOLS
    84   return EXIT_SKIP;
    85 #endif
    86   test::Suite suite(argc, argv);
    87 
    88104  std::string file = "../../data/foo.sorted.bam";
    89105
     
    99115  in.open(file);
    100116  size_t n1 = std::distance(BamReadIterator(in), BamReadIterator());
    101   std::cout << "entries in " << file << ": " << n1 << "\n";
     117  suite.out() << "entries in " << file << ": " << n1 << "\n";
    102118  in.close();
    103119
     
    105121  size_t n2 = std::distance(BamReadIterator(copy), BamReadIterator());
    106122  copy.close();
    107   std::cout << "entries in " << outname << ": " << n2 << "\n";
     123  suite.out() << "entries in " << outname << ": " << n2 << "\n";
    108124  if (n1!=n2) {
    109     std::cout << "error: not same number of entries in copy\n";
    110     exit(1);
     125    suite.out() << "error: not same number of entries in copy\n";
     126    suite.add(false);
    111127  }
    112128
     
    115131  if (!std::equal(BamReadIterator(in), BamReadIterator(),
    116132                  BamReadIterator(copy), BamReadEqual())) {
    117     std::cout << "error: " << file << " and " << outname << " not equal\n";
    118     exit(1);
     133    suite.out() << "error: " << file << " and " << outname << " not equal\n";
     134    suite.add(false);
    119135  }
    120136  copy.close();
    121137  in.close();
    122138  unlink(outname.c_str());
    123   std::cout << "OK\n";
    124   return 0;
    125139}
     140#endif
  • branches/0.10-stable/test/bam_pair_analyse.cc

    r2902 r2929  
    2020#include "Suite.h"
    2121
     22using namespace theplu::yat;
     23
     24#if HAVE_LIBBAM
    2225#include "yat/omic/algorithm.h"
    2326#include "yat/omic/BamRead.h"
    2427#include "yat/omic/BamReadIterator.h"
     28#endif
    2529
    26 using namespace theplu::yat;
     30void test1(test::Suite& suite);
     31
     32int main(int argc, char* argv[])
     33{
     34  test::Suite suite(argc, argv);
     35#ifndef HAVE_LIBBAM
     36  suite.out() << "no libbam\n";
     37  return EXIT_SKIP;
     38#endif
     39#ifndef HAVE_SAMTOOLS
     40  suite.out() << "no samtools available\n";
     41  return EXIT_SKIP;
     42#endif
     43
     44#ifdef HAVE_LIBBAM
     45  test1(suite);
     46#endif
     47  return suite.return_value();
     48}
     49
     50
     51#ifdef HAVE_LIBBAM
    2752using namespace omic;
    2853
     
    3964};
    4065
    41 
    42 int main(int argc, char* argv[])
     66void test1(test::Suite& suite)
    4367{
    44 #ifndef HAVE_SAMTOOLS
    45   return EXIT_SKIP;
    46 #endif
    47   test::Suite suite(argc, argv);
    48 
    4968  std::string file = "../../data/foo.sorted.bam";
    5069
     
    5473  Counter counter;
    5574  bam_pair_analyse(iter, end, counter);
    56 
    5775  suite.out() << counter.n_ << "\n";
    58 
    5976  suite.add(counter.n_==395);
    60 
    6177  is.close();
    62   return suite.return_value();
    6378}
     79#endif
  • branches/0.10-stable/test/bam_region_iterator.cc

    r2928 r2929  
    2020#include "Suite.h"
    2121
     22#ifdef HAVE_LIBBAM
    2223#include "yat/omic/BamReadIterator.h"
    2324#include "yat/omic/BamWriteIterator.h"
    2425#include "yat/omic/config_bam.h"
     26#endif
    2527
     28#ifdef YAT_BAM_HEADER
    2629#include YAT_BAM_HEADER
     30#endif
    2731
    2832#include <algorithm>
     
    3337
    3438using namespace theplu::yat;
    35 using namespace theplu::yat::omic;
     39
     40void test1(test::Suite& suite);
     41int main(int argc, char* argv[])
     42{
     43  test::Suite suite(argc, argv);
     44#ifndef HAVE_LIBBAM
     45  suite.out() << "no libbam\n";
     46  return EXIT_SKIP;
     47#endif
     48#ifndef HAVE_SAMTOOLS
     49  suite.out() << "no samtools\n";
     50  return EXIT_SKIP;
     51#endif
     52
     53  try {
     54    test1(suite);
     55  }
     56  catch (std::runtime_error& e) {
     57    suite.err() << "what: " << e.what() << "\n";
     58    suite.add(false);
     59  }
     60
     61  return suite.return_value();
     62}
    3663
    3764void test1(test::Suite& suite)
    3865{
     66#ifdef HAVE_LIBBAM
     67  using namespace omic;
    3968  std::string file = "../../data/foo.sorted.bam";
    4069
     
    6493  suite.err() << "count: " << count << "\nexpected: 185\n";
    6594  suite.add(false);
     95#endif
    6696}
    67 
    68 
    69 int main(int argc, char* argv[])
    70 {
    71 #ifndef HAVE_SAMTOOLS
    72   return EXIT_SKIP;
    73 #endif
    74   test::Suite suite(argc, argv);
    75 
    76   try {
    77     test1(suite);
    78   }
    79   catch (std::runtime_error& e) {
    80     suite.err() << "what: " << e.what() << "\n";
    81     suite.add(false);
    82   }
    83 
    84   return suite.return_value();
    85 }
Note: See TracChangeset for help on using the changeset viewer.