this repo has no description
www.jonmsterling.com/01HC/
1// SPDX-FileCopyrightText: 2025 The Project Pterodactyl Developers
2//
3// SPDX-License-Identifier: MPL-2.0
4
5import Testing
6
7@testable import PterodactylBuild
8@testable import llbuild2fx
9
10struct BuildTests {
11 @Test
12 func testImports() async throws {
13 let group = LLBMakeDefaultDispatchGroup()
14 let db = LLBInMemoryCASDatabase(group: group)
15 let functionCache = FXInMemoryFunctionCache(group: group)
16 let executor = FXLocalExecutor()
17 let engine = FXEngine(group: group, db: db, functionCache: functionCache, executor: executor)
18 let client = LLBCASFSClient(db)
19 let ctx = Context()
20
21 let declTree = LLBDeclFileTree.dir(
22 [
23 "src": .dir([
24 "bar.ext": .file(contents: Array("hello world".utf8)),
25 "foo.ext": .file(contents: Array("import bar".utf8)),
26 "baz.ext": .file(contents: Array("import foo".utf8))
27 ])
28 ]
29 )
30
31 let treeID: LLBDataID = try await client.store(declTree, ctx).get()
32 let dependencyGraph = try await engine.build(key: Keys.SourceTree.GetDependencyGraph(sourceTreeId: treeID), ctx).get()
33 let foo = UnitName(basename: "foo")
34 let bar = UnitName(basename: "bar")
35 let baz = UnitName(basename: "baz")
36
37 #expect(
38 dependencyGraph.edges == [
39 bar: [],
40 foo: [bar],
41 baz: [foo]
42 ]
43 )
44
45 let dependenciesOfBaz = try await engine.build(key: Keys.SourceTree.GetDependencies(sourceTreeId: treeID, unitName: baz), ctx).get()
46 #expect(dependenciesOfBaz == [foo, bar])
47 return
48 }
49}