CI gating tests migration to tmt
This commit is contained in:
parent
5c13a4f454
commit
bc63414838
1
.fmf/version
Normal file
1
.fmf/version
Normal file
@ -0,0 +1 @@
|
||||
1
|
@ -1,7 +1,7 @@
|
||||
Name: intltool
|
||||
Summary: Utility for internationalizing various kinds of data files
|
||||
Version: 0.51.0
|
||||
Release: 27%{?dist}
|
||||
Release: 28%{?dist}
|
||||
License: GPL-2.0-or-later WITH Autoconf-exception-generic
|
||||
#VCS: bzr:https://code.edge.launchpad.net/~intltool/intltool/trunk
|
||||
Source: https://edge.launchpad.net/intltool/trunk/%{version}/+download/intltool-%{version}.tar.gz
|
||||
@ -69,6 +69,9 @@ fi
|
||||
%{_mandir}/man8/intltool*.8*
|
||||
|
||||
%changelog
|
||||
* Tue Aug 6 2024 Manish Tiwari <matiwari@redhat.com> - 0.51.0-28
|
||||
- CI gating tests migration to tmt
|
||||
|
||||
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 0.51.0-27
|
||||
- Bump release for June 2024 mass rebuild
|
||||
|
||||
|
5
plans/basic.fmf
Normal file
5
plans/basic.fmf
Normal file
@ -0,0 +1,5 @@
|
||||
summary: Basic smoke test
|
||||
discover:
|
||||
how: fmf
|
||||
execute:
|
||||
how: tmt
|
19
tests/cases/context.xml
Normal file
19
tests/cases/context.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<test>
|
||||
<entry>
|
||||
<_name>Foo</_name>
|
||||
</entry>
|
||||
<entry>
|
||||
<!-- This is the comment on the first Bar -->
|
||||
<_name msgctxt="1">
|
||||
Bar</_name>
|
||||
</entry>
|
||||
<entry>
|
||||
<!-- This is the comment on the second Bar -->
|
||||
<_name msgctxt="2">
|
||||
Bar</_name>
|
||||
</entry>
|
||||
<entry>
|
||||
<!-- This is the comment on Baz -->
|
||||
<_name>Baz</_name>
|
||||
</entry>
|
||||
</test>
|
17
tests/cases/context.xml.in
Normal file
17
tests/cases/context.xml.in
Normal file
@ -0,0 +1,17 @@
|
||||
<test>
|
||||
<entry>
|
||||
<_name>Foo</_name>
|
||||
</entry>
|
||||
<entry>
|
||||
<!-- This is the comment on the first Bar -->
|
||||
<_name msgctxt="1">Bar</_name>
|
||||
</entry>
|
||||
<entry>
|
||||
<!-- This is the comment on the second Bar -->
|
||||
<_name msgctxt="2">Bar</_name>
|
||||
</entry>
|
||||
<entry>
|
||||
<!-- This is the comment on Baz -->
|
||||
<_name>Baz</_name>
|
||||
</entry>
|
||||
</test>
|
7
tests/cases/context.xml.in.h
Normal file
7
tests/cases/context.xml.in.h
Normal file
@ -0,0 +1,7 @@
|
||||
char *s = N_("Foo");
|
||||
/* This is the comment on the first Bar */
|
||||
char *s = C_("1", "Bar");
|
||||
/* This is the comment on the second Bar */
|
||||
char *s = C_("2", "Bar");
|
||||
/* This is the comment on Baz */
|
||||
char *s = N_("Baz");
|
109
tests/intltool_tests.py
Normal file
109
tests/intltool_tests.py
Normal file
@ -0,0 +1,109 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import logging
|
||||
import subprocess
|
||||
from difflib import Differ
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
COMMANDS = [
|
||||
"intltool-extract",
|
||||
"intltool-merge"
|
||||
]
|
||||
INPUT_FILE = "cases/context.xml.in"
|
||||
|
||||
|
||||
def test_intltool_installation(cmd: str):
|
||||
"""
|
||||
Check if intltool is installed correctly
|
||||
"""
|
||||
try:
|
||||
intltool_cmd = subprocess.Popen([cmd], stdout=subprocess.PIPE)
|
||||
intltool_cmd_execution_response = intltool_cmd.communicate()
|
||||
assert "Usage" in str(intltool_cmd_execution_response)
|
||||
except FileNotFoundError:
|
||||
logging.error(f"Either {cmd} is not installed or not accessible.")
|
||||
except OSError:
|
||||
logging.error(f"Some OSError occurred while executing {cmd}")
|
||||
except AssertionError:
|
||||
logging.error(f"[CMD] output does not include text: Usage.")
|
||||
else:
|
||||
logging.info(f"Execution of {cmd} succeed. Test Passed.")
|
||||
|
||||
|
||||
def test_intltool_extract(cmd, input_file):
|
||||
"""
|
||||
Check intltool extract behavior
|
||||
"""
|
||||
try:
|
||||
intltool_extract = subprocess.Popen(
|
||||
[cmd, "--type=gettext/xml", input_file, "--update"],
|
||||
stdout=subprocess.PIPE)
|
||||
intltool_extract_execution_response = intltool_extract.communicate()
|
||||
assert "Wrote" in str(intltool_extract_execution_response)
|
||||
except AssertionError:
|
||||
logging.error(f"Writing output file for {input_file} file failed.")
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
else:
|
||||
logging.info(f"Writing output file for {input_file} succeed.")
|
||||
|
||||
comparison_test_pass = True
|
||||
with open("{}.h".format(input_file)) as output_file, open("results/{}.h".format("context.xml.in")) as refer_file:
|
||||
differ = Differ()
|
||||
for line in differ.compare(output_file.readlines(), refer_file.readlines()):
|
||||
if line.startswith("+") or line.startswith("-"):
|
||||
comparison_test_pass = False
|
||||
|
||||
try:
|
||||
assert comparison_test_pass
|
||||
except AssertionError:
|
||||
logging.error("Extracted file does NOT match with the result. Test failed.")
|
||||
else:
|
||||
logging.info("Extracted file does match with the result. Test passed.")
|
||||
|
||||
|
||||
def test_intltool_merge(cmd, input_file):
|
||||
"""
|
||||
Check intltool merge behavior
|
||||
"""
|
||||
merged_file = "context.xml"
|
||||
try:
|
||||
intltool_merge = subprocess.Popen(
|
||||
[cmd, "-o", "cases", input_file, "cases/{}".format(merged_file)],
|
||||
stdout=subprocess.PIPE)
|
||||
intltool_merge_execution_response = intltool_merge.communicate()
|
||||
assert "Merging" in str(intltool_merge_execution_response)
|
||||
except AssertionError:
|
||||
logging.error(f"Writing output file for {input_file} file failed.")
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
else:
|
||||
logging.info(f"Writing output file for {input_file} succeed.")
|
||||
|
||||
comparison_test_pass = True
|
||||
with open("cases/{}".format(merged_file)) as output_file, open("results/{}".format(merged_file)) as refer_file:
|
||||
differ = Differ()
|
||||
for line in differ.compare(output_file.readlines(), refer_file.readlines()):
|
||||
if line.startswith("+") or line.startswith("-"):
|
||||
comparison_test_pass = False
|
||||
|
||||
try:
|
||||
assert comparison_test_pass
|
||||
except AssertionError:
|
||||
logging.error("Merged file does NOT match with the result. Test failed.")
|
||||
else:
|
||||
logging.info("Merged file does match with the result. Test passed.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
"""
|
||||
Executes test cases
|
||||
"""
|
||||
logging.info("Executing test cases for Intltool..")
|
||||
for CMD in COMMANDS:
|
||||
test_intltool_installation(CMD)
|
||||
test_intltool_extract(COMMANDS[0], INPUT_FILE)
|
||||
test_intltool_merge(COMMANDS[1], INPUT_FILE)
|
||||
logging.info("Tests execution of Intltool completed!")
|
6
tests/main.fmf
Normal file
6
tests/main.fmf
Normal file
@ -0,0 +1,6 @@
|
||||
summary: Run intltool test
|
||||
test: ./test.sh
|
||||
framework: beakerlib
|
||||
require:
|
||||
- intltool
|
||||
- python3
|
19
tests/results/context.xml
Normal file
19
tests/results/context.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<test>
|
||||
<entry>
|
||||
<_name>Foo</_name>
|
||||
</entry>
|
||||
<entry>
|
||||
<!-- This is the comment on the first Bar -->
|
||||
<_name msgctxt="1">
|
||||
Bar</_name>
|
||||
</entry>
|
||||
<entry>
|
||||
<!-- This is the comment on the second Bar -->
|
||||
<_name msgctxt="2">
|
||||
Bar</_name>
|
||||
</entry>
|
||||
<entry>
|
||||
<!-- This is the comment on Baz -->
|
||||
<_name>Baz</_name>
|
||||
</entry>
|
||||
</test>
|
7
tests/results/context.xml.in.h
Normal file
7
tests/results/context.xml.in.h
Normal file
@ -0,0 +1,7 @@
|
||||
char *s = N_("Foo");
|
||||
/* This is the comment on the first Bar */
|
||||
char *s = C_("1", "Bar");
|
||||
/* This is the comment on the second Bar */
|
||||
char *s = C_("2", "Bar");
|
||||
/* This is the comment on Baz */
|
||||
char *s = N_("Baz");
|
25
tests/test.sh
Executable file
25
tests/test.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
|
||||
PACKAGE="intltool"
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
rlAssertRpm $PACKAGE
|
||||
rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
|
||||
rlRun "cp -r cases results intltool_tests.py $TmpDir"
|
||||
rlRun "pushd $TmpDir"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
rlLog "Run intltool_tests.py"
|
||||
rlRun "python3 intltool_tests.py"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "popd"
|
||||
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
||||
rlPhaseEnd
|
||||
rlJournalPrintText
|
||||
rlJournalEnd
|
Loading…
Reference in New Issue
Block a user