Skip to content

Commit

Permalink
tests: add spread suite for cmake plugin
Browse files Browse the repository at this point in the history
Move the plugin and snapd integration tests for the CMake plugin into a
Spread suite.

LP: #1783830

Signed-off-by: Kyle Fazzari <kyrofa@ubuntu.com>
  • Loading branch information
kyrofa committed Jul 27, 2018
1 parent ad7260c commit 86c9b01
Show file tree
Hide file tree
Showing 17 changed files with 84 additions and 119 deletions.
2 changes: 2 additions & 0 deletions spread.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ prepare: |
restore: $SETUP_DIR/restore.sh

suites:
tests/spread/plugins/cmake/:
summary: tests of snapcraft's cmake plugin
tests/spread/plugins/go/:
summary: tests of snapcraft's plugins

Expand Down
81 changes: 0 additions & 81 deletions tests/integration/plugins/test_cmake_plugin.py

This file was deleted.

32 changes: 0 additions & 32 deletions tests/integration/snapd/test_cmake_snap.py

This file was deleted.

Binary file removed tests/integration/snaps/cmake-hello/icon.png
Binary file not shown.
4 changes: 0 additions & 4 deletions tests/integration/snaps/cmake-hello/test.c

This file was deleted.

40 changes: 40 additions & 0 deletions tests/spread/plugins/cmake/rebuild/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
summary: Build and run a basic cmake snap

environment:
SNAP_DIR: ../snaps/cmake-with-lib

prepare: |
. "$SETUP_DIR/config.sh"
set_outdated_step_action "clean"
restore: |
. "$SETUP_DIR/config.sh"
clear_config
cd "$SNAP_DIR"
snapcraft clean
rm -f ./*.snap
execute: |
cd "$SNAP_DIR"
output="$(snapcraft prime)"
# Assert that cmake actually configured and built from scratch
echo "$output" | MATCH "The CXX compiler identification"
echo "$output" | MATCH "Building CXX object CMakeFiles/foo.dir/foo.cpp.o"
echo "$output" | MATCH "Building CXX object CMakeFiles/usefoo.dir/main.cpp.o"
[ "$(./prime/bin/usefoo)" = "foo" ]
# Modify the source code
cp new_foo.cpp src/foo.cpp
# Prime again. This should rebuild
output="$(snapcraft prime)"
# Assert that cmake did not start from scratch, and reused everything it could
echo "$output" | MATCH -v "The CXX compiler identification"
echo "$output" | MATCH -v "Building CXX object CMakeFiles/usefoo.dir/main.cpp.o"
echo "$output" | MATCH "Building CXX object CMakeFiles/foo.dir/foo.cpp.o"
[ "$(./prime/bin/usefoo)" = "new foo" ]
15 changes: 15 additions & 0 deletions tests/spread/plugins/cmake/run/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
summary: Build and run a basic cmake snap

environment:
SNAP_DIR: ../snaps/cmake-hello

restore: |
cd "$SNAP_DIR"
snapcraft clean
rm -f ./*.snap
execute: |
cd "$SNAP_DIR"
snapcraft
sudo snap install cmake-hello_*.snap --dangerous
[ "$(cmake-hello)" = "hello world" ]
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: cmake-hello
version: 0.1
version: 1.0
summary: test the cmake plugin
description: |
This is a basic cmake snap. It just prints a hello world.
If you want to add other functionalities to this snap, please don't.
Make a new one.
icon: icon.png
grade: devel
confinement: strict

build-packages: [gcc, libc6-dev]
Expand Down
7 changes: 7 additions & 0 deletions tests/spread/plugins/cmake/snaps/cmake-hello/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <stdio.h>

int main()
{
printf("hello world\n");
return 0;
}
17 changes: 17 additions & 0 deletions tests/spread/setup/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh -e

export CONFIG_FILE_PATH="$HOME/.config/snapcraft/cli.cfg"
mkdir -p "$(dirname "$CONFIG_FILE_PATH")"

set_outdated_step_action()
{
cat <<- EOF > "$CONFIG_FILE_PATH"
[Lifecycle]
outdated_step_action = $1
EOF
}

clear_config()
{
rm -f "$CONFIG_FILE_PATH"
}

0 comments on commit 86c9b01

Please sign in to comment.