diff --git a/tests/Sanity/cargo-smoke/main.fmf b/tests/Sanity/cargo-smoke/main.fmf new file mode 100644 index 0000000..35d1a7b --- /dev/null +++ b/tests/Sanity/cargo-smoke/main.fmf @@ -0,0 +1,5 @@ +summary: Test basic cargo operations +duration: 2m +tier: 1 +extra-nitrate: TC#0617226 +id: 0747b0c9-272d-46bb-a5a4-0800f1e24f7a diff --git a/tests/Sanity/cargo-smoke/runtest.sh b/tests/Sanity/cargo-smoke/runtest.sh new file mode 100755 index 0000000..382117d --- /dev/null +++ b/tests/Sanity/cargo-smoke/runtest.sh @@ -0,0 +1,74 @@ +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +# Define package name(s) for rlAssertRpm to report installed versions +PACKAGE=$(rpm -qf $(which cargo)) +PACKAGES=${PACKAGES:-$PACKAGE} +BASENAME="smoke" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm --all + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlRun "mkdir .cargo" + rlRun "export CARGO_HOME=$TmpDir/.cargo" + rlPhaseEnd + +for cratetype in binary library; do + rlPhaseStartTest "Test $cratetype crate" + rlRun "CRATENAME=${BASENAME}${cratetype}" + + if [ $cratetype == "library" ]; then + rlRun "cargo new --lib $CRATENAME" + else + rlRun "cargo new $CRATENAME" + fi + rlAssertExists "./$CRATENAME" + rlRun "pushd $CRATENAME" + rlAssertExists "Cargo.toml" + rlAssertExists "src" + rlAssertGrep "$CRATENAME" Cargo.toml + + # Test building both release and debug crates + for buildtype in debug release; do + CMD='cargo build' + if [ $buildtype == 'release' ]; then + CMD+=' --release' + fi + rlRun "$CMD" + if [ $cratetype == "library" ]; then + rlAssertExists "target/$buildtype/lib$CRATENAME.rlib" + else + rlAssertExists "target/$buildtype/$CRATENAME" + rlRun "target/$buildtype/$CRATENAME" + fi + done + + # Subcommands applicable to binary and library crates + rlRun "cargo check" + rlRun "cargo test" + rlRun "cargo bench" + rlRun "cargo doc" + + # run and install/uninstall subcommands don't apply to library crates + if [ $cratetype == "binary" ]; then + rlRun "cargo run" + rlRun "cargo install --path ." + rlRun "${CARGO_HOME}/bin/${CRATENAME}" + rlRun "cargo uninstall $CRATENAME" + fi + + # Ensure that cargo clean works and removes the target directory + rlRun "cargo clean" + rlAssertNotExists "target" + + rlRun "popd" + rlPhaseEnd +done + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalEnd