From e515f722284df0fa7e7f6136d6088d06301e5ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Tue, 1 Mar 2022 18:42:10 +0100 Subject: [PATCH] Add test stage to CI. --- .gitlab-ci.yml | 6 ++++++ test.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100755 test.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9493dec..ec327fa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,6 +2,7 @@ image: "rust:latest" stages: - build + - test build-job: stage: build @@ -10,3 +11,8 @@ build-job: - target/release/indivisible script: - cargo build --release + +test-job: + stage: test + script: + - ./test.sh diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..7761095 --- /dev/null +++ b/test.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +echo -n "Prime finding..." +if [[ $(./target/release/indivisible 5) == 11 ]] +then + echo " pass" +else + echo " FAIL" + exit 1 +fi + +echo -n "Positive prime test..." +if ./target/release/indivisible -t 11 +then + echo " pass" +else + echo " FAIL" + exit 1 +fi + +echo -n "Negative prime test..." +if ! ./target/release/indivisible -t 9 +then + echo " pass" +else + echo " FAIL" + exit 1 +fi