Skip to content

Commit

Permalink
make version 0.2.6b the default, add cmdline opts for setting cart ve…
Browse files Browse the repository at this point in the history
…rsion, make all tests always output the latest version, except for a new old-version test. Also, include the bbs tests list in the repo.
  • Loading branch information
thisismypassport committed Apr 18, 2024
1 parent a146c78 commit 3df4909
Show file tree
Hide file tree
Showing 66 changed files with 165 additions and 64 deletions.
58 changes: 58 additions & 0 deletions bbs_tests.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
9983
10388
11722
12502
12682
13057
15116
18483
20407
21098
24899
26851
33331
41037
42655
43229
44028
47025
59366
59497
59509
66786
66935
69899
72921
75108
75741
78599
82023
83367
85620
86280
89823
89915
90020
91453
94408
96334
97636
100973
101541
103651
107459
109575
109673
109822
112308
112740
112916
114060
114663
115136
116823
116846
119614
131586
132559
142353
7 changes: 5 additions & 2 deletions pico_cart.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def set_code_without_title(m, code):
if old_title != m.title:
m.title = old_title

def set_version(m, id):
m.version_id = id
m.version_tuple = get_version_tuple(id)

def read_code_from_rom(r, keep_compression=False, **opts):
code_rom = None
if keep_compression:
Expand Down Expand Up @@ -390,8 +394,7 @@ def ext_nybbles(line):
cart.meta[header[len(k_meta_prefix):]].append(line.rstrip('\n'))

elif header == None and clean.startswith("version "):
cart.version_id = int(clean.split()[1])
cart.version_tuple = get_version_tuple(cart.version_id)
cart.set_version(int(clean.split()[1]))

except Exception as e:
throw(f"Invalid {header} line in p8 file (line #{line_i + 1})")
Expand Down
3 changes: 2 additions & 1 deletion pico_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,11 @@ def fixnum_to_num(value):
}

def get_default_version_id():
version_id = 41 # TODO - update as newer versions get more common
version_id = 42 # TODO - update as newer versions get more common
return maybe_int(os.getenv("PICO8_VERSION_ID"), version_id)

def get_default_platform():
# there's also 'E' for either Emscripten or Education
platform = 'w' if os.name == 'nt' else 'x' if sys.platform == 'darwin' else 'l'
return os.getenv("PICO8_PLATFORM_CHAR", platform)

Expand Down
9 changes: 7 additions & 2 deletions run_bbs_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def CommaSep(val):

parser = argparse.ArgumentParser()
parser.add_argument("-c", "--carts", type=CommaSep, help="specify a specific cart or carts to run on (overrides -f)")
parser.add_argument("-f", "--carts-file", help="specify which carts to run on via a file", default="private_bbs_tests.lst")
parser.add_argument("-f", "--carts-file", help="specify which carts to run on via a file", default="bbs_tests.lst")
parser.add_argument("-n", "--new-only", action="store_true", help="only test new carts")
parser.add_argument("--input-redownload", action="store_true", help="download the carts again")
parser.add_argument("--input-reprocess", action="store_true", help="process the downloaded carts again (count sizes and convert to p8)")
Expand All @@ -26,6 +26,7 @@ def CommaSep(val):
parser.add_argument("-oa", "--focus-all", action="store_true", help="test all focuses")
parser.add_argument("-i", "--compare-input", action="store_true", help="compare results vs the inputs too")
parser.add_argument("-u", "--compare-unfocused", action="store_true", help="compare results vs the unfocused results too")
parser.add_argument("--no-update", action="store_true", help="do not update carts to latest version")
parser.add_argument("-v", "--verbose", action="store_true", help="print changes in individual carts")
parser.add_argument("-x", "--exe", action="store_true", help="use a packaged exe instead of the python script")
parser.add_argument("-p", "--pico8", action="append", help="specify a pico8 exe to test the results with")
Expand Down Expand Up @@ -207,7 +208,11 @@ def process_output(kind, output):
process_output("compress", check_run(f"{cart}:compress", compress_results, parse_meta=True))
best_path_for_pico8 = compress_path

minify_opts = [f"--focus-{focus}"] if focus else []
minify_opts = []
if focus:
minify_opts.append(f"--focus-{focus}")
if not g_opts.no_update:
minify_opts.append("--update-version")

if g_opts.all or g_opts.only_safe_minify:
safe_minify_results = run_code(uncompress_path, safe_minify_path, "--minify-safe-only", "--count", "--parsable-count", *minify_opts)
Expand Down
18 changes: 11 additions & 7 deletions run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
# for test consistency:
os.environ["PICO8_EXPORT_REPRO_TIME"] = '1577934245'
os.environ["PICO8_PLATFORM_CHAR"] = 'w'
#os.environ["PICO8_VERSION_ID"] = ... - best test the version we set by default

def norm_paths(output):
return output.replace("\\", "/")
Expand All @@ -43,7 +42,7 @@ def try_read_dir_contents(dir):

def run_test(name, input, output, *args, private=False, check_output=True, from_output=False,
stdout_output=None, norm_stdout=nop, exit_code=0, extra_outputs=None, output_reader=try_file_read,
pico8_output_val=None, pico8_output=None, pico8_run=None, copy_in_to_out=False):
pico8_output_val=None, pico8_output=None, pico8_run=None, copy_in_to_out=False, update_version=True):
if g_opts.test:
for wanted_test in g_opts.test:
if fnmatch.fnmatch(name, wanted_test):
Expand All @@ -66,6 +65,9 @@ def run_test(name, input, output, *args, private=False, check_output=True, from_
if copy_in_to_out:
file_write(outpath, file_read(path_join(path_dirname(inpath), output)))

if update_version:
args += ("--update-version",)

if not input:
args = (outpath,) + args
elif not output:
Expand Down Expand Up @@ -196,26 +198,26 @@ def run():
run_test("p82url", "test.url.p8", "test.url", from_output=True)
run_test("default", "default.p8", "default.rom")
run_test("default2", "default2.p8", "default2.rom")
run_test("genend", "genend.p8.png", "genend.p8")
run_test("genend", "genend.p8.png", "genend.p8", update_version=False)
run_test("lint", "bad.p8", None, "--lint", stdout_output="bad.txt", norm_stdout=norm_paths, exit_code=2)
run_test("linttab", "bad.p8", None, "--lint", "--error-format", "tabbed",
stdout_output="bad-tab.txt", norm_stdout=norm_paths, exit_code=2)
run_test("count", "bad.p8", None, "--count", stdout_output="badcount.txt")
run_test("countminus", "minus.p8", None, "--count", stdout_output="minuscount.txt")
run_test("error", "worse.p8", None, "--lint", stdout_output="worse.txt", norm_stdout=norm_paths, exit_code=1)
run_test("script", "script.p8", "script.p8", "--script", path_join("test_input", "my_script.py"),
"--script-args", "my-script-arg", "--my-script-opt", "123")
"--update-version", "--script-args", "my-script-arg", "--my-script-opt", "123", update_version=False)
run_test("sublang.lint", "sublang.p8", None, "--lint",
"--script", path_join("test_input", "sublang.py"), stdout_output="sublang.txt", norm_stdout=norm_paths, exit_code=2)
run_test("sublang", "sublang.p8", "sublang.p8", "--minify",
"--script", path_join("test_input", "sublang.py"))
run_test("unkform1", "unkform1", "unkform1")
run_test("unkform2", "unkform2.png", "unkform2", "--format", "png", "--input-format", "auto")
run_test("unkform1", "unkform1", "unkform1", update_version=False)
run_test("unkform2", "unkform2.png", "unkform2", "--format", "png", "--input-format", "auto", update_version=False)
run_test("mini", "mini.p8", "mini.p8", "--minify", "--no-minify-lines", "--no-minify-consts",
"--builtin", "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z",
"--local-builtin", "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z")
run_test("tinyrom", "tiny.rom", "tiny.lua")
run_test("title", "title.p8", "title.p8.png")
run_test("title", "title.p8", "title.p8.png", update_version=False)
if run_test("repl", "repl.p8", "repl.p8", "--minify",
"--rename-map", "test_output/repl.map", extra_outputs=["repl.map"], pico8_output_val="finished"):
run_test("unminrepl", "repl.p8", "repl-un.p8", "--unminify", from_output=True, pico8_output_val="finished")
Expand All @@ -237,6 +239,8 @@ def run():
run_test("short-lines", "short.p8", "short-lines.p8", "-m", "--no-minify-consts", "--no-minify-lines", "--focus-chars", pico8_output_val="K\nK")
run_test("short-spaces", "short.p8", "short-spaces.p8", "-m", "--no-minify-consts", "--no-minify-spaces", "--focus-chars", pico8_output_val="K\nK")
run_test("short2", "short2.p8", "short2.p8", "-m", "--no-minify-consts", "--focus-compressed", "--no-minify-spaces")
run_test("version-latest", "versioned.p8", "versioned-latest.p8", "-m", "-oc", pico8_output="versioned.p8.printh")
run_test("version-orig", "versioned.p8", "versioned-orig.p8", "-m", "-oc", update_version=False, pico8_output="versioned.p8.printh")

def main(raw_args):
global g_opts
Expand Down
10 changes: 9 additions & 1 deletion shrinko8.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
from pico_export import read_cart_export, read_pod_file, ListOp
from pico_tokenize import k_hint_split_re
from pico_constfold import parse_constant
from pico_defs import get_default_version_id
import argparse

k_version = 'v1.2.0c'
k_version = 'v1.2.1'

def SplitBySeps(val):
return k_hint_split_re.split(val)
Expand Down Expand Up @@ -107,6 +108,8 @@ def ParsableCountHandler(prefix, name, size, limit):
pgroup.add_argument("--template-only", action="store_true", help="when creating the png cart, ignore the label & title, using just the template")
pgroup.add_argument("--dump-misc-too", action="store_true", help="causes --dump to also dump misc. files inside the export")
pgroup.add_argument("--version", action="store_true", help="print version of cart. (if no cart is provided - print shrinko8 version and exit)")
pgroup.add_argument("--output-version", type=int, help="the version to convert the cart to. (Same as 'version' field of p8 files)")
pgroup.add_argument("--update-version", action="store_true", help="convert the cart to the highest supported version")
pgroup.add_argument("--bbs", action="store_true", help="interpret input as a bbs cart id, e.g. '#...' and download it from the bbs")
pgroup.add_argument("--url", action="store_true", help="interpret input as a URL, and download it from the internet")

Expand Down Expand Up @@ -363,6 +366,11 @@ def handle_processing(args, main_cart, extra_carts):
had_warns = False

for cart in itertools.chain((main_cart,), extra_carts):
if args.update_version:
cart.set_version(get_default_version_id())
elif e(args.output_version):
cart.set_version(args.output_version)

src = CartSource(cart)

if args.input_count:
Expand Down
2 changes: 1 addition & 1 deletion test_compare/const.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 36
version 42
__lua__
stop() -- for pure syntax check
-- neg
Expand Down
2 changes: 1 addition & 1 deletion test_compare/const2.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 36
version 42
__lua__
stop() -- for pure syntax check
_ENV["min"]=123
Expand Down
2 changes: 1 addition & 1 deletion test_compare/constcl-1.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 41
version 42
__lua__
?"debug version v1.2"
n=0function _update()n+=1.25?n
Expand Down
2 changes: 1 addition & 1 deletion test_compare/constcl-2.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 41
version 42
__lua__
?"debug version "..(e or"???")
n=0function _update()n+=-1.3?-2
Expand Down
2 changes: 1 addition & 1 deletion test_compare/constcl.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 41
version 42
__lua__
if e then?"debug version "..(i or"???")
end n=0function _update()n+=.25?n
Expand Down
2 changes: 1 addition & 1 deletion test_compare/constmin.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 36
version 42
__lua__
stop()?0
?-1
Expand Down
2 changes: 1 addition & 1 deletion test_compare/globasmemb.p8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pico-8 cartridge // http://www.pico-8.com
version 41
version 42
__lua__
_ENV=setmetatable({print=1,O=2},{__index=_ENV})assert(print+O==3,1)K=_ENV assert(K.O==2,2)printh"OK"
2 changes: 1 addition & 1 deletion test_compare/input-reformat.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 41
version 42
__lua__

print = printh
Expand Down
2 changes: 1 addition & 1 deletion test_compare/input-un.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 41
version 42
__lua__

print = printh
Expand Down
2 changes: 1 addition & 1 deletion test_compare/merged.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 41
version 42
__lua__
for i=0,0x42ff do
if peek(i) != 0 then
Expand Down
2 changes: 1 addition & 1 deletion test_compare/mini.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 41
version 42
__lua__
function A(n,f,i,o,d,e,u,c,t,r,a,g,h,j,k,l,m,p,q,s,v,w,y,z)
n=0f=0i=0o=0d=0e=0u=0c=0t=0r=0a=0g=0h=0j=0k=0l=0m=0p=0q=0s=0v=0w=0y=0z=0
Expand Down
2 changes: 1 addition & 1 deletion test_compare/nopreserve.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 41
version 42
__lua__
n,i=circfill,rectfill circfill,rectfill=nil n(120,126,3)n(126,120,3)i(120,120,123,123)i(123,123,126,126)printh"yep"
__meta:title__
Expand Down
2 changes: 1 addition & 1 deletion test_compare/notnil.p8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pico-8 cartridge // http://www.pico-8.com
version 41
version 42
__lua__
assert(l==nil,0)assert(n==nil,1)assert(i==nil,2)assert(a==nil,3)assert(s==nil,4)assert(o==nil,5)assert(c==nil,6)assert(p==nil,7)assert(e==nil,8)assert(d==nil,9)assert(b==nil,10)assert(f==nil,11)assert(g==nil,12)assert(h==nil,13)assert(j==nil,14)assert(k==nil,15)assert(m==nil,16)assert(q==nil,17)assert(r==nil,18)assert(u==nil,19)assert(v==nil,20)assert(w==nil,21)assert(x==nil,22)assert(y==nil,23)assert(z==nil,24)assert(A==nil,25)local l=pack(1,nil)assert(l.l==nil,100)assert(l.i==nil,101)assert(l.a==nil,102)assert(l.s==nil,103)assert(l.o==nil,104)assert(l.c==nil,105)assert(l.p==nil,106)assert(l.e==nil,107)assert(l.d==nil,108)assert(l.b==nil,109)assert(l.f==nil,110)assert(l.g==nil,111)assert(l.h==nil,112)assert(l.j==nil,113)assert(l.k==nil,114)assert(l.m==nil,115)assert(l.q==nil,116)assert(l.r==nil,117)assert(l.t==nil,118)assert(l.u==nil,119)assert(l.v==nil,120)assert(l.w==nil,121)assert(l.x==nil,122)assert(l.y==nil,123)assert(l.z==nil,124)assert(l.A==nil,125)printh"passed"
2 changes: 1 addition & 1 deletion test_compare/output-simp.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 41
version 42
__lua__
print=printh?"hello ᶜ7there♥ら"
🐱,u,h,s,k,y,l,l=11,12,13,14,15,16,17,17t(stat(band()))-- this one comment, i do want!
Expand Down
2 changes: 1 addition & 1 deletion test_compare/output.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 41
version 42
__lua__
print=printh?"hello ᶜ7there♥ら"
🐱,a,h,u,s,x,e,e=11,12,13,14,15,16,17,17t(stat(band()))-- this one comment, i do want!
Expand Down
2 changes: 1 addition & 1 deletion test_compare/output_min.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 41
version 42
__lua__
print=printh
?"hello ᶜ7there♥ら"
Expand Down
2 changes: 1 addition & 1 deletion test_compare/output_minrename-ih.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 41
version 42
__lua__
print=printh?"hello ᶜ7there♥ら"
🐱,あ,ョ,◝,゛,゜,F,F=11,12,13,14,15,16,17,17t(stat(band()))t()x=0 b=0 b=0print"this is included"?"#[disable[[this for now/ever]]]"
Expand Down
2 changes: 1 addition & 1 deletion test_compare/output_minrename-ob.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 41
version 42
__lua__
print=printh?"hello ᶜ7there♥ら"
🐱,あ,ョ,◝,゛,゜,F,F=11,12,13,14,15,16,17,17t(stat(band()))t()x=0 b=0 b=0print"this is included"?"#[disable[[this for now/ever]]]"
Expand Down
2 changes: 1 addition & 1 deletion test_compare/output_minrename-oc.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 41
version 42
__lua__
print=printh?"hello ᶜ7there♥ら"
🐱,あ,ョ,◝,゛,゜,F,F=11,12,13,14,15,16,17,17t(stat(band()))t()x=0 b=0 b=0print"this is included"?"#[disable[[this for now/ever]]]"
Expand Down
2 changes: 1 addition & 1 deletion test_compare/output_minrename.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 41
version 42
__lua__
print=printh?"hello ᶜ7there♥ら"
🐱,あ,ョ,◝,゛,゜,F,F=11,12,13,14,15,16,17,17t(stat(band()))-- this one comment, i do want!
Expand Down
2 changes: 1 addition & 1 deletion test_compare/output_semiob.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 41
version 42
__lua__
print=printh
?"hello ᶜ7there♥ら"
Expand Down
2 changes: 1 addition & 1 deletion test_compare/output_tokens.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 41
version 42
__lua__
print=printh -- note: most of this test is NOT covered in print/printh - check output as well (as always)

Expand Down
2 changes: 1 addition & 1 deletion test_compare/reorder.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 41
version 42
__lua__
d=time
do local o,n,c,l=1,2,4assert(l==nil)printh(o..n..c)end
Expand Down
2 changes: 1 addition & 1 deletion test_compare/reorder_safe.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 41
version 42
__lua__
sep=time
do local o,n,c,l=1,2,4assert(l==nil)printh(o..n..c)end
Expand Down
2 changes: 1 addition & 1 deletion test_compare/reorder_safe_2.p8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pico-8 cartridge // http://www.pico-8.com
version 41
version 42
__lua__
d=time
do local o,n,c,l=1,2,4assert(l==nil)printh(o..n..c)end
Expand Down
Loading

0 comments on commit 3df4909

Please sign in to comment.