diff options
author | Roman Grundkiewicz <rgrundki@exseed.ed.ac.uk> | 2020-04-30 23:02:37 +0300 |
---|---|---|
committer | Roman Grundkiewicz <rgrundki@exseed.ed.ac.uk> | 2020-04-30 23:02:37 +0300 |
commit | 7117166c6d4fe67b5e98219f4cd90f2f5144a241 (patch) | |
tree | fe98f724aef699e6aa6ed0df7683a7be35335fb2 /tests | |
parent | d1db7ea10071252fa669c034c9c99acf159c8920 (diff) |
Add tests for providing options using the equals sign
Diffstat (limited to 'tests')
-rw-r--r-- | tests/interface/cli/.gitignore | 1 | ||||
-rw-r--r-- | tests/interface/cli/setup.sh | 2 | ||||
-rw-r--r-- | tests/interface/cli/test_cli_options_with_equals.sh | 34 | ||||
-rw-r--r-- | tests/interface/cli/test_cli_options_with_spaces.sh | 34 | ||||
-rw-r--r-- | tests/interface/cli/test_cli_paths_with_equals.sh | 24 |
5 files changed, 95 insertions, 0 deletions
diff --git a/tests/interface/cli/.gitignore b/tests/interface/cli/.gitignore new file mode 100644 index 0000000..db74516 --- /dev/null +++ b/tests/interface/cli/.gitignore @@ -0,0 +1 @@ +config*.yml diff --git a/tests/interface/cli/setup.sh b/tests/interface/cli/setup.sh new file mode 100644 index 0000000..8b8cd07 --- /dev/null +++ b/tests/interface/cli/setup.sh @@ -0,0 +1,2 @@ +test -f $MRT_DATA/europarl.de-en/corpus.bpe.en || exit 1 +test -f $MRT_DATA/europarl.de-en/corpus.bpe.de || exit 1 diff --git a/tests/interface/cli/test_cli_options_with_equals.sh b/tests/interface/cli/test_cli_options_with_equals.sh new file mode 100644 index 0000000..d9fafc6 --- /dev/null +++ b/tests/interface/cli/test_cli_options_with_equals.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Exit on error +set -e + +rm -rf config_equals.yml + +# Test all types of options +$MRT_MARIAN/marian \ + --quiet-translation=true \ + --mini-batch=16 \ + --dropout-rnn=0.3 \ + --type=s2s \ + --data-weighting=data.txt \ + --dim-vocabs=8000 8000 \ + --sentencepiece-alphas=0.01 0.01 \ + --precision=float32 float16 float16 \ + --vocabs=vocab.yml vocab.yml \ + --dump-config minimal > config_equals.yml + +test -e config_equals.yml + +grep -q "quiet-translation: true" config_equals.yml +grep -q "mini-batch: 16" config_equals.yml +grep -q "dropout-rnn: 0.3" config_equals.yml +grep -q "type: s2s" config_equals.yml +grep -q "data-weighting: data.txt" config_equals.yml +grep -q "dim-vocabs: - 8000 - 8000" <(grep -A2 "dim-vocabs:" config_equals.yml | tr '\n' ' ') +grep -q "sentencepiece-alphas: - 0.01 - 0.01" <(grep -A2 "sentencepiece-alphas:" config_equals.yml | tr '\n' ' ') +grep -q "precision: - float32 - float16 - float16" <(grep -A3 "precision:" config_equals.yml | tr '\n' ' ') +grep -q "vocabs: - vocab.yml - vocab.yml" <(grep -A2 "vocabs:" config_equals.yml | tr '\n' ' ') + +# Exit with success code +exit 0 diff --git a/tests/interface/cli/test_cli_options_with_spaces.sh b/tests/interface/cli/test_cli_options_with_spaces.sh new file mode 100644 index 0000000..12b5c89 --- /dev/null +++ b/tests/interface/cli/test_cli_options_with_spaces.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Exit on error +set -e + +rm -rf config_spaces.yml + +# Test all types of options +$MRT_MARIAN/marian \ + --quiet-translation true \ + --mini-batch 16 \ + --dropout-rnn 0.3 \ + --type s2s \ + --data-weighting data.txt \ + --dim-vocabs 8000 8000 \ + --sentencepiece-alphas 0.01 0.01 \ + --precision float32 float16 float16 \ + --vocabs vocab.yml vocab.yml \ + --dump-config minimal > config_spaces.yml + +test -e config_spaces.yml + +grep -q "quiet-translation: true" config_spaces.yml +grep -q "mini-batch: 16" config_spaces.yml +grep -q "dropout-rnn: 0.3" config_spaces.yml +grep -q "type: s2s" config_spaces.yml +grep -q "data-weighting: data.txt" config_spaces.yml +grep -q "dim-vocabs: - 8000 - 8000" <(grep -A2 "dim-vocabs:" config_spaces.yml | tr '\n' ' ') +grep -q "sentencepiece-alphas: - 0.01 - 0.01" <(grep -A2 "sentencepiece-alphas:" config_spaces.yml | tr '\n' ' ') +grep -q "precision: - float32 - float16 - float16" <(grep -A3 "precision:" config_spaces.yml | tr '\n' ' ') +grep -q "vocabs: - vocab.yml - vocab.yml" <(grep -A2 "vocabs:" config_spaces.yml | tr '\n' ' ') + +# Exit with success code +exit 0 diff --git a/tests/interface/cli/test_cli_paths_with_equals.sh b/tests/interface/cli/test_cli_paths_with_equals.sh new file mode 100644 index 0000000..b19745f --- /dev/null +++ b/tests/interface/cli/test_cli_paths_with_equals.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Exit on error +set -e + +rm -rf config_paths.yml + +# 'input' and 'models' are vector-like options with single values only +$MRT_MARIAN/marian-decoder \ + --input=tmpdir/input.txt \ + --models=tmpdir/model.npz \ + --vocabs=tmpdir/vocab.yml tmpdir/vocab.yml \ + --dim-vocabs=[] \ + --dump-config minimal > config_paths.yml + +test -e config_paths.yml + +grep -q "input: - tmpdir/input.txt" <(grep -A1 "input:" config_paths.yml | tr '\n' ' ') +grep -q "models: - tmpdir/model.npz" <(grep -A1 "models:" config_paths.yml | tr '\n' ' ') +grep -q "vocabs: - tmpdir/vocab.yml - tmpdir/vocab.yml" <(grep -A2 "vocabs:" config_paths.yml | tr '\n' ' ') +grep -q "dim-vocabs: \[\]" <(grep -A1 "dim-vocabs:" config_paths.yml | tr '\n' ' ') + +# Exit with success code +exit 0 |