bazel start + mcp start
This commit is contained in:
1 parent
a90653260a
commit
4c082aca7c
33 files changed
+1728
-79
No files matched your search
@@ -21,6 +21,7 @@ type FakeNode struct {
|
||||
Runs map[string]bool
|
||||
Last node.StartSpec
|
||||
Homes map[string][]byte
|
||||
Files map[string][]byte
|
||||
Exports map[string]*fakeExport
|
||||
Imports map[string]*fakeImport
|
||||
Passes int
|
||||
@@ -30,7 +31,7 @@ type FakeNode struct {
|
||||
}
|
||||
|
||||
func NewFakeNode(name string) *FakeNode {
|
||||
return &FakeNode{name: name, Runs: map[string]bool{}, Homes: map[string][]byte{},
|
||||
return &FakeNode{name: name, Runs: map[string]bool{}, Homes: map[string][]byte{}, Files: map[string][]byte{},
|
||||
Exports: map[string]*fakeExport{}, Imports: map[string]*fakeImport{}, Usable: model.Size{MemoryMB: 8192, CPUs: 4}}
|
||||
}
|
||||
|
||||
@@ -188,6 +189,28 @@ func (f *FakeNode) DeleteHome(_ context.Context, drive, machine string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *FakeNode) ReadFile(_ context.Context, drive, machine, path string, offset int64, limit int) ([]byte, int64, error) {
|
||||
f.Mu.Lock()
|
||||
defer f.Mu.Unlock()
|
||||
data, ok := f.Files[drive+"/"+machine+"/"+path]
|
||||
if !ok {
|
||||
return nil, 0, errors.New("there's no file " + path)
|
||||
}
|
||||
end := min(int64(len(data)), offset+int64(limit))
|
||||
return data[offset:end], int64(len(data)), nil
|
||||
}
|
||||
|
||||
func (f *FakeNode) WriteFile(_ context.Context, drive, machine, path string, offset int64, data []byte) error {
|
||||
f.Mu.Lock()
|
||||
defer f.Mu.Unlock()
|
||||
key := drive + "/" + machine + "/" + path
|
||||
if offset == 0 {
|
||||
f.Files[key] = nil
|
||||
}
|
||||
f.Files[key] = append(f.Files[key], data...)
|
||||
return nil
|
||||
}
|
||||
|
||||
type fakeExport struct {
|
||||
data []byte
|
||||
pos int
|
||||
|
||||
Reference in new issue
Block a user