Skip to content

Commit

Permalink
Travis fixing, no_newline_sed for OSX+++ #WIP
Browse files Browse the repository at this point in the history
Add downloader example test to the Travis script

This fixes issue #29.

The example had a bashism while using `sed`; cf. also #30.

And `"s:.*/\\([^\\?\\/]*\\)\\?.*:\\1:"` was wrong
  • Loading branch information
smondet committed Dec 20, 2016
1 parent 5424c72 commit 06a1a73
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 7 deletions.
20 changes: 15 additions & 5 deletions src/test/examples.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 =
Expand Down Expand Up @@ -154,9 +164,9 @@ let downloader () =
if_seq (filename_ov =$= no_value)
~t:begin
let filename =
url >> exec ["sed"; "s:.*/\\([^\\?\\/]*\\)\\?.*:\\1:"]
|> output_as_string
in
(* let e = "s:.*/\\([^\\?\\/]*\\\)\\(\\?.*\\\)?:\\1:" in *)
let e = "s/.*\\/\\([^\\?\\/]*\\)?\\?.*/\\1/" in
no_newline_sed ~input:url e in
let output_path =
string_concat [tmp_dir; string "/"; filename] in
[current_name#set output_path]
Expand Down
35 changes: 33 additions & 2 deletions tools/travis_ci_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 -

0 comments on commit 06a1a73

Please sign in to comment.