[Notes] [Git][BuildStream/buildstream][jmac/vdir_import_test] virtual_directory_import.py: Test direct import of randomly generated directory



Title: GitLab

Jim MacArthur pushed to branch jmac/vdir_import_test at BuildStream / buildstream

Commits:

1 changed file:

Changes:

  • tests/storage/virtual_directory_import.py
    ... ... @@ -141,7 +141,7 @@ def directory_not_empty(path):
    141 141
         return os.listdir(path)
    
    142 142
     
    
    143 143
     
    
    144
    -@pytest.mark.parametrize("original,overlay", combinations([1, 2, 3, 4, 5]))
    
    144
    +@pytest.mark.parametrize("original,overlay", combinations([1, 2, 3, 4, 5, 6]))
    
    145 145
     def test_cas_import(cli, tmpdir, original, overlay):
    
    146 146
         fake_context = FakeContext()
    
    147 147
         fake_context.artifactdir = tmpdir
    
    ... ... @@ -153,26 +153,28 @@ def test_cas_import(cli, tmpdir, original, overlay):
    153 153
         d.import_files(d2)
    
    154 154
         d.export_files(os.path.join(tmpdir, "output"))
    
    155 155
     
    
    156
    -    for item in root_filesets[overlay - 1]:
    
    157
    -        (path, typename, content) = item
    
    158
    -        realpath = resolve_symlinks(path, os.path.join(tmpdir, "output"))
    
    159
    -        if typename == 'F':
    
    160
    -            if os.path.isdir(realpath) and directory_not_empty(realpath):
    
    161
    -                # The file should not have overwritten the directory in this case.
    
    162
    -                pass
    
    163
    -            else:
    
    164
    -                assert os.path.isfile(realpath), "{} did not exist in the combined virtual directory".format(path)
    
    165
    -                assert file_contents_are(realpath, content)
    
    166
    -        elif typename == 'S':
    
    167
    -            if os.path.isdir(realpath) and directory_not_empty(realpath):
    
    168
    -                # The symlink should not have overwritten the directory in this case.
    
    169
    -                pass
    
    170
    -            else:
    
    171
    -                assert os.path.islink(realpath)
    
    172
    -                assert os.readlink(realpath) == content
    
    173
    -        elif typename == 'D':
    
    174
    -            # Note that isdir accepts symlinks to dirs, so a symlink to a dir is acceptable.
    
    175
    -            assert os.path.isdir(realpath)
    
    156
    +    if overlay < 6:
    
    157
    +        # TODO: We don't do a detailed content check for root 6, the random one
    
    158
    +        for item in root_filesets[overlay - 1]:
    
    159
    +            (path, typename, content) = item
    
    160
    +            realpath = resolve_symlinks(path, os.path.join(tmpdir, "output"))
    
    161
    +            if typename == 'F':
    
    162
    +                if os.path.isdir(realpath) and directory_not_empty(realpath):
    
    163
    +                    # The file should not have overwritten the directory in this case.
    
    164
    +                    pass
    
    165
    +                else:
    
    166
    +                    assert os.path.isfile(realpath), "{} did not exist in the combined virtual directory".format(path)
    
    167
    +                    assert file_contents_are(realpath, content)
    
    168
    +            elif typename == 'S':
    
    169
    +                if os.path.isdir(realpath) and directory_not_empty(realpath):
    
    170
    +                    # The symlink should not have overwritten the directory in this case.
    
    171
    +                    pass
    
    172
    +                else:
    
    173
    +                    assert os.path.islink(realpath)
    
    174
    +                    assert os.readlink(realpath) == content
    
    175
    +            elif typename == 'D':
    
    176
    +                # Note that isdir accepts symlinks to dirs, so a symlink to a dir is acceptable.
    
    177
    +                assert os.path.isdir(realpath)
    
    176 178
     
    
    177 179
         # Now do the same thing with filebaseddirectories and check the contents match
    
    178 180
         d3 = create_new_casdir(original, fake_context, tmpdir)
    



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