forked from 0cjs/8bitdev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest
executable file
·97 lines (83 loc) · 3.37 KB
/
Test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env bash
set -eu -o pipefail
die() {
local exitcode="$1"; shift
[[ -z $1 ]] || echo 1>&2 "$@"
exit $exitcode
}
# If $py is unset, set it to a reasonable default. Either way, confirm
# that it appears to be a Python 3 interpreter.
#
checkpy() {
: ${py:=python3}
# stderr not redirected here so user sees any error from run attempt.
"$py" --version >/dev/null || die 2 "Bad Python interpreter: $py"
local v=$("$py" --version 2>&1 | head -1)
[[ $v = 'Python 3.'* ]] || die 2 "Bad Python version: $v"
}
####################################################################
# Build functions
build_toolsets() {
[[ -f $all_tools ]] && $b8tool buildtoolset asxxxx
$b8tool buildtoolset asl
$b8tool buildtoolset diskimg
$b8tool buildtoolset dos33fs
$b8tool buildtoolset linapple
}
# ASxxxx builds
# Due to issues with 32-bit binaries, run only when $all_tools set.
build_asxxxx() {
[[ -f $all_tools ]] || return 0
# Though we don't need to explicitly specify `simple` as an input
# file for the link (aslink would get it from the output file) we
# do so anyway to test that b8tool handles it correctly.
$b8tool asx src/asxxxx/simple.a65
$b8tool asxlink src/asxxxx/simple simple
$b8tool asx src/asxxxx/reloctest.a65
$b8tool asxlink src/asxxxx/reloctest -- -b '_code=0x400'
$b8tool asx src/asxxxx/zptest.a65
$b8tool asxlink src/asxxxx/zptest -- -b '_code=0x0300'
}
####################################################################
# Main
export B8_PROJDIR=$(cd "$(dirname "$0")" && pwd -P)
export BUILDDIR="$B8_PROJDIR/.build"
all_tools="$B8_PROJDIR/.all-tools"
# Creating this file is useful to slightly speed the edit/build/test
# cycle when working on "regular" ASL code; the toolsets and asxxx builds
# are the majority of the wall clock time when running only a few tests.
# This file is never ignored or committed so `git status` will make it
# clear you're not building everything that might be changed.
# XXX This can go when we move more stuff into a single b8tool invocation.
fast_hack="$B8_PROJDIR/.fast-hack"
b8tool="$B8_PROJDIR/b8tool/bin/b8tool"
b8_plib="$B8_PROJDIR/b8tool/pylib" # used locally; not part of b8tool
# Leading command line args (these must be at the start):
# • -C: clean rebuild of everything, including toolchains
# • -c: clean rebuild of only this repo's source (test/toolchain output)
# • -A: build and use all tools
# All args after these are passed on to pytest.
while [[ ${#@} -gt 0 ]]; do case "$1" in
-C) shift; rm -rf "$BUILDDIR";;
-c) shift; rm -rf "$BUILDDIR"/{obj,ptobj,pytest};;
-A) shift; touch "$all_tools";;
-p) shift; py="$1"; shift;;
*) break;;
esac; done
checkpy; . $B8_PROJDIR/activate -q -p "$py"
[[ -f $fast_hack ]] || build_toolsets
[[ $PATH =~ ^$B8_PROJDIR/bin:|:$B8_PROJDIR/bin:|:$B8_PROJDIR/bin$ ]] \
|| export PATH="$B8_PROJDIR/bin:$PATH"
[[ -f $fast_hack ]] || build_asxxxx
$b8tool aslauto exe/ src/ --exclude=src/asxxxx/
# Top-level programs whose build is not triggered by automated tests.
$b8tool asl \
src/asl/nomacro.a65 \
exe/a1/charset.a65 \
src/a2/misc.a65 \
src/fm7.a69 \
exe/jr200/hello.a68 exe/jr200/pmon.a68 src/jr200/jr200.a68 \
exe/tmc68/hello.a68 exe/tmc68/pmon.a68 \
--
$b8tool a2dsk exe/a2/charset.a65
$b8tool pytest -- "$@"