Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/marian-regression-tests.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoman Grundkiewicz <rgrundki@exseed.ed.ac.uk>2020-07-26 19:34:47 +0300
committerGitHub <noreply@github.com>2020-07-26 19:34:47 +0300
commit22ea945dd7e2aec7490199dc10f5eac7b08cd996 (patch)
tree7fcff17c61843576116d6b4219c84c44d5e3ae37 /tests
parentb5bc11015761626a5d24a21e00034871542fe1e1 (diff)
parent7117166c6d4fe67b5e98219f4cd90f2f5144a241 (diff)
Merge pull request #54 from marian-nmt/fix-vector-options-with-equals-sign
Add tests for providing vector-like options using the equals sign
Diffstat (limited to 'tests')
-rw-r--r--tests/interface/cli/.gitignore1
-rw-r--r--tests/interface/cli/setup.sh2
-rw-r--r--tests/interface/cli/test_cli_options_with_equals.sh34
-rw-r--r--tests/interface/cli/test_cli_options_with_spaces.sh34
-rw-r--r--tests/interface/cli/test_cli_paths_with_equals.sh24
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