File tree Expand file tree Collapse file tree 3 files changed +24
-4
lines changed
Expand file tree Collapse file tree 3 files changed +24
-4
lines changed Original file line number Diff line number Diff line change 1111
1212jobs :
1313 build :
14+ strategy :
15+ matrix :
16+ os : [ubuntu-latest, windows-latest]
1417
15- runs-on : ubuntu-latest
18+ runs-on : ${{ matrix.os }}
1619
1720 steps :
1821 - uses : actions/checkout@v2
Original file line number Diff line number Diff line change @@ -14,3 +14,6 @@ all-features = true
1414
1515[dependencies ]
1616camino = { version = " 1.0.5" , optional = true }
17+
18+ [dev-dependencies ]
19+ cfg-if = " 1.0.0"
Original file line number Diff line number Diff line change @@ -82,6 +82,8 @@ mod utf8_paths {
8282
8383 /// Construct a relative UTF-8 path from a provided base directory path to the provided path.
8484 ///
85+ /// Requires the `camino` feature.
86+ ///
8587 /// ```rust
8688 /// # extern crate camino;
8789 /// use camino::*;
@@ -152,12 +154,24 @@ pub use crate::utf8_paths::*;
152154#[ cfg( test) ]
153155mod tests {
154156 use super :: * ;
157+ use cfg_if:: cfg_if;
155158
156159 #[ test]
157160 fn test_absolute ( ) {
158- assert_diff_paths ( "/foo" , "/bar" , Some ( "../foo" ) ) ;
159- assert_diff_paths ( "/foo" , "bar" , Some ( "/foo" ) ) ;
160- assert_diff_paths ( "foo" , "/bar" , None ) ;
161+ fn abs ( path : & str ) -> String {
162+ // Absolute paths look different on Windows vs Unix.
163+ cfg_if ! {
164+ if #[ cfg( windows) ] {
165+ format!( "C:\\ {}" , path)
166+ } else {
167+ format!( "/{}" , path)
168+ }
169+ }
170+ }
171+
172+ assert_diff_paths ( & abs ( "foo" ) , & abs ( "bar" ) , Some ( "../foo" ) ) ;
173+ assert_diff_paths ( & abs ( "foo" ) , "bar" , Some ( & abs ( "foo" ) ) ) ;
174+ assert_diff_paths ( "foo" , & abs ( "bar" ) , None ) ;
161175 assert_diff_paths ( "foo" , "bar" , Some ( "../foo" ) ) ;
162176 }
163177
You can’t perform that action at this time.
0 commit comments