diff --git a/gating.yaml b/gating.yaml
index 4124226..648918d 100644
--- a/gating.yaml
+++ b/gating.yaml
@@ -3,4 +3,4 @@ product_versions:
- rhel-9
decision_context: osci_compose_gate
rules:
- - !PassingTestCaseRule {test_case_name: desktop-qe.desktop-ci.tier1-gating.functional}
+ - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}
diff --git a/tests/cases/context.xml.in b/tests/cases/context.xml.in
new file mode 100644
index 0000000..4b58d97
--- /dev/null
+++ b/tests/cases/context.xml.in
@@ -0,0 +1,17 @@
+
+
+ <_name>Foo
+
+
+
+ <_name msgctxt="1">Bar
+
+
+
+ <_name msgctxt="2">Bar
+
+
+
+ <_name>Baz
+
+
diff --git a/tests/intltool_tests.py b/tests/intltool_tests.py
new file mode 100644
index 0000000..4a0ffa2
--- /dev/null
+++ b/tests/intltool_tests.py
@@ -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!")
diff --git a/tests/results/context.xml b/tests/results/context.xml
new file mode 100644
index 0000000..e21ad0e
--- /dev/null
+++ b/tests/results/context.xml
@@ -0,0 +1,19 @@
+
+
+ <_name>Foo
+
+
+
+ <_name msgctxt="1">
+Bar
+
+
+
+ <_name msgctxt="2">
+Bar
+
+
+
+ <_name>Baz
+
+
diff --git a/tests/results/context.xml.in.h b/tests/results/context.xml.in.h
new file mode 100644
index 0000000..161a65b
--- /dev/null
+++ b/tests/results/context.xml.in.h
@@ -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");
diff --git a/tests/tests.yml b/tests/tests.yml
new file mode 100644
index 0000000..180963e
--- /dev/null
+++ b/tests/tests.yml
@@ -0,0 +1,11 @@
+ - hosts: localhost
+ tags:
+ - classic
+ roles:
+ - role: standard-test-basic
+ required_packages:
+ - intltool
+ tests:
+ - make-check:
+ dir: .
+ run: python3 intltool_tests.py