From eec44c9aa9dd15534302dcb012fdee2149827da5 Mon Sep 17 00:00:00 2001 From: Mikolaj Izdebski Date: Wed, 8 Mar 2023 08:18:59 +0100 Subject: [PATCH] Onboard package into gating --- .fmf/version | 1 + gating.yaml | 8 +++++++ plans/plan.fmf | 5 ++++ tests/macros/main.fmf | 5 ++++ tests/macros/runtest.sh | 41 +++++++++++++++++++++++++++++++++ tests/macros/test_template.java | 4 ++++ tests/main.fmf | 4 ++++ tests/smoke/main.fmf | 11 +++++++++ tests/smoke/runtest.sh | 29 +++++++++++++++++++++++ 9 files changed, 108 insertions(+) create mode 100644 .fmf/version create mode 100644 gating.yaml create mode 100644 plans/plan.fmf create mode 100644 tests/macros/main.fmf create mode 100755 tests/macros/runtest.sh create mode 100644 tests/macros/test_template.java create mode 100644 tests/main.fmf create mode 100644 tests/smoke/main.fmf create mode 100755 tests/smoke/runtest.sh 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/gating.yaml b/gating.yaml new file mode 100644 index 0000000..05d1cc5 --- /dev/null +++ b/gating.yaml @@ -0,0 +1,8 @@ +--- !Policy +product_versions: + - fedora-* +decision_contexts: + - bodhi_update_push_testing + - bodhi_update_push_stable +rules: + - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional} diff --git a/plans/plan.fmf b/plans/plan.fmf new file mode 100644 index 0000000..1ccac40 --- /dev/null +++ b/plans/plan.fmf @@ -0,0 +1,5 @@ +summary: Run tests from dist-git +discover: + how: fmf +execute: + how: tmt diff --git a/tests/macros/main.fmf b/tests/macros/main.fmf new file mode 100644 index 0000000..5082f3c --- /dev/null +++ b/tests/macros/main.fmf @@ -0,0 +1,5 @@ +summary: Jurand macros test +description: | + Test whether Jurand RPM macros work. +require: + - rpm-build diff --git a/tests/macros/runtest.sh b/tests/macros/runtest.sh new file mode 100755 index 0000000..d99da7f --- /dev/null +++ b/tests/macros/runtest.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Author: Mikolaj Izdebski +. /usr/share/beakerlib/beakerlib.sh + +rlJournalStart + + rlPhaseStartSetup + rlAssertRpm jurand + rlAssertRpm rpm-build + rlPhaseEnd + + rlPhaseStartTest + rlAssertGrep "^import com.Foo;$" test_template.java + rlAssertGrep "^import biz.Bar;$" test_template.java + rlAssertGrep "^@Foo$" test_template.java + rlAssertGrep "^class test{}$" test_template.java + + rlRun "cp test_template.java test.java" + rlRun -s "rpm -E '%java_remove_imports test.java -n Foo'" + rlAssertGrep /usr/bin/jurand $rlRun_LOG + rlRun "sh $rlRun_LOG" + rlAssertNotGrep "^import com.Foo;$" test.java + rlAssertGrep "^import biz.Bar;$" test.java + rlAssertGrep "^@Foo$" test.java + rlAssertGrep "^class test{}$" test.java + + rlRun "cp test_template.java test.java" + rlRun -s "rpm -E '%java_remove_annotations test.java -n Foo'" + rlAssertGrep /usr/bin/jurand $rlRun_LOG + rlRun "sh $rlRun_LOG" + rlAssertNotGrep "^import com.Foo;$" test.java + rlAssertGrep "^import biz.Bar;$" test.java + rlAssertNotGrep "^@Foo$" test.java + rlAssertGrep "^class test{}$" test.java + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "rm -f test.java" + rlPhaseEnd +rlJournalEnd +rlJournalPrintText diff --git a/tests/macros/test_template.java b/tests/macros/test_template.java new file mode 100644 index 0000000..87bdcaa --- /dev/null +++ b/tests/macros/test_template.java @@ -0,0 +1,4 @@ +import com.Foo; +import biz.Bar; +@Foo +class test{} diff --git a/tests/main.fmf b/tests/main.fmf new file mode 100644 index 0000000..99fd67e --- /dev/null +++ b/tests/main.fmf @@ -0,0 +1,4 @@ +contact: Mikolaj Izdebski +framework: beakerlib +test: ./runtest.sh +tier: 0 diff --git a/tests/smoke/main.fmf b/tests/smoke/main.fmf new file mode 100644 index 0000000..1964a90 --- /dev/null +++ b/tests/smoke/main.fmf @@ -0,0 +1,11 @@ +summary: Jurand smoke test +description: | + Download Guava sources, run Jurand to remove annotations and then + compile Guava to verify that annotations were removed, producing + valid Java code that can be compiled. +require: + - wget + - tar + - gzip + - findutils + - java-1.8.0-openjdk-devel diff --git a/tests/smoke/runtest.sh b/tests/smoke/runtest.sh new file mode 100755 index 0000000..90a68f7 --- /dev/null +++ b/tests/smoke/runtest.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# Author: Mikolaj Izdebski +. /usr/share/beakerlib/beakerlib.sh + +rlJournalStart + + rlPhaseStartSetup + rlAssertRpm jurand + rlAssertRpm java-1.8.0-openjdk-devel + export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk + rlRun "wget https://src.fedoraproject.org/lookaside/pkgs/guava/guava-31.1.tar.gz/sha512/660b486d82d526ce722130f2968ea8ab9eb53f5915f80e53ef135a7bfcb6ced9b2f2a50ebdb8b316cc48a4f2553fa067a1d6fc0bc4498774a9f1990a535651b8/guava-31.1.tar.gz" + rlAssertExists guava-31.1.tar.gz + rlRun "tar xf guava-31.1.tar.gz" + rlAssertExists guava-31.1 + rlPhaseEnd + + rlPhaseStartTest + rlRun "jurand -i -a guava-31.1/guava/src -p org[.]checkerframework[.] com[.]google[.]common[.]annotations[.] com[.]google[.]errorprone[.]annotation[.] com[.]google[.]errorprone[.]annotations[.] com[.]google[.]j2objc[.]annotations[.] javax[.]annotation[.]" + rlRun -s "find guava-31.1/guava/src guava-31.1/futures/failureaccess/src -name \*.java | sort" + rlRun -s "${JAVA_HOME}/bin/javac -d . @$rlRun_LOG" + rlAssertNotGrep error: $rlRun_LOG + rlAssertExists com/google/common/base/Strings.class + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "rm -rf guava-31.1.tar.gz guava-31.1/ com/" + rlPhaseEnd +rlJournalEnd +rlJournalPrintText