File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,6 +9,16 @@ pub fn cargo_bundle_bin() -> PathBuf {
99 project_root ( ) . join ( "target/debug/cargo-bundle" )
1010}
1111
12+ #[ cfg( test) ]
13+ #[ allow( dead_code) ] // Used in tests
14+ pub fn parse_bundle_paths ( stdout : & str ) -> Vec < PathBuf > {
15+ stdout
16+ . lines ( )
17+ . filter ( |line| line. starts_with ( " " ) )
18+ . map ( |line| PathBuf :: from ( line. trim ( ) ) )
19+ . collect ( )
20+ }
21+
1222/// Places a valid-enough binary at `target/debug/examples/<name>` so that
1323/// cargo-bundle (running with CARGO_BUNDLE_SKIP_BUILD) has something to package.
1424pub fn setup_example_binary ( name : & str ) {
Original file line number Diff line number Diff line change @@ -55,27 +55,21 @@ fn deb() {
5555 String :: from_utf8_lossy( & output. stderr)
5656 ) ;
5757
58- let arch = if cfg ! ( target_arch = "x86_64" ) {
59- "amd64"
60- } else if cfg ! ( target_arch = "aarch64" ) {
61- "arm64"
62- } else {
63- "amd64"
64- } ;
65-
66- let deb_path = root. join ( format ! (
67- "target/debug/examples/bundle/deb/goodbye_0.9.1_{arch}.deb"
68- ) ) ;
58+ let bundle_paths = common:: parse_bundle_paths ( & String :: from_utf8_lossy ( & output. stdout ) ) ;
59+ assert_eq ! ( bundle_paths. len( ) , 1 , "Expected exactly one bundle path" ) ;
60+ let deb_path = & bundle_paths[ 0 ] ;
6961 assert ! (
7062 deb_path. exists( ) ,
7163 "Debian package not found at {:?}" ,
7264 deb_path
7365 ) ;
7466
7567 // The 128x128 PNG should have been placed in the hicolor icon tree.
76- let icon_path = root. join ( format ! (
77- "target/debug/examples/bundle/deb/goodbye_0.9.1_{arch}/data/usr/share/icons/hicolor/128x128/apps/goodbye.png"
78- ) ) ;
68+ let package_dir = deb_path
69+ . parent ( )
70+ . unwrap ( )
71+ . join ( deb_path. file_stem ( ) . unwrap ( ) ) ;
72+ let icon_path = package_dir. join ( "data/usr/share/icons/hicolor/128x128/apps/goodbye.png" ) ;
7973 assert ! (
8074 icon_path. exists( ) ,
8175 "PNG icon not found in deb data at {:?}" ,
Original file line number Diff line number Diff line change @@ -36,7 +36,6 @@ fn osx() {
3636}
3737
3838#[ test]
39- #[ cfg( target_os = "linux" ) ]
4039fn deb ( ) {
4140 common:: setup_example_binary ( "hello" ) ;
4241
@@ -55,27 +54,21 @@ fn deb() {
5554 String :: from_utf8_lossy( & output. stderr)
5655 ) ;
5756
58- let arch = if cfg ! ( target_arch = "x86_64" ) {
59- "amd64"
60- } else if cfg ! ( target_arch = "aarch64" ) {
61- "arm64"
62- } else {
63- "amd64"
64- } ;
65-
66- let deb_path = root. join ( format ! (
67- "target/debug/examples/bundle/deb/hello_0.9.1_{arch}.deb"
68- ) ) ;
57+ let bundle_paths = common:: parse_bundle_paths ( & String :: from_utf8_lossy ( & output. stdout ) ) ;
58+ assert_eq ! ( bundle_paths. len( ) , 1 , "Expected exactly one bundle path" ) ;
59+ let deb_path = & bundle_paths[ 0 ] ;
6960 assert ! (
7061 deb_path. exists( ) ,
7162 "Debian package not found at {:?}" ,
7263 deb_path
7364 ) ;
7465
7566 // SVG should be copied to the scalable hicolor directory.
76- let svg_path = root. join ( format ! (
77- "target/debug/examples/bundle/deb/hello_0.9.1_{arch}/data/usr/share/icons/hicolor/scalable/apps/hello.svg"
78- ) ) ;
67+ let package_dir = deb_path
68+ . parent ( )
69+ . unwrap ( )
70+ . join ( deb_path. file_stem ( ) . unwrap ( ) ) ;
71+ let svg_path = package_dir. join ( "data/usr/share/icons/hicolor/scalable/apps/hello.svg" ) ;
7972 assert ! (
8073 svg_path. exists( ) ,
8174 "SVG icon not found in deb data at {:?}" ,
You can’t perform that action at this time.
0 commit comments