@@ -116,23 +116,46 @@ fn test_diff_paths() {
116116 assert_eq ! ( t( "/foo/bar" , "/baz" ) , Some ( "../foo/bar" . into( ) ) ) ;
117117 assert_eq ! ( t( "foo" , "bar" ) , Some ( "../foo" . into( ) ) ) ;
118118
119- // If the `path` doesn't belong in the same crate, we should keep an absolute path.
120- assert_eq ! (
121- diff_paths(
122- Path :: new( "/askama-bugs/b/templates/empty.txt" ) ,
123- Path :: new( "/askama-bugs/a" ) ,
124- Some ( "/askama-bugs/b" . into( ) ) ,
125- ) ,
126- Some ( "/askama-bugs/b/templates/empty.txt" . into( ) ) ,
127- ) ;
119+ // Windows paths are a nightmare to test...
120+ if !cfg ! ( windows) {
121+ // If the `path` doesn't belong in the same crate, we should keep an absolute path.
122+ assert_eq ! (
123+ diff_paths(
124+ Path :: new( "/askama-bugs/b/templates/empty.txt" ) ,
125+ Path :: new( "/askama-bugs/a" ) ,
126+ Some ( "/askama-bugs/b" . into( ) ) ,
127+ ) ,
128+ Some ( "/askama-bugs/b/templates/empty.txt" . into( ) ) ,
129+ ) ;
128130
129- // If it's in the same crate, relative path should be returned.
130- assert_eq ! (
131- diff_paths(
132- Path :: new( "/askama-bugs/b/templates/empty.txt" ) ,
133- Path :: new( "/askama-bugs/b" ) ,
134- Some ( "/askama-bugs/b" . into( ) ) ,
135- ) ,
136- Some ( "templates/empty.txt" . into( ) ) ,
137- ) ;
131+ // If it's in the same crate, relative path should be returned.
132+ assert_eq ! (
133+ diff_paths(
134+ Path :: new( "/askama-bugs/b/templates/empty.txt" ) ,
135+ Path :: new( "/askama-bugs/b" ) ,
136+ Some ( "/askama-bugs/b" . into( ) ) ,
137+ ) ,
138+ Some ( "templates/empty.txt" . into( ) ) ,
139+ ) ;
140+ } else {
141+ // If the `path` doesn't belong in the same crate, we should keep an absolute path.
142+ assert_eq ! (
143+ diff_paths(
144+ Path :: new( "C:/askama-bugs/b/templates/empty.txt" ) ,
145+ Path :: new( "C:/askama-bugs/a" ) ,
146+ Some ( "C:/askama-bugs/b" . into( ) ) ,
147+ ) ,
148+ Some ( "C:/askama-bugs/b/templates/empty.txt" . into( ) ) ,
149+ ) ;
150+
151+ // If it's in the same crate, relative path should be returned.
152+ assert_eq ! (
153+ diff_paths(
154+ Path :: new( "C:/askama-bugs/b/templates/empty.txt" ) ,
155+ Path :: new( "C:/askama-bugs/b" ) ,
156+ Some ( "C:/askama-bugs/b" . into( ) ) ,
157+ ) ,
158+ Some ( "templates/empty.txt" . into( ) ) ,
159+ ) ;
160+ }
138161}
0 commit comments