CBE: Don't expose openCFile, always close file after an update

This commit is contained in:
Noam Preil 2020-07-08 14:10:11 -04:00
parent 6b48634166
commit d060be8804
No known key found for this signature in database
GPG Key ID: FC347E7C85BE8238
2 changed files with 5 additions and 4 deletions

View File

@ -86,7 +86,7 @@ pub fn writeFilePath(
return result;
}
pub fn openCFile(allocator: *Allocator, file: fs.File, options: Options) !File.C {
fn openCFile(allocator: *Allocator, file: fs.File, options: Options) !File.C {
return File.C{
.allocator = allocator,
.file = file,
@ -282,6 +282,8 @@ pub const File = struct {
}
}
try writer.writeAll(self.main.items);
self.file.?.close();
self.file = null;
}
};

View File

@ -480,9 +480,8 @@ pub const TestContext = struct {
switch (update.case) {
.Transformation => |expected_output| {
if (case.cbe) {
var cfile: *link.File.C = module.bin_file.cast(link.File.C).?;
cfile.file.?.close();
cfile.file = null;
// The C file is always closed after an update, because we don't support
// incremental updates
var file = try tmp.dir.openFile(bin_name, .{ .read = true });
defer file.close();
var out = file.reader().readAllAlloc(allocator, 1024 * 1024) catch @panic("Unable to read C output!");