Skip to content

Commit

Permalink
Fix test script that depend on printenv
Browse files Browse the repository at this point in the history
Signed-off-by: Greta Yorsh <[email protected]>
  • Loading branch information
gretay-js committed Feb 15, 2019
1 parent 9df8f00 commit a98b830
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
7 changes: 7 additions & 0 deletions test/blackbox-tests/test-cases/env-cflags/printenv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Manipulate output of "dune printenv" to make it independent of the local configuration.

export STANDARD_C_FLAGS=`ocamlc -config | grep ocamlc_cflags | sed 's/ocamlc_cflags: //'`
export STANDARD_CXX_FLAGS=`ocamlc -config | grep ocamlc_cflags | sed 's/ocamlc_cflags: //' | sed 's/-std=[^ ]* //' | sed 's/-std=[^$]*//'`
dune printenv $@ | tr '\n' ' ' | sed 's/ \+/ /g' | sed "s/$STANDARD_C_FLAGS/STANDARD_C_FLAGS/" | sed "s/$STANDARD_CXX_FLAGS/STANDARD_CXX_FLAGS/"
14 changes: 6 additions & 8 deletions test/blackbox-tests/test-cases/env-cflags/run.t
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
$ export STANDARD_C_FLAGS=`ocamlc -config | grep ocamlc_cflags | sed 's/ocamlc_cflags: //'`
$ export STANDARD_CXX_FLAGS=`ocamlc -config | grep ocamlc_cflags | sed 's/ocamlc_cflags: //' | sed 's/-std=[^ ]* //' | sed 's/-std=[^$]*//'`
$ dune printenv --profile default . | tr '\n' ' ' | sed 's/ \+/ /g' | sed "s/$STANDARD_C_FLAGS/STANDARD_C_FLAGS/" | sed "s/$STANDARD_CXX_FLAGS/STANDARD_CXX_FLAGS/"
$ ./printenv.sh --profile default .
( (flags (-w -40)) (ocamlc_flags (-g)) (ocamlopt_flags (-g)) (c_flags (STANDARD_C_FLAGS ":standard + in .")) (cxx_flags (STANDARD_CXX_FLAGS ":standard + in .")) )

$ dune printenv --profile default src | tr '\n' ' ' | sed 's/ \+/ /g' | sed "s/$STANDARD_C_FLAGS/STANDARD_C_FLAGS/" | sed "s/$STANDARD_CXX_FLAGS/STANDARD_CXX_FLAGS/"
$ ./printenv.sh --profile default src
( (flags (-w -40)) (ocamlc_flags (-g)) (ocamlopt_flags (-g)) (c_flags (STANDARD_C_FLAGS ":standard + in ." ":standard + in src")) (cxx_flags (STANDARD_CXX_FLAGS ":standard + in ." ":standard + in src")) )

$ dune printenv --profile default bin | tr '\n' ' ' | sed 's/ \+/ /g' | sed "s/$STANDARD_C_FLAGS/STANDARD_C_FLAGS/" | sed "s/$STANDARD_CXX_FLAGS/STANDARD_CXX_FLAGS/"
$ ./printenv.sh --profile default bin | tr '\n' ' ' | sed 's/ \+/ /g' | sed "s/$STANDARD_C_FLAGS/STANDARD_C_FLAGS/" | sed "s/$STANDARD_CXX_FLAGS/STANDARD_CXX_FLAGS/"
( (flags (-w -40)) (ocamlc_flags (-g)) (ocamlopt_flags (-g)) (c_flags ("in bin")) (cxx_flags ("in bin")) )
$ dune printenv --profile default run | tr '\n' ' ' | sed 's/ \+/ /g' | sed "s/$STANDARD_C_FLAGS/STANDARD_C_FLAGS/" | sed "s/$STANDARD_CXX_FLAGS/STANDARD_CXX_FLAGS/"
$ ./printenv.sh --profile default run | tr '\n' ' ' | sed 's/ \+/ /g' | sed "s/$STANDARD_C_FLAGS/STANDARD_C_FLAGS/" | sed "s/$STANDARD_CXX_FLAGS/STANDARD_CXX_FLAGS/"
( (flags (-w -40)) (ocamlc_flags (-g)) (ocamlopt_flags (-g)) (c_flags (-DTEST_C)) (cxx_flags (-DTEST_CPP)) )
$ dune exec --profile default ./run/foo.exe
DTEST_C defined.
[1]

$ dune exec --profile default ./run/bar.exe
DTEST_CPP defined.
[1]

7 changes: 7 additions & 0 deletions test/blackbox-tests/test-cases/env/printenv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Manipulate output of "dune printenv" to make it independent of the local configuration.

export STANDARD_C_FLAGS=`ocamlc -config | grep ocamlc_cflags | sed 's/ocamlc_cflags: //'`
export STANDARD_CXX_FLAGS=`ocamlc -config | grep ocamlc_cflags | sed 's/ocamlc_cflags: //' | sed 's/-std=[^ ]* //' | sed 's/-std=[^$]*//'`
dune printenv $@ | tr '\n' ' ' | sed 's/ \+/ /g' | sed "s/$STANDARD_C_FLAGS/STANDARD_C_FLAGS/" | sed "s/$STANDARD_CXX_FLAGS/STANDARD_CXX_FLAGS/"
4 changes: 1 addition & 3 deletions test/blackbox-tests/test-cases/env/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
Vendored project without env customization, the global default should
apply:

$ export STANDARD_C_FLAGS=`ocamlc -config | grep ocamlc_cflags | sed 's/ocamlc_cflags: //'`
$ export STANDARD_CXX_FLAGS=`ocamlc -config | grep ocamlc_cflags | sed 's/ocamlc_cflags: //' | sed 's/-std=[^ ]* //' | sed 's/-std=[^$]*//'`
$ dune printenv --profile default vendor/without-env-customization | tr '\n' ' ' | sed 's/ \+/ /g' | sed "s/$STANDARD_C_FLAGS/STANDARD_C_FLAGS/" | sed "s/$STANDARD_CXX_FLAGS/STANDARD_CXX_FLAGS/"
$ ./printenv.sh --profile default vendor/without-env-customization
( (flags (-w -40)) (ocamlc_flags (-g)) (ocamlopt_flags (-g)) (c_flags (STANDARD_C_FLAGS)) (cxx_flags (STANDARD_CXX_FLAGS)) )

Vendored project with env customization, the global default +
Expand Down

0 comments on commit a98b830

Please sign in to comment.