| 1 | // vtest build: !msvc |
| 2 | // vtest flaky: true |
| 3 | // vtest retry: 1 |
| 4 | module gfx |
| 5 | |
| 6 | import os |
| 7 | |
| 8 | fn assert_program_panics(source string, expected string) { |
| 9 | source_path := os.join_path(os.temp_dir(), |
| 10 | 'sokol_gfx_make_image_requires_setup_${os.getpid()}.v') |
| 11 | os.write_file(source_path, source) or { panic(err) } |
| 12 | defer { |
| 13 | os.rm(source_path) or {} |
| 14 | } |
| 15 | res := os.execute('${os.quoted_path(@VEXE)} run ${os.quoted_path(source_path)}') |
| 16 | assert res.exit_code != 0, 'expected the test program to fail' |
| 17 | assert res.output.contains(expected), 'expected `${expected}` in `${res.output}`' |
| 18 | } |
| 19 | |
| 20 | fn test_make_image_requires_setup() { |
| 21 | assert_program_panics('import sokol.gfx |
| 22 | |
| 23 | fn main() { |
| 24 | mut desc := gfx.ImageDesc{} |
| 25 | _ = gfx.make_image(&desc) |
| 26 | } |
| 27 | ', |
| 28 | 'sokol.gfx is not initialized; call gfx.setup(...) before gfx.make_image(...)') |
| 29 | } |
| 30 | |