sx sync: catch bindings take parens; Allocator.alloc -> alloc_bytes
This commit is contained in:
@@ -83,7 +83,7 @@ Manifest :: struct {
|
|||||||
// Copy `s` into `alloc`-owned, null-terminated storage so the manifest
|
// Copy `s` into `alloc`-owned, null-terminated storage so the manifest
|
||||||
// survives the source bytes / parse scratch being dropped.
|
// survives the source bytes / parse scratch being dropped.
|
||||||
dup_str :: (s: string, alloc: Allocator) -> string {
|
dup_str :: (s: string, alloc: Allocator) -> string {
|
||||||
raw : [*]u8 = xx alloc.alloc(s.len + 1);
|
raw : [*]u8 = xx alloc.alloc_bytes(s.len + 1);
|
||||||
if s.len > 0 { memcpy(raw, s.ptr, s.len); }
|
if s.len > 0 { memcpy(raw, s.ptr, s.len); }
|
||||||
raw[s.len] = 0;
|
raw[s.len] = 0;
|
||||||
return string.{ ptr = raw, len = s.len };
|
return string.{ ptr = raw, len = s.len };
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ save :: (self: *Repo, root_dir: string) -> !LoadErr {
|
|||||||
// Copy `s` into `alloc`-owned, null-terminated storage so it survives the
|
// Copy `s` into `alloc`-owned, null-terminated storage so it survives the
|
||||||
// parse scratch / source buffer being freed.
|
// parse scratch / source buffer being freed.
|
||||||
db_dup_str :: (s: string, alloc: Allocator) -> string {
|
db_dup_str :: (s: string, alloc: Allocator) -> string {
|
||||||
raw : [*]u8 = xx alloc.alloc(s.len + 1);
|
raw : [*]u8 = xx alloc.alloc_bytes(s.len + 1);
|
||||||
if s.len > 0 { memcpy(raw, s.ptr, s.len); }
|
if s.len > 0 { memcpy(raw, s.ptr, s.len); }
|
||||||
raw[s.len] = 0;
|
raw[s.len] = 0;
|
||||||
return string.{ ptr = raw, len = s.len };
|
return string.{ ptr = raw, len = s.len };
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ check_rejects_bad_slug :: () -> bool {
|
|||||||
a := valid_app();
|
a := valid_app();
|
||||||
a.slug = "Bad_Slug"; // uppercase + underscore
|
a.slug = "Bad_Slug"; // uppercase + underscore
|
||||||
matched := false;
|
matched := false;
|
||||||
validate_app(a) catch e { matched = (e == error.BadSlug); };
|
validate_app(a) catch (e) { matched = (e == error.BadSlug); };
|
||||||
return matched;
|
return matched;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ check_rejects_empty_version :: () -> bool {
|
|||||||
r := valid_release();
|
r := valid_release();
|
||||||
r.version = "";
|
r.version = "";
|
||||||
matched := false;
|
matched := false;
|
||||||
validate_release(r) catch e { matched = (e == error.EmptyVersion); };
|
validate_release(r) catch (e) { matched = (e == error.EmptyVersion); };
|
||||||
return matched;
|
return matched;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ check_rejects_bad_version :: () -> bool {
|
|||||||
r := valid_release();
|
r := valid_release();
|
||||||
r.version = "1.2"; // missing PATCH component
|
r.version = "1.2"; // missing PATCH component
|
||||||
matched := false;
|
matched := false;
|
||||||
validate_release(r) catch e { matched = (e == error.BadVersion); };
|
validate_release(r) catch (e) { matched = (e == error.BadVersion); };
|
||||||
return matched;
|
return matched;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ check_rejects_bad_channel :: () -> bool {
|
|||||||
c := valid_channel();
|
c := valid_channel();
|
||||||
c.name = "Bad Channel"; // space + uppercase
|
c.name = "Bad Channel"; // space + uppercase
|
||||||
matched := false;
|
matched := false;
|
||||||
validate_channel(c) catch e { matched = (e == error.BadChannelName); };
|
validate_channel(c) catch (e) { matched = (e == error.BadChannelName); };
|
||||||
return matched;
|
return matched;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ check_rejects_empty_content_type :: () -> bool {
|
|||||||
a := valid_artifact();
|
a := valid_artifact();
|
||||||
a.content_type = ""; // required string cleared
|
a.content_type = ""; // required string cleared
|
||||||
matched := false;
|
matched := false;
|
||||||
validate_artifact(a) catch e { matched = (e == error.MissingField); };
|
validate_artifact(a) catch (e) { matched = (e == error.MissingField); };
|
||||||
return matched;
|
return matched;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ check_rejects_bad_size :: () -> bool {
|
|||||||
a := valid_artifact();
|
a := valid_artifact();
|
||||||
a.size_bytes = -1; // a content-addressed artifact has positive bytes
|
a.size_bytes = -1; // a content-addressed artifact has positive bytes
|
||||||
matched := false;
|
matched := false;
|
||||||
validate_artifact(a) catch e { matched = (e == error.BadSize); };
|
validate_artifact(a) catch (e) { matched = (e == error.BadSize); };
|
||||||
return matched;
|
return matched;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,7 +161,7 @@ check_rejects_bad_digest :: () -> bool {
|
|||||||
a := valid_artifact();
|
a := valid_artifact();
|
||||||
a.sha256 = "not-a-sha"; // not 64 lowercase-hex chars
|
a.sha256 = "not-a-sha"; // not 64 lowercase-hex chars
|
||||||
matched := false;
|
matched := false;
|
||||||
validate_artifact(a) catch e { matched = (e == error.BadDigest); };
|
validate_artifact(a) catch (e) { matched = (e == error.BadDigest); };
|
||||||
return matched;
|
return matched;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ check_missing_artifact_path :: (alloc: Allocator) -> bool {
|
|||||||
if pe { return false; } // parse must not fail here
|
if pe { return false; } // parse must not fail here
|
||||||
raised := false;
|
raised := false;
|
||||||
matched := false;
|
matched := false;
|
||||||
validate_manifest(m, "examples") catch err { raised = true; matched = (err == error.MissingArtifact); };
|
validate_manifest(m, "examples") catch (err) { raised = true; matched = (err == error.MissingArtifact); };
|
||||||
return raised and matched;
|
return raised and matched;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ main :: () -> s32 {
|
|||||||
arts1.append(mk_artifact("art_01b", "rel_01", "not-a-sha")); // invalid digest
|
arts1.append(mk_artifact("art_01b", "rel_01", "not-a-sha")); // invalid digest
|
||||||
failed := false;
|
failed := false;
|
||||||
was_validation := false;
|
was_validation := false;
|
||||||
repo.publish(mk_release("rel_01", "1.1.0"), @arts1, the_channel()) catch e {
|
repo.publish(mk_release("rel_01", "1.1.0"), @arts1, the_channel()) catch (e) {
|
||||||
failed = true;
|
failed = true;
|
||||||
was_validation = (e == error.Validation);
|
was_validation = (e == error.Validation);
|
||||||
};
|
};
|
||||||
@@ -123,7 +123,7 @@ main :: () -> s32 {
|
|||||||
arts2.append(mk_artifact("art_02", "WRONG", DIGEST_B)); // release_id mismatch
|
arts2.append(mk_artifact("art_02", "WRONG", DIGEST_B)); // release_id mismatch
|
||||||
ifailed := false;
|
ifailed := false;
|
||||||
was_integrity := false;
|
was_integrity := false;
|
||||||
repo.publish(mk_release("rel_02", "1.2.0"), @arts2, the_channel()) catch e {
|
repo.publish(mk_release("rel_02", "1.2.0"), @arts2, the_channel()) catch (e) {
|
||||||
ifailed = true;
|
ifailed = true;
|
||||||
was_integrity = (e == error.Integrity);
|
was_integrity = (e == error.Integrity);
|
||||||
};
|
};
|
||||||
@@ -145,7 +145,7 @@ main :: () -> s32 {
|
|||||||
arts_xc.append(mk_artifact("art_xc", "rel_xc", DIGEST_B)); // self-consistent artifact
|
arts_xc.append(mk_artifact("art_xc", "rel_xc", DIGEST_B)); // self-consistent artifact
|
||||||
xc_failed := false;
|
xc_failed := false;
|
||||||
xc_integrity := false;
|
xc_integrity := false;
|
||||||
repo.publish(mk_release("rel_xc", "1.3.0"), @arts_xc, mk_channel_for("app_02")) catch e {
|
repo.publish(mk_release("rel_xc", "1.3.0"), @arts_xc, mk_channel_for("app_02")) catch (e) {
|
||||||
xc_failed = true;
|
xc_failed = true;
|
||||||
xc_integrity = (e == error.Integrity);
|
xc_integrity = (e == error.Integrity);
|
||||||
};
|
};
|
||||||
@@ -170,7 +170,7 @@ main :: () -> s32 {
|
|||||||
arts_xa.append(mk_artifact_for("art_xa", "app_02", "rel_xa", DIGEST_B));
|
arts_xa.append(mk_artifact_for("art_xa", "app_02", "rel_xa", DIGEST_B));
|
||||||
xa_failed := false;
|
xa_failed := false;
|
||||||
xa_integrity := false;
|
xa_integrity := false;
|
||||||
repo.publish(mk_release("rel_xa", "1.4.0"), @arts_xa, the_channel()) catch e {
|
repo.publish(mk_release("rel_xa", "1.4.0"), @arts_xa, the_channel()) catch (e) {
|
||||||
xa_failed = true;
|
xa_failed = true;
|
||||||
xa_integrity = (e == error.Integrity);
|
xa_integrity = (e == error.Integrity);
|
||||||
};
|
};
|
||||||
@@ -196,7 +196,7 @@ main :: () -> s32 {
|
|||||||
arts_cn.append(mk_artifact("art_cn", "rel_cn", DIGEST_B)); // self-consistent artifact
|
arts_cn.append(mk_artifact("art_cn", "rel_cn", DIGEST_B)); // self-consistent artifact
|
||||||
cn_failed := false;
|
cn_failed := false;
|
||||||
cn_integrity := false;
|
cn_integrity := false;
|
||||||
repo.publish(mk_release("rel_cn", "1.5.0"), @arts_cn, mk_named_channel("app_01", "beta")) catch e {
|
repo.publish(mk_release("rel_cn", "1.5.0"), @arts_cn, mk_named_channel("app_01", "beta")) catch (e) {
|
||||||
cn_failed = true;
|
cn_failed = true;
|
||||||
cn_integrity = (e == error.Integrity);
|
cn_integrity = (e == error.Integrity);
|
||||||
};
|
};
|
||||||
@@ -222,7 +222,7 @@ main :: () -> s32 {
|
|||||||
arts_dup.append(mk_artifact("art_dup", "rel_00", DIGEST_B));
|
arts_dup.append(mk_artifact("art_dup", "rel_00", DIGEST_B));
|
||||||
dup_failed := false;
|
dup_failed := false;
|
||||||
dup_integrity := false;
|
dup_integrity := false;
|
||||||
repo.publish(mk_release("rel_00", "9.9.9"), @arts_dup, the_channel()) catch e {
|
repo.publish(mk_release("rel_00", "9.9.9"), @arts_dup, the_channel()) catch (e) {
|
||||||
dup_failed = true;
|
dup_failed = true;
|
||||||
dup_integrity = (e == error.Integrity);
|
dup_integrity = (e == error.Integrity);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user