Skip to content

Commit 2d331e0

Browse files
author
Sergio Schvezov
authored
pluginhandler: allow cleaning the build step (#3126)
PluginV2 based parts were not able to clean due to the improper guard set at the start of the clean_build method. Signed-off-by: Sergio Schvezov <sergio.schvezov@canonical.com>
1 parent 68c6425 commit 2d331e0

19 files changed

Lines changed: 26 additions & 22 deletions

File tree

snapcraft/internal/pluginhandler/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -777,10 +777,6 @@ def _get_machine_manifest(self):
777777
}
778778

779779
def clean_build(self):
780-
# Only relevant for PluginV1.
781-
if not isinstance(self.plugin, plugins.v1.PluginV1):
782-
return
783-
784780
if self.is_clean(steps.BUILD):
785781
return
786782

tests/spread/plugins/v1/rust/rebuild/task.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ execute: |
4343
snapcraft build
4444
4545
# Verify the changed source is reflected
46-
if ! diff src/main.rs parts/rust-hello/src/src/main.rs; then
46+
if ! diff src/main.rs parts/hello/src/src/main.rs; then
4747
echo "The source has not changed."
4848
exit 1
4949
fi

tests/spread/plugins/v1/rust/rust-toolchain/task.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ execute: |
3535
3636
# Verify that nightly was used instead of the default stable
3737
# e.g.; MATCH 'rustc-version: rustc 1.39.0-beta.1 (968967007 2019-09-24)'
38-
MATCH 'rustc-version: rustc .*-beta.*' < parts/rust-hello/state/build
38+
MATCH 'rustc-version: rustc .*-beta.*' < parts/hello/state/build

tests/spread/plugins/v2/build-and-run-hello/task.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
summary: Build, rebuild and run hello.c with different plugin configurations
1+
summary: >-
2+
Build, clean, build, modify and rebuild, and run hello
3+
with different plugin configurations
24
35
environment:
46
SNAP/autotools: autotools-hello
@@ -47,6 +49,12 @@ execute: |
4749
snap install "${SNAP}"_1.0_*.snap --dangerous
4850
[ "$($SNAP)" = "hello world" ]
4951
52+
# Clean the hello part, then build and run again.
53+
snapcraft clean hello
54+
snapcraft
55+
snap install "${SNAP}"_1.0_*.snap --dangerous
56+
[ "$($SNAP)" = "hello world" ]
57+
5058
# Make sure that what we built runs with the changes applied.
5159
if [ -f hello ]; then
5260
modified_file=hello

tests/spread/plugins/v2/snaps/autotools-hello/snap/snapcraft.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ apps:
1515
command: usr/bin/hello
1616

1717
parts:
18-
autotools-project:
18+
hello:
1919
plugin: autotools
2020
source: .
2121
autotools-configure-parameters:

tests/spread/plugins/v2/snaps/cmake-hello/snap/snapcraft.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ apps:
1515
command: usr/bin/cmake-hello
1616

1717
parts:
18-
cmake-project:
18+
hello:
1919
plugin: cmake
2020
cmake-parameters:
2121
- -DCMAKE_INSTALL_PREFIX=/usr

tests/spread/plugins/v2/snaps/dump-hello/snap/snapcraft.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ apps:
1212
command: hello
1313

1414
parts:
15-
nil-part:
15+
hello:
1616
plugin: dump
1717
source: .

tests/spread/plugins/v2/snaps/go-build-tags/snap/snapcraft.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ apps:
1414
command: bin/go-build-tags
1515

1616
parts:
17-
go-build-tags:
17+
hello:
1818
source: .
1919
plugin: go
2020
go-buildtags:

tests/spread/plugins/v2/snaps/go-mod-hello/snap/snapcraft.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ apps:
1414
command: bin/go-mod-hello
1515

1616
parts:
17-
go-hello:
17+
hello:
1818
source: .
1919
plugin: go

tests/spread/plugins/v2/snaps/make-hello/snap/snapcraft.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ apps:
1515
command: bin/hello
1616

1717
parts:
18-
make-project:
18+
hello:
1919
plugin: make
2020
make-parameters:
2121
- HELLO=1

0 commit comments

Comments
 (0)