1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
import os
import pytest
from buildstream._exceptions import ErrorDomain
from buildstream._context import Context
from buildstream.storage._casbaseddirectory import CasBasedDirectory
from buildstream.storage._filebaseddirectory import FileBasedDirectory
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"storage-test"
)
def setup_backend(backend_class, tmpdir):
if backend_class == FileBasedDirectory:
return backend_class(os.path.join(tmpdir, "vdir"))
else:
context = Context()
context.artifactdir = os.path.join(tmpdir, "cas")
return backend_class(context)
@pytest.mark.parametrize("backend", [
FileBasedDirectory, CasBasedDirectory])
@pytest.mark.datafiles(DATA_DIR)
def test_import(tmpdir, datafiles, backend):
original = os.path.join(str(datafiles), "original")
c = setup_backend(backend, str(tmpdir))
c.import_files(original)
assert("bin/bash" in c.list_relative_paths())
assert("bin/hello" in c.list_relative_paths())
@pytest.mark.parametrize("backend", [
FileBasedDirectory, CasBasedDirectory])
@pytest.mark.datafiles(DATA_DIR)
def test_modified_file_list(tmpdir, datafiles, backend):
original = os.path.join(str(datafiles), "original")
overlay = os.path.join(str(datafiles), "overlay")
c = setup_backend(backend, str(tmpdir))
c.import_files(original)
c.mark_unmodified()
c.import_files(overlay)
print("List of all paths in imported results: {}".format(c.list_relative_paths()))
assert("bin/bash" in c.list_relative_paths())
assert("bin/bash" in c.list_modified_paths())
assert("bin/hello" not in c.list_modified_paths())
|