@@ -45,18 +45,62 @@ describe('Publish Build Artifacts Suite', function () {
4545 if ( os . platform ( ) == 'win32' ) {
4646 it ( 'Publish to UNC' , ( done : MochaDone ) => {
4747 setResponseFile ( 'publishBuildArtifactsGood.json' ) ;
48-
48+
4949 let tr = new trm . TaskRunner ( 'PublishBuildArtifacts' , false , true ) ;
50- tr . setInput ( 'PathtoPublish' , '/bin/release' ) ;
50+ tr . setInput ( 'PathtoPublish' , 'C:\\bin\\release' ) ;
51+ tr . setInput ( 'ArtifactName' , 'drop' ) ;
52+ tr . setInput ( 'ArtifactType' , 'FilePath' ) ;
53+ tr . setInput ( 'TargetPath' , '\\\\UNCShare\\subdir' ) ;
54+
55+ tr . run ( )
56+ . then ( ( ) => {
57+ assert ( ! tr . stderr , 'should not have written to stderr. error: ' + tr . stderr ) ;
58+ assert ( tr . succeeded , 'task should have succeeded' ) ;
59+ assert ( tr . stdout . indexOf ( 'test stdout from robocopy (no trailing slashes)' ) >= 0 , 'should copy files.' ) ;
60+ assert ( tr . stdout . search ( / a r t i f a c t .a s s o c i a t e / gi) >= 0 , 'should associate artifact.' ) ;
61+ done ( ) ;
62+ } )
63+ . fail ( ( err ) => {
64+ done ( err ) ;
65+ } ) ;
66+ } )
67+
68+ it ( 'Appends . to robocopy source with trailing slash' , ( done : MochaDone ) => {
69+ setResponseFile ( 'publishBuildArtifactsGood.json' ) ;
70+
71+ let tr = new trm . TaskRunner ( 'PublishBuildArtifacts' , false , true ) ;
72+ tr . setInput ( 'PathtoPublish' , 'C:\\bin\\release\\' ) ;
73+ tr . setInput ( 'ArtifactName' , 'drop' ) ;
74+ tr . setInput ( 'ArtifactType' , 'FilePath' ) ;
75+ tr . setInput ( 'TargetPath' , '\\\\UNCShare\\subdir' ) ;
76+
77+ tr . run ( )
78+ . then ( ( ) => {
79+ assert ( ! tr . stderr , 'should not have written to stderr. error: ' + tr . stderr ) ;
80+ assert ( tr . succeeded , 'task should have succeeded' ) ;
81+ assert ( tr . stdout . indexOf ( 'test stdout from robocopy (source with trailing slash)' ) >= 0 , 'should copy files.' ) ;
82+ assert ( tr . stdout . search ( / a r t i f a c t .a s s o c i a t e / gi) >= 0 , 'should associate artifact.' ) ;
83+ done ( ) ;
84+ } )
85+ . fail ( ( err ) => {
86+ done ( err ) ;
87+ } ) ;
88+ } )
89+
90+ it ( 'Appends . to robocopy target with trailing slash' , ( done : MochaDone ) => {
91+ setResponseFile ( 'publishBuildArtifactsGood.json' ) ;
92+
93+ let tr = new trm . TaskRunner ( 'PublishBuildArtifacts' , false , true ) ;
94+ tr . setInput ( 'PathtoPublish' , 'C:\\bin\\release' ) ;
5195 tr . setInput ( 'ArtifactName' , 'drop' ) ;
5296 tr . setInput ( 'ArtifactType' , 'FilePath' ) ;
5397 tr . setInput ( 'TargetPath' , '\\\\UNCShare' ) ;
54-
98+
5599 tr . run ( )
56100 . then ( ( ) => {
57101 assert ( ! tr . stderr , 'should not have written to stderr. error: ' + tr . stderr ) ;
58102 assert ( tr . succeeded , 'task should have succeeded' ) ;
59- assert ( tr . stdout . match ( / t e s t s t d o u t f r o m r o b o c o p y / gi ) . length === 1 , 'should copy files.' ) ;
103+ assert ( tr . stdout . indexOf ( ' test stdout from robocopy (target with trailing slash)' ) >= 0 , 'should copy files.' ) ;
60104 assert ( tr . stdout . search ( / a r t i f a c t .a s s o c i a t e / gi) >= 0 , 'should associate artifact.' ) ;
61105 done ( ) ;
62106 } )
@@ -69,10 +113,10 @@ describe('Publish Build Artifacts Suite', function () {
69113 setResponseFile ( 'publishBuildArtifactsBad.json' ) ;
70114
71115 let tr = new trm . TaskRunner ( 'PublishBuildArtifacts' , false , true ) ;
72- tr . setInput ( 'PathtoPublish' , '/ bin/ release' ) ;
116+ tr . setInput ( 'PathtoPublish' , 'C:\\ bin\\ release' ) ;
73117 tr . setInput ( 'ArtifactName' , 'drop' ) ;
74118 tr . setInput ( 'ArtifactType' , 'FilePath' ) ;
75- tr . setInput ( 'TargetPath' , '\\\\UNCShare' ) ;
119+ tr . setInput ( 'TargetPath' , '\\\\UNCShare\\subdir ' ) ;
76120
77121 tr . run ( )
78122 . then ( ( ) => {
@@ -90,16 +134,16 @@ describe('Publish Build Artifacts Suite', function () {
90134 setResponseFile ( 'publishBuildArtifactsGood.json' ) ;
91135
92136 let tr = new trm . TaskRunner ( 'PublishBuildArtifacts' , false , true ) ;
93- tr . setInput ( 'PathtoPublish' , '/ bin/ release' ) ;
137+ tr . setInput ( 'PathtoPublish' , 'C:\\ bin\\ release' ) ;
94138 tr . setInput ( 'ArtifactName' , 'drop' ) ;
95139 tr . setInput ( 'ArtifactType' , 'FilePath' ) ;
96- tr . setInput ( 'TargetPath' , '\\\\UNCShare' ) ;
140+ tr . setInput ( 'TargetPath' , '\\\\UNCShare\\subdir ' ) ;
97141
98142 tr . run ( )
99143 . then ( ( ) => {
100144 assert ( ! tr . stderr , 'should not have written to stderr. error: ' + tr . stderr ) ;
101145 assert ( tr . succeeded , 'task should have succeeded' ) ;
102- assert ( tr . stdout . indexOf ( '##vso[artifact.associate artifacttype=filepath;artifactname=drop;artifactlocation=\\\\UNCShare;]\\\\UNCShare' ) >= 0 , 'should associate artifact.' ) ;
146+ assert ( tr . stdout . indexOf ( '##vso[artifact.associate artifacttype=filepath;artifactname=drop;artifactlocation=\\\\UNCShare\\subdir ;]\\\\UNCShare\\subdir ' ) >= 0 , 'should associate artifact.' ) ;
103147 done ( ) ;
104148 } )
105149 . fail ( ( err ) => {
@@ -115,7 +159,7 @@ describe('Publish Build Artifacts Suite', function () {
115159 tr . setInput ( 'PathtoPublish' , '/bin/release' ) ;
116160 tr . setInput ( 'ArtifactName' , 'drop' ) ;
117161 tr . setInput ( 'ArtifactType' , 'FilePath' ) ;
118- tr . setInput ( 'TargetPath' , '\\\\UNCShare' ) ;
162+ tr . setInput ( 'TargetPath' , '\\\\UNCShare\\subdir ' ) ;
119163
120164 tr . run ( )
121165 . then ( ( ) => {
0 commit comments