Skip to content

Commit

Permalink
embed: better asset lookup for TestApp
Browse files Browse the repository at this point in the history
  • Loading branch information
larpon committed Sep 6, 2023
1 parent d1f58d6 commit 064af98
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions embed/embed.v
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ struct ExampleApp {
EasyApp
}

// asset unifies locating project assets
// asset unifies locating example project assets
pub fn (ea ExampleApp) asset(path string) string {
$if wasm32_emscripten {
return path
}
return os.resource_abs_path(os.join_path('..', '..', 'assets', path))
return os.join_path(@VMODROOT, 'assets', path)
}

/*
Expand Down Expand Up @@ -246,10 +246,21 @@ struct TestApp {
EasyApp
}

// asset unifies locating project assets
// asset unifies locating project assets for visually tested apps
pub fn (ta TestApp) asset(path string) string {
$if wasm32_emscripten {
return path
}
return os.resource_abs_path(os.join_path('..', '..', 'assets', path))

mut test_asset_path := os.join_path(@VMODROOT,'tests','visual','assets',path)
if !os.exists(test_asset_path) {
test_asset_path = os.join_path(@VMODROOT, 'assets', path)
}
if !os.exists(test_asset_path) {
test_asset_path = os.resource_abs_path(os.join_path('..', '..', 'tests','visual', 'assets', path))
}
if !os.exists(test_asset_path) {
test_asset_path = os.resource_abs_path(os.join_path('..', '..', 'assets', path))
}
return test_asset_path
}

0 comments on commit 064af98

Please sign in to comment.