Skip to content

Commit

Permalink
ci: test same examples as macOS (apk only for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
larpon committed Sep 29, 2024
1 parent 95704b4 commit 688cc8e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 35 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci_emulator_run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,8 @@ jobs:
vab --package-id "io.v.ci.vab.aab.deploytest" --name "V DEPLOY TEST AAB" --package aab v/examples/gg/bezier.v
v retry -r 2 -- vab v_deploy_test_aab.aab
# 'flappylearning' can build but running is currently broken on Android
# Skip fireworks for now
declare -a v_examples=('2048' 'tetris' 'sokol/particles' 'sokol/drawing.v' 'sokol/freetype_raven.v' 'gg/bezier.v' 'gg/bezier_anim.v' 'gg/polygons.v' 'gg/raven_text_rendering.v' 'gg/rectangles.v' 'gg/stars.v' 'gg/worker_thread.v')
declare -a v_examples=('2048' 'flappylearning' 'tetris' 'sokol/particles' 'sokol/drawing.v' 'sokol/freetype_raven.v' 'gg/bezier.v' 'gg/bezier_anim.v' 'gg/polygons.v' 'gg/raven_text_rendering.v' 'gg/rectangles.v' 'gg/stars.v' 'gg/worker_thread.v')
echo "Compiling V examples ${v_examples[@]}"
for example in "${v_examples[@]}"; do
Expand Down
2 changes: 1 addition & 1 deletion android/emulator/emulator.v
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub:
pub struct Options {
pub:
verbosity int
wipe_data bool = true
wipe_data bool
avd string
await_boot bool = true // will wait for the device to boot
visible bool // show emulator window on desktop
Expand Down
70 changes: 38 additions & 32 deletions tests/at-runtime/emulator/emulator_test.vv
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ const exe_dir = os.dir(os.real_path(os.executable()))

const test_dir_base = os.join_path(os.vtmp_dir(), 'vab', 'tests', 'runtime', 'emulator')
const vab_test_avd = 'vab_emulator_tests'
const test_v_examples = [
'2048',
'flappylearning',
'tetris',
'sokol/particles',
'sokol/drawing.v',
'sokol/freetype_raven.v',
'gg/bezier.v',
'gg/bezier_anim.v',
'gg/polygons.v',
'gg/raven_text_rendering.v',
'gg/rectangles.v',
'gg/stars.v',
'gg/worker_thread.v',
]

const env_is_managable = env.managable()

Expand All @@ -18,37 +33,31 @@ const is_ci = os.getenv('CI') != ''
fn test_run_on_emulator() {
ensure_env()

vab := vabxt.vabexe()

mut emu := emulator.make()!
emu.start(
verbosity: 3
await_boot: true
visible: !is_ci // show window on desktop
avd: vab_test_avd
wipe_data: true
visible: !is_ci // show window on desktop
avd: vab_test_avd
// acceleration: 'off'
)!
// start tests ...
// for _ in 0 .. 20 {
// if recv.try_pop(mut signal) == .success {
// if signal > -1 {
// println('emu exiting. code ${signal}')
// break
// }
// }
// println('Doing fake work')
// time.sleep(1000 * time.millisecond)
//
//
// }

vab, test_dir := setup(@FN)

vab_cmd := [vab, '--device', emu.name, 'run', v_example('2048'), '-o', test_dir]
res := run(vab_cmd)
if res.exit_code != 0 {
println('error: ${res.output}')
}

time.sleep(10000 * time.millisecond)
for example in test_v_examples {
test_dir := setup_test_dir('${@FN}_${os.file_name(example)}')
package_id := 'io.v.apk.v${example.replace('/', '.')}'
vab_cmd := [vab, '--package-id', package_id, '--device', emu.name, 'run', v_example(example),
'-o', test_dir]
res := run(vab_cmd)
if res.exit_code != 0 {
eprintln('error: ${res.output}')
assert false, 'Emulator test failed'
}

time.sleep(250 * time.millisecond)
}

emu.stop()
}
Expand Down Expand Up @@ -94,19 +103,16 @@ fn ensure_env() {
exit(1)
}
}
// vab (per design) implicitly deploys to any devices sat via `--device-id`.
// Make sure no deployment is done after build if CI/other sets `ANDROID_SERIAL`
os.unsetenv('ANDROID_SERIAL')
}

fn setup(id string) (string, string) {
fn setup_test_dir(id string) string {
test_dir := os.join_path(test_dir_base, id)
os.rm(test_dir) or {}
os.mkdir_all(test_dir) or { panic('mkdir_all failed making "${test_dir}": ${err}') }

// vab (per design) implicitly deploys to any devices sat via `--device-id`.
// Make sure no deployment is done after build if CI/other sets `ANDROID_SERIAL`
os.unsetenv('ANDROID_SERIAL')
vab := vabxt.vabexe()
assert vab != '', 'vab needs to be installed to run this test'
return vab, test_dir
return test_dir
}

fn v_example(path string) string {
Expand Down

0 comments on commit 688cc8e

Please sign in to comment.