summaryrefslogtreecommitdiff
path: root/tests/sources/zip.py
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-12-29 19:39:35 -0500
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-01-01 19:44:53 +0900
commitc6df92fcbec1300334cdb1a79fdfa633fb3385fb (patch)
tree4ecce9db0109df4c0340c65119c71c19ba6e84bf /tests/sources/zip.py
parentfbdb5118f6322cf2f5e8bdb24bc7c5a8fdd374bc (diff)
downloadbuildstream-c6df92fcbec1300334cdb1a79fdfa633fb3385fb.tar.gz
tests/sources: Use new error checking tools for source tests
Also added a test case for the `patch` plugin which checks for graceful failure when the specified patch file is not a regular file (but a block device or a named pipe instead).
Diffstat (limited to 'tests/sources/zip.py')
-rw-r--r--tests/sources/zip.py38
1 files changed, 18 insertions, 20 deletions
diff --git a/tests/sources/zip.py b/tests/sources/zip.py
index 70ad491ff..b028163f9 100644
--- a/tests/sources/zip.py
+++ b/tests/sources/zip.py
@@ -2,7 +2,7 @@ import os
import pytest
import zipfile
-from buildstream._pipeline import PipelineError
+from buildstream._exceptions import ErrorDomain
from buildstream import _yaml
from tests.testutils import cli
@@ -52,9 +52,8 @@ def test_fetch_bad_url(cli, tmpdir, datafiles):
result = cli.run(project=project, args=[
'fetch', 'target.bst'
])
- assert result.exit_code != 0
- assert result.exception
- assert isinstance(result.exception, PipelineError)
+ result.assert_main_error(ErrorDomain.PIPELINE, None)
+ result.assert_task_error(ErrorDomain.SOURCE, None)
# Test that when I fetch with an invalid ref, it fails.
@@ -71,9 +70,8 @@ def test_fetch_bad_ref(cli, tmpdir, datafiles):
result = cli.run(project=project, args=[
'fetch', 'target.bst'
])
- assert result.exit_code != 0
- assert result.exception
- assert isinstance(result.exception, PipelineError)
+ result.assert_main_error(ErrorDomain.PIPELINE, None)
+ result.assert_task_error(ErrorDomain.SOURCE, None)
# Test that when tracking with a ref set, there is a warning
@@ -90,7 +88,7 @@ def test_track_warning(cli, tmpdir, datafiles):
result = cli.run(project=project, args=[
'track', 'target.bst'
])
- assert result.exit_code == 0
+ result.assert_success()
assert "Potential man-in-the-middle attack!" in result.stderr
@@ -117,13 +115,13 @@ def test_stage_default_basedir(cli, tmpdir, datafiles):
# Track, fetch, build, checkout
result = cli.run(project=project, args=['track', 'target.bst'])
- assert result.exit_code == 0
+ result.assert_success()
result = cli.run(project=project, args=['fetch', 'target.bst'])
- assert result.exit_code == 0
+ result.assert_success()
result = cli.run(project=project, args=['build', 'target.bst'])
- assert result.exit_code == 0
+ result.assert_success()
result = cli.run(project=project, args=['checkout', 'target.bst', checkoutdir])
- assert result.exit_code == 0
+ result.assert_success()
# Check that the content of the first directory is checked out (base-dir: '*')
original_dir = os.path.join(str(datafiles), "content", "a")
@@ -145,13 +143,13 @@ def test_stage_no_basedir(cli, tmpdir, datafiles):
# Track, fetch, build, checkout
result = cli.run(project=project, args=['track', 'target.bst'])
- assert result.exit_code == 0
+ result.assert_success()
result = cli.run(project=project, args=['fetch', 'target.bst'])
- assert result.exit_code == 0
+ result.assert_success()
result = cli.run(project=project, args=['build', 'target.bst'])
- assert result.exit_code == 0
+ result.assert_success()
result = cli.run(project=project, args=['checkout', 'target.bst', checkoutdir])
- assert result.exit_code == 0
+ result.assert_success()
# Check that the full content of the tarball is checked out (base-dir: '')
original_dir = os.path.join(str(datafiles), "content")
@@ -173,13 +171,13 @@ def test_stage_explicit_basedir(cli, tmpdir, datafiles):
# Track, fetch, build, checkout
result = cli.run(project=project, args=['track', 'target.bst'])
- assert result.exit_code == 0
+ result.assert_success()
result = cli.run(project=project, args=['fetch', 'target.bst'])
- assert result.exit_code == 0
+ result.assert_success()
result = cli.run(project=project, args=['build', 'target.bst'])
- assert result.exit_code == 0
+ result.assert_success()
result = cli.run(project=project, args=['checkout', 'target.bst', checkoutdir])
- assert result.exit_code == 0
+ result.assert_success()
# Check that the content of the first directory is checked out (base-dir: '*')
original_dir = os.path.join(str(datafiles), "content", "a")