diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/plans/basic.fmf b/plans/basic.fmf new file mode 100644 index 0000000..c1627f9 --- /dev/null +++ b/plans/basic.fmf @@ -0,0 +1,5 @@ +summary: Basic smoke test +discover: + how: fmf +execute: + how: tmt diff --git a/tests/foma-input.txt b/tests/foma-input.txt new file mode 100644 index 0000000..bdb3098 --- /dev/null +++ b/tests/foma-input.txt @@ -0,0 +1,3 @@ +def Animals c a t | d o g ; +regex Animals+ ; +print defined diff --git a/tests/main.fmf b/tests/main.fmf new file mode 100644 index 0000000..9496f9c --- /dev/null +++ b/tests/main.fmf @@ -0,0 +1,7 @@ +framework: beakerlib +duration: 10m +require: +- foma +- python3 +test: ./runtest.sh + diff --git a/tests/runtest.sh b/tests/runtest.sh new file mode 100755 index 0000000..72376bb --- /dev/null +++ b/tests/runtest.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm python3 + rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" + rlRun "cp test_foma.py foma-input.txt $tmp" + rlRun "pushd $tmp" + rlPhaseEnd + + rlPhaseStartTest + rlRun "python3 test_foma.py -v" \ + 0 "Running test cases" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $tmp" 0 "Remove tmp directory" + rlPhaseEnd +rlJournalEnd diff --git a/tests/test_foma.py b/tests/test_foma.py new file mode 100644 index 0000000..53d3768 --- /dev/null +++ b/tests/test_foma.py @@ -0,0 +1,25 @@ +import unittest +import sys +import subprocess + +class TestFoma(unittest.TestCase): + + def test_dummy(self): + self.assertEqual(True, True) + + @unittest.expectedFailure + def test_expected_failure(self): + self.assertEqual(False, True) + + def test_foma(self): + cp = subprocess.run(['foma -f foma-input.txt'], encoding='UTF-8', text=True, shell=True, capture_output=True) + self.assertEqual( + 'defined Animals: 455 bytes. 6 states, 6 arcs, 2 paths.\n' + '471 bytes. 6 states, 8 arcs, Cyclic.\n' + 'Animals\t455 bytes. 6 states, 6 arcs, 2 paths.\n', + cp.stdout) + self.assertEqual('', cp.stderr) + self.assertEqual(0, cp.returncode) + +if __name__ == "__main__": + unittest.main()