summaryrefslogtreecommitdiff
path: root/tests/frontend/project/plugins/randomelement.py
blob: b36b75c8a220a14aac51722999bc16ff174d7f66 (plain)
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
import os

from buildstream import Element


class RandomElement(Element):
    BST_VIRTUAL_DIRECTORY = True

    def configure(self, node):
        pass

    def preflight(self):
        pass

    def get_unique_key(self):
        pass

    def configure_sandbox(self, sandbox):
        pass

    def stage(self, sandbox):
        pass

    def assemble(self, sandbox):
        rootdir = sandbox.get_virtual_directory()
        outputdir = rootdir.descend("output", create=True)

        # Generate non-reproducible output
        with outputdir.open_file("random", mode="wb") as f:
            f.write(os.urandom(64))

        return "/output"


def setup():
    return RandomElement