refactor: keep Claro in one strict C89 source file
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ ROOT = pathlib.Path(__file__).resolve().parent.parent
|
||||
CLARO = ROOT / ("claro.exe" if os.name == "nt" else "claro")
|
||||
|
||||
if not CLARO.exists():
|
||||
print("Build first: gcc -std=c99 src/claro.c -O0 -o " + ("claro.exe" if os.name == "nt" else "claro") + " -lm")
|
||||
print("Build first: gcc -std=c89 -pedantic-errors src/claro.c -O0 -o " + ("claro.exe" if os.name == "nt" else "claro") + " -lm")
|
||||
raise SystemExit(2)
|
||||
|
||||
raise SystemExit(subprocess.call([str(CLARO), "test"], cwd=str(ROOT)))
|
||||
|
||||
@@ -22,7 +22,7 @@ def main() -> int:
|
||||
encoding="utf-8",
|
||||
)
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
|
||||
@@ -22,7 +22,7 @@ def main() -> int:
|
||||
encoding="utf-8",
|
||||
)
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Compile the single source in isolation and exercise C89 portability boundaries."""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shlex
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
FLAGS = ['-std=c89', '-pedantic-errors', '-Werror=implicit-function-declaration']
|
||||
|
||||
|
||||
def main():
|
||||
cc = shlex.split(os.environ.get('CLARO_CC', 'gcc'))
|
||||
with tempfile.TemporaryDirectory(prefix='claro-c89-', dir=os.environ.get('TMPDIR')) as directory:
|
||||
work = Path(directory)
|
||||
source = work / 'claro.c'
|
||||
source.write_bytes((ROOT / 'src/claro.c').read_bytes())
|
||||
exe = work / ('claro.exe' if os.name == 'nt' else 'claro')
|
||||
subprocess.run(cc + FLAGS + [str(source), '-o', str(exe), '-lm'], check=True)
|
||||
unit = work / 'format_probe.c'
|
||||
unit.write_text(r'''#define main claro_application_main
|
||||
#include "claro.c"
|
||||
#undef main
|
||||
#include <assert.h>
|
||||
int main(void)
|
||||
{
|
||||
char guard[8] = "abcdefg";
|
||||
char buffer[400];
|
||||
char *number;
|
||||
int result;
|
||||
result=claro_snprintf(guard+1,4,"%s","123456");
|
||||
assert(result==6 && guard[0]=='a' && guard[5]=='f');
|
||||
assert(strcmp(guard+1,"123")==0);
|
||||
assert(claro_snprintf(NULL,0,"%s:%d","hello",-12)==9);
|
||||
assert(claro_snprintf(guard,1,"%s","hello")==5 && guard[0]==0);
|
||||
assert(claro_snprintf(buffer,sizeof(buffer),"%.*s",3,"abcdef")==3);
|
||||
assert(strcmp(buffer,"abc")==0);
|
||||
assert(claro_snprintf(buffer,sizeof(buffer),"%.*s",-1,"abc")==3);
|
||||
assert(strcmp(buffer,"abc")==0);
|
||||
claro_snprintf(buffer,sizeof(buffer),"%08lx %.15g %.0f %%",(unsigned long)42,1.25,3.0);
|
||||
assert(strcmp(buffer,"0000002a 1.25 3 %")==0);
|
||||
claro_snprintf(buffer,sizeof(buffer),"%.0f",DBL_MAX);
|
||||
assert(strlen(buffer)<sizeof(buffer));
|
||||
number=num_to_string(-0.0); assert(strcmp(number,"0")==0); free(number);
|
||||
return 0;
|
||||
}
|
||||
''')
|
||||
unit_exe = work / ('format_probe.exe' if os.name == 'nt' else 'format_probe')
|
||||
subprocess.run(cc + FLAGS + [str(unit), '-o', str(unit_exe), '-lm'], check=True)
|
||||
subprocess.run([str(unit_exe)], cwd=work, check=True)
|
||||
invalid = work / 'invalid.c'
|
||||
invalid.write_text('int main(void) { int n = 0; n++; int late = 1; return late; }\n')
|
||||
bad = subprocess.run(cc + FLAGS + ['-fsyntax-only', str(invalid)], capture_output=True, text=True)
|
||||
assert bad.returncode != 0 and 'error' in bad.stderr.lower(), 'C89 compiler gate accepted invalid C99 syntax'
|
||||
script = work / 'probe.claro'
|
||||
script.write_text('''TEACH add a b
|
||||
RETURN a + b
|
||||
END
|
||||
DO add 2 3
|
||||
SAY RESULT
|
||||
SAY 2147483648
|
||||
SAY -2147483649
|
||||
SAY 9007199254740991
|
||||
SAY -2.5
|
||||
IMPORT "lib/random.claro" AS random
|
||||
DO random.seed 1
|
||||
DO random.int -2147483648 2147483647
|
||||
SET sample RESULT
|
||||
IF sample >= -2147483648
|
||||
IF sample <= 2147483647
|
||||
SAY "range OK"
|
||||
END
|
||||
END
|
||||
''')
|
||||
run = subprocess.run([str(exe), str(script)], cwd=work, text=True, capture_output=True)
|
||||
expected = '5\n2147483648\n-2147483649\n9007199254740991\n-2.5\nrange OK\n'
|
||||
assert run.returncode == 0 and run.stdout == expected, (run.returncode, run.stdout, run.stderr)
|
||||
print('PASS: standalone strict C89 build, rejected C99 fixture, bounded formatting, functions, numbers, extreme random bounds')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -19,7 +19,7 @@ def main() -> int:
|
||||
script = tmp_path / "tokens.claro"
|
||||
script.write_text('SAY "a repeated string literal"\n' * 2000, encoding="utf-8")
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
|
||||
@@ -10,7 +10,7 @@ ROOT = Path(__file__).resolve().parents[1]
|
||||
def main():
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
result = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-c", "src/claro.c", "-o", str(Path(tmp) / "claro.o")],
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-c", "src/claro.c", "-o", str(Path(tmp) / "claro.o")],
|
||||
cwd=ROOT,
|
||||
text=True,
|
||||
capture_output=True,
|
||||
|
||||
@@ -35,7 +35,7 @@ def main() -> int:
|
||||
)
|
||||
build = subprocess.run(
|
||||
[
|
||||
"gcc", "-std=c99", "-O0", "-g",
|
||||
"gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g",
|
||||
"-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm",
|
||||
], cwd=ROOT, text=True, capture_output=True,
|
||||
|
||||
@@ -26,7 +26,7 @@ def main() -> int:
|
||||
)
|
||||
build = subprocess.run(
|
||||
[
|
||||
"gcc", "-std=c99", "-O0", "-g",
|
||||
"gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g",
|
||||
"-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm",
|
||||
], cwd=ROOT, text=True, capture_output=True,
|
||||
|
||||
@@ -23,7 +23,7 @@ def main() -> int:
|
||||
encoding="utf-8",
|
||||
)
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
|
||||
@@ -23,7 +23,7 @@ def main() -> int:
|
||||
+ 'SAY item_count\n', encoding="utf-8"
|
||||
)
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
|
||||
@@ -22,7 +22,7 @@ def main() -> int:
|
||||
encoding="utf-8",
|
||||
)
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
|
||||
@@ -22,7 +22,7 @@ def main() -> int:
|
||||
encoding="utf-8",
|
||||
)
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
|
||||
@@ -23,7 +23,7 @@ def main() -> int:
|
||||
encoding="utf-8",
|
||||
)
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
|
||||
@@ -29,7 +29,7 @@ def main() -> int:
|
||||
)
|
||||
build = subprocess.run(
|
||||
[
|
||||
"gcc", "-std=c99", "-O0", "-g",
|
||||
"gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g",
|
||||
"-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm",
|
||||
], cwd=ROOT, text=True, capture_output=True,
|
||||
|
||||
@@ -23,7 +23,7 @@ def main() -> int:
|
||||
encoding="utf-8",
|
||||
)
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Execute every Claro code block in docs/FIRST_HOUR.md and check its output."""
|
||||
from pathlib import Path
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
EXE = ROOT / ("claro.exe" if os.name == "nt" else "claro")
|
||||
INPUTS = {2: "Ada\n", 5: "4\n"}
|
||||
EXPECTED = {
|
||||
1: "Hello!\n",
|
||||
2: "What is your name?\nHello Ada\n",
|
||||
3: "0\n",
|
||||
4: "1\n",
|
||||
5: "What is 2 + 2?\nCorrect!\n",
|
||||
6: "Practice helps\nPractice helps\nPractice helps\n",
|
||||
7: "milk\nbread\n",
|
||||
8: "5\n",
|
||||
9: "Hello\n",
|
||||
}
|
||||
|
||||
|
||||
def main() -> int:
|
||||
text = (ROOT / "docs/FIRST_HOUR.md").read_text(encoding="utf-8")
|
||||
blocks = re.findall(r"```claro\s*\n(.*?)\n```", text, flags=re.DOTALL)
|
||||
if len(blocks) != len(EXPECTED):
|
||||
print(f"FAIL: expected {len(EXPECTED)} Claro blocks, found {len(blocks)}")
|
||||
return 1
|
||||
with tempfile.TemporaryDirectory(prefix="claro-first-hour-") as tmp:
|
||||
for number, block in enumerate(blocks, 1):
|
||||
script = Path(tmp) / f"block-{number}.claro"
|
||||
script.write_text(block + "\n", encoding="utf-8")
|
||||
run = subprocess.run([str(EXE), str(script)], cwd=tmp,
|
||||
input=INPUTS.get(number, ""), text=True,
|
||||
capture_output=True)
|
||||
if run.returncode or run.stdout != EXPECTED[number]:
|
||||
print(f"FAIL: First Hour block {number}: exit={run.returncode}")
|
||||
print(f"expected stdout: {EXPECTED[number]!r}")
|
||||
print(f"actual stdout: {run.stdout!r}")
|
||||
print(run.stderr, end="", file=sys.stderr)
|
||||
return 1
|
||||
print(f"PASS: First Hour block {number}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -21,7 +21,7 @@ def main() -> int:
|
||||
encoding="utf-8",
|
||||
)
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
|
||||
@@ -16,7 +16,7 @@ def main() -> int:
|
||||
with tempfile.TemporaryDirectory(prefix="get-at-cleanup-") as tmp:
|
||||
binary = Path(tmp) / "claro-asan"
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
|
||||
@@ -21,7 +21,7 @@ def main() -> int:
|
||||
encoding="utf-8",
|
||||
)
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
|
||||
@@ -23,7 +23,7 @@ def main() -> int:
|
||||
encoding="utf-8",
|
||||
)
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
|
||||
@@ -23,7 +23,7 @@ def main() -> int:
|
||||
encoding="utf-8",
|
||||
)
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
|
||||
@@ -43,7 +43,7 @@ def main() -> int:
|
||||
)
|
||||
binary = tmp_path / "claro-http"
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "src/claro.c", "-o", str(binary), "-lm"],
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
if build.returncode:
|
||||
|
||||
@@ -24,7 +24,7 @@ def main() -> int:
|
||||
encoding="utf-8",
|
||||
)
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
|
||||
@@ -35,7 +35,7 @@ def main() -> int:
|
||||
)
|
||||
build = subprocess.run(
|
||||
[
|
||||
"gcc", "-std=c99", "-O0", "-g",
|
||||
"gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g",
|
||||
"-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm",
|
||||
], cwd=ROOT, text=True, capture_output=True,
|
||||
|
||||
@@ -6,7 +6,7 @@ from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
EXE = ROOT / ("claro.exe" if os.name == "nt" else "claro")
|
||||
EXPECTED_VERSION = "Claro v2026.10.20.155641"
|
||||
EXPECTED_VERSION = "Claro v2026.10.20.160950"
|
||||
|
||||
|
||||
def fail(message):
|
||||
@@ -57,11 +57,11 @@ def main():
|
||||
fail(out)
|
||||
starter = work / "StarterApp"
|
||||
starter_project = read(starter / "claro.project")
|
||||
for phrase in ["manifest-version: 1", "name: StarterApp", "main: main.claro", "version: v2026.10.20.155641", "packages:"]:
|
||||
for phrase in ["manifest-version: 1", "name: StarterApp", "main: main.claro", "version: v2026.10.20.160950", "packages:"]:
|
||||
if phrase not in starter_project:
|
||||
fail(f"claro new project file missing {phrase!r}:\n{starter_project}")
|
||||
starter_lock = read(starter / "claro.lock")
|
||||
for phrase in ["lock-version: 1", "version: v2026.10.20.155641"]:
|
||||
for phrase in ["lock-version: 1", "version: v2026.10.20.160950"]:
|
||||
if phrase not in starter_lock:
|
||||
fail(f"claro new lockfile missing {phrase!r}:\n{starter_lock}")
|
||||
|
||||
@@ -71,7 +71,7 @@ def main():
|
||||
if rc != 0:
|
||||
fail(out)
|
||||
project = read(work / "claro.project")
|
||||
for phrase in ["manifest-version: 1", "name: ClaroProject", "main: main.claro", "version: v2026.10.20.155641", "packages:"]:
|
||||
for phrase in ["manifest-version: 1", "name: ClaroProject", "main: main.claro", "version: v2026.10.20.160950", "packages:"]:
|
||||
if phrase not in project:
|
||||
fail(f"claro.project missing {phrase!r}:\n{project}")
|
||||
|
||||
@@ -100,7 +100,7 @@ def main():
|
||||
fail(f"Package checksum should be a stable non-placeholder value, got {checksum!r}")
|
||||
|
||||
lock = read(work / "claro.lock")
|
||||
for phrase in ["lock-version: 1", "version: v2026.10.20.155641", "package: math-tools", "checksum:"]:
|
||||
for phrase in ["lock-version: 1", "version: v2026.10.20.160950", "package: math-tools", "checksum:"]:
|
||||
if phrase not in lock:
|
||||
fail(f"claro.lock missing {phrase!r}:\n{lock}")
|
||||
|
||||
@@ -127,12 +127,12 @@ def main():
|
||||
fail(f"Lock format-version diagnostic was unclear:\n{out}")
|
||||
if read(work / "claro.lock") != invalid_lock:
|
||||
fail("package doctor must not rewrite an invalid lock format version")
|
||||
invalid_release_lock = lock.replace("version: v2026.10.20.155641", "version: v1.18.25", 1)
|
||||
invalid_release_lock = lock.replace("version: v2026.10.20.160950", "version: v1.18.25", 1)
|
||||
(work / "claro.lock").write_text(invalid_release_lock, encoding="utf-8")
|
||||
rc, out = run([str(EXE), "package", "doctor"], work)
|
||||
if rc == 0:
|
||||
fail("package doctor must reject a lockfile for a different Claro release")
|
||||
if "BAD lock release version: expected exactly one version: v2026.10.20.155641 line" not in out:
|
||||
if "BAD lock release version: expected exactly one version: v2026.10.20.160950 line" not in out:
|
||||
fail(f"Lock release-version diagnostic was unclear:\n{out}")
|
||||
if read(work / "claro.lock") != invalid_release_lock:
|
||||
fail("package doctor must not rewrite an invalid lock release version")
|
||||
@@ -343,7 +343,7 @@ def main():
|
||||
fail("Long package name should not create a package folder")
|
||||
|
||||
(work / "claro.project").write_text(
|
||||
"manifest-version: 1\nname: ClaroProject\nmain: main.claro\nversion: v2026.10.20.155641\npackages:\npackage: ../bad\n",
|
||||
"manifest-version: 1\nname: ClaroProject\nmain: main.claro\nversion: v2026.10.20.160950\npackages:\npackage: ../bad\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
rc, out = run([str(EXE), "package", "doctor"], work)
|
||||
@@ -382,7 +382,7 @@ def main():
|
||||
fail("package add should not create a package folder while unsafe names remain in claro.project")
|
||||
|
||||
(work / "claro.project").write_text(
|
||||
"manifest-version: 1\nname: ClaroProject\nmain: main.claro\nversion: v2026.10.20.155641\npackages:\npackage: math-tools\npackage: ../bad\n",
|
||||
"manifest-version: 1\nname: ClaroProject\nmain: main.claro\nversion: v2026.10.20.160950\npackages:\npackage: math-tools\npackage: ../bad\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
rc, out = run([str(EXE), "package", "remove", "math-tools"], work)
|
||||
|
||||
@@ -22,7 +22,7 @@ def main() -> int:
|
||||
encoding="utf-8",
|
||||
)
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
|
||||
@@ -22,7 +22,7 @@ def main() -> int:
|
||||
script.write_text((f'READ FILE "{quoted}" AS contents\n' * 2000) + 'SAY contents\n', encoding="utf-8")
|
||||
binary = tmp_path / "claro-asan"
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
|
||||
@@ -21,7 +21,7 @@ def main() -> int:
|
||||
encoding="utf-8",
|
||||
)
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
|
||||
@@ -21,7 +21,7 @@ def main() -> int:
|
||||
encoding="utf-8",
|
||||
)
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
|
||||
@@ -18,7 +18,7 @@ def main() -> int:
|
||||
script = tmp_path / "run_command_expressions.claro"
|
||||
script.write_text('RUN COMMAND "true" AS output\n' * 2000, encoding="utf-8")
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
|
||||
@@ -20,7 +20,7 @@ def main() -> int:
|
||||
with tempfile.TemporaryDirectory(prefix="runtime-error-cleanup-") as tmp:
|
||||
binary = Path(tmp) / "claro-asan"
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
|
||||
@@ -19,7 +19,7 @@ def main() -> int:
|
||||
script = tmp_path / "typecheck.claro"
|
||||
script.write_text("SET known TO 1\n" + "SAY known\n" * 2000, encoding="utf-8")
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined",
|
||||
"src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
|
||||
@@ -43,4 +43,4 @@ with tempfile.TemporaryDirectory() as td:
|
||||
run([str(local), "package", "remove", "text"], cwd=proj)
|
||||
run([str(local), "run"], cwd=proj)
|
||||
|
||||
print("Validation passed. Claro v2026.10.20.155641 networking reliability is ready for use.")
|
||||
print("Validation passed. Claro v2026.10.20.160950 networking reliability is ready for use.")
|
||||
|
||||
@@ -23,10 +23,10 @@ def compiler_cmd():
|
||||
env_cc = os.environ.get("CLARO_CC")
|
||||
if env_cc:
|
||||
parts = env_cc.split()
|
||||
return parts + ["-std=c99", "src/claro.c", "-O0", "-o", str(EXE), "-lm"]
|
||||
return parts + ["-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "src/claro.c", "-O0", "-o", str(EXE), "-lm"]
|
||||
if ZIG_CC.exists():
|
||||
return [str(ZIG_CC), "cc", "-std=c99", "src/claro.c", "-O0", "-o", str(EXE), "-lm"]
|
||||
return ["gcc", "-std=c99", "src/claro.c", "-O0", "-o", str(EXE), "-lm"]
|
||||
return [str(ZIG_CC), "cc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "src/claro.c", "-O0", "-o", str(EXE), "-lm"]
|
||||
return ["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "src/claro.c", "-O0", "-o", str(EXE), "-lm"]
|
||||
|
||||
|
||||
def build():
|
||||
@@ -37,11 +37,13 @@ def build():
|
||||
|
||||
def main():
|
||||
build()
|
||||
run([sys.executable, "tools/validate_c89.py"])
|
||||
out = run([str(EXE), "--version"])
|
||||
if "Claro v2026.10.20.155641" not in out:
|
||||
if "Claro v2026.10.20.160950" not in out:
|
||||
raise SystemExit("Wrong version string")
|
||||
run([str(EXE), "test"])
|
||||
run([str(EXE), "validate"])
|
||||
run([sys.executable, "tools/validate_first_hour.py"])
|
||||
run([sys.executable, "tools/validate_ide_metadata.py"])
|
||||
run([sys.executable, "tools/validate_lsp_helper.py"])
|
||||
run([sys.executable, "tools/validate_concurrency.py"])
|
||||
@@ -55,7 +57,7 @@ def main():
|
||||
run([sys.executable, "tools/validate_write_file_expression_cleanup.py"])
|
||||
run([sys.executable, "tools/validate_version_convention.py"])
|
||||
run([str(EXE), "examples/networking.claro"])
|
||||
print("v2026.10.20.155641 validation complete")
|
||||
print("v2026.10.20.160950 validation complete")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -7,7 +7,7 @@ from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
EXE = ROOT / "claro.exe"
|
||||
EXPECTED = "Claro v2026.10.20.155641"
|
||||
EXPECTED = "Claro v2026.10.20.160950"
|
||||
|
||||
|
||||
def fail(message):
|
||||
@@ -31,12 +31,12 @@ def main():
|
||||
if ide.returncode != 0:
|
||||
fail(ide.stdout)
|
||||
metadata = json.loads(ide.stdout)
|
||||
if metadata.get("version") != "v2026.10.20.155641":
|
||||
fail(f"Expected IDE metadata version 'v2026.10.20.155641', got {metadata.get('version')!r}")
|
||||
if metadata.get("version") != "v2026.10.20.160950":
|
||||
fail(f"Expected IDE metadata version 'v2026.10.20.160950', got {metadata.get('version')!r}")
|
||||
validator = ROOT / "tools" / "validate_v1_17.py"
|
||||
text = validator.read_text(encoding="utf-8")
|
||||
if "Claro v2026.10.20.155641" not in text:
|
||||
fail("tools/validate_v1_17.py must validate Claro v2026.10.20.155641")
|
||||
if "Claro v2026.10.20.160950" not in text:
|
||||
fail("tools/validate_v1_17.py must validate Claro v2026.10.20.160950")
|
||||
print("Version convention validation OK")
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ def main() -> int:
|
||||
script.write_text((f'WRITE FILE "{path}" WITH "hello"\n' * 2000), encoding="utf-8")
|
||||
binary = tmp_path / "claro-asan"
|
||||
build = subprocess.run(
|
||||
["gcc", "-std=c99", "-O0", "-g", "-fsanitize=address,undefined", "src/claro.c", "-o", str(binary), "-lm"],
|
||||
["gcc", "-std=c89", "-pedantic-errors", "-Werror=implicit-function-declaration", "-O0", "-g", "-fsanitize=address,undefined", "src/claro.c", "-o", str(binary), "-lm"],
|
||||
cwd=ROOT, text=True, capture_output=True,
|
||||
)
|
||||
if build.returncode:
|
||||
|
||||
Reference in New Issue
Block a user