diff --git a/src/test/examples.ml b/src/test/examples.ml index 4cc38ab..1536a23 100644 --- a/src/test/examples.ml +++ b/src/test/examples.ml @@ -68,6 +68,16 @@ let downloader () = let options = List.concat_map regexp_list ~f:(fun r -> ["-e"; r]) in string >> exec (["grep"; "-q"] @ options) |> succeeds in + let no_newline_sed ~input expr = + let with_potential_newline = + string_concat [input; string "\n"] + >> exec ["sed"; expr] + |> output_as_string + in + with_potential_newline >> exec ["tr"; "-d"; "\\n"] + |> output_as_string + in + let module Unwrapper = struct type cmd = unit t @@ -80,8 +90,8 @@ let downloader () = {extension = ext; verb; commands} let remove_suffix v suf = - v >> exec ["sed"; sprintf "s:^\\(.*\\)%s$:\\1:" suf] - |> output_as_string + no_newline_sed ~input:v (sprintf "s:^\\(.*\\)%s$:\\1:" suf) + let to_switch name_variable t_list = let make_case t = @@ -154,9 +164,7 @@ let downloader () = if_seq (filename_ov =$= no_value) ~t:begin let filename = - url >> exec ["sed"; "s:.*/\\([^\\?\\/]*\\)\\?.*:\\1:"] - |> output_as_string - in + no_newline_sed ~input:url "s:.*/\\([^\\?\\/]*\\)\\?.*:\\1:" in let output_path = string_concat [tmp_dir; string "/"; filename] in [current_name#set output_path] diff --git a/tools/travis_ci_test.sh b/tools/travis_ci_test.sh index dabbe50..2544770 100644 --- a/tools/travis_ci_test.sh +++ b/tools/travis_ci_test.sh @@ -69,6 +69,37 @@ make native gennspio_test=_build/src/test/genspio-test.byte genspio_examples=_build/src/test/genspio-examples.byte -$genspio_test +echo "================== TEST 0 ======================================================" +$gennspio_test + +# We also run the example +# we get the script and then we test it + +genspio_downloader=/tmp/genspio-downloader +$genspio_examples dl $genspio_downloader + +sh $genspio_downloader -h + +echo "================== TEST 1 ======================================================" +sh $genspio_downloader -c -t /tmp/test1 -f k3.0.0.tar.gz -u https://github.com/hammerlab/ketrew/archive/ketrew.3.0.0.tar.gz +ls -la /tmp/test1 +test -f /tmp/test1/k3.0.0.tar +test -f /tmp/test1/ketrew-ketrew.3.0.0/README.md + + +echo "================== TEST 2 ======================================================" +sh $genspio_downloader -c -t /tmp/genstest2 -u https://www.dropbox.com/s/h16b8ak9smkgw3g/test.tar.gz.zip.bz2.tbz2?raw=1 +ls -la /tmp/genstest2 +test -f /tmp/genstest2/src/lib/EDSL.ml + +echo "================== TEST 3 ======================================================" +# like -t /tmp/test2, without -c (which is fragile w.r.t. tar) +mkdir -p /tmp/test3 +cd /tmp/test3 +sh $genspio_downloader -u https://github.com/hammerlab/ketrew/archive/ketrew.3.0.0.tar.gz +ls -la /tmp/test3 +test -f /tmp/test3/ketrew-ketrew.3.0.0/README.md + + + -$genspio_examples dl -