[Notes] [Git][BuildStream/buildstream][jennis/read_only_dir_in_tarball] 2 commits: tar tests: Add tarball which contains a read-only dir



Title: GitLab

James Ennis pushed to branch jennis/read_only_dir_in_tarball at BuildStream / buildstream

Commits:

4 changed files:

Changes:

  • tests/sources/tar.py
    ... ... @@ -3,6 +3,7 @@ import pytest
    3 3
     import tarfile
    
    4 4
     import tempfile
    
    5 5
     import subprocess
    
    6
    +from shutil import copyfile
    
    6 7
     
    
    7 8
     from buildstream._exceptions import ErrorDomain
    
    8 9
     from buildstream import _yaml
    
    ... ... @@ -257,3 +258,27 @@ def test_stage_default_basedir_lzip(cli, tmpdir, datafiles, srcdir):
    257 258
         original_contents = list_dir_contents(original_dir)
    
    258 259
         checkout_contents = list_dir_contents(checkoutdir)
    
    259 260
         assert(checkout_contents == original_contents)
    
    261
    +
    
    262
    +
    
    263
    +# Test that a tarball that contains a read only dir breaks
    
    264
    +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'read-only'))
    
    265
    +def test_read_only_dir(cli, tmpdir, datafiles, srcdir):
    
    266
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    267
    +    generate_project(project, tmpdir)
    
    268
    +
    
    269
    +    # Get the tarball in tests/sources/tar/read-only/content
    
    270
    +    #
    
    271
    +    # NOTE that we need to do this because tarfile.open and tar.add()
    
    272
    +    # are packing the tar up with writeable files and dirs
    
    273
    +    tarball = os.path.join(str(datafiles), 'content', 'a.tar.gz')
    
    274
    +    if not os.path.exists(tarball):
    
    275
    +        raise FileNotFoundError('{} does not exist'.format(tarball))
    
    276
    +    copyfile(tarball, os.path.join(tmpdir, 'a.tar.gz'))
    
    277
    +
    
    278
    +    # Track, fetch, build, checkout
    
    279
    +    result = cli.run(project=project, args=['track', 'target.bst'])
    
    280
    +    result.assert_success()
    
    281
    +    result = cli.run(project=project, args=['fetch', 'target.bst'])
    
    282
    +    result.assert_success()
    
    283
    +    result = cli.run(project=project, args=['build', 'target.bst'])
    
    284
    +    result.assert_success()

  • tests/sources/tar/read-only/content/a.tar.gz
    No preview for this file type
  • tests/sources/tar/read-only/target-lz.bst
    1
    +kind: import
    
    2
    +description: The kind of this element is irrelevant.
    
    3
    +sources:
    
    4
    +- kind: tar
    
    5
    +  url: tmpdir:/a.tar.lz
    
    6
    +  ref: foo

  • tests/sources/tar/read-only/target.bst
    1
    +kind: import
    
    2
    +description: The kind of this element is irrelevant.
    
    3
    +sources:
    
    4
    +- kind: tar
    
    5
    +  url: tmpdir:/a.tar.gz
    
    6
    +  ref: foo



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]