Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: add lifecycle ordering tests #2163

Merged
merged 2 commits into from
Jun 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions snapcraft/internal/lifecycle/_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ def _clean_part(part_name, step, config, staged_state, primed_state):

def mark_dependents_dirty(part_name, cleaned_step, config):
dependent_part_names = config.parts.get_reverse_dependencies(part_name)
dependent_parts = {p for p in config.all_parts
if p.name in dependent_part_names}

# Keep ordering
dependent_parts = [p for p in config.all_parts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this rings a bell, I bet if we run blame we will see it was once a list 😛

if p.name in dependent_part_names]

dirty_part_names = set()
for part in dependent_parts:
Expand Down
52 changes: 52 additions & 0 deletions tests/unit/lifecycle/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
#
# Copyright (C) 2015-2018 Canonical Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import fixtures
import logging
import textwrap

import snapcraft
from snapcraft.internal import project_loader
from tests import unit


class LifecycleTestBase(unit.TestCase):

def setUp(self):
super().setUp()

self.fake_logger = fixtures.FakeLogger(level=logging.INFO)
self.useFixture(self.fake_logger)
self.project_options = snapcraft.ProjectOptions()

def make_snapcraft_project(self, parts, snap_type=''):
yaml = textwrap.dedent("""\
name: test
version: 0
summary: test
description: test
confinement: strict
grade: stable
{type}

{parts}
""")

self.snapcraft_yaml_file_path = self.make_snapcraft_yaml(
yaml.format(parts=parts, type=snap_type))
project = snapcraft.project.Project(
snapcraft_yaml_file_path=self.snapcraft_yaml_file_path)
return project_loader.load_config(project)