@@ -521,27 +521,33 @@ func TestCompileCommands(t *testing.T) {
521521 require .True (t , paths .New (test1 ).Join ("Test1.arduino.avr.nano.hex" ).Exist ())
522522
523523 // Build sketch with --output path
524- require .NoError (t , os .Chdir (tmp ))
525- exitCode , d = executeWithArgs (t , "compile" , "-b" , "arduino:avr:nano" , "-o" , "test" , test1 )
526- require .Zero (t , exitCode , "exit code" )
527- require .Contains (t , string (d ), "Sketch uses" )
528- require .True (t , paths .New ("test.hex" ).Exist ())
529-
530- exitCode , d = executeWithArgs (t , "compile" , "-b" , "arduino:avr:nano" , "-o" , "test2.hex" , test1 )
531- require .Zero (t , exitCode , "exit code" )
532- require .Contains (t , string (d ), "Sketch uses" )
533- require .True (t , paths .New ("test2.hex" ).Exist ())
534- require .NoError (t , paths .New (tmp , "anothertest" ).MkdirAll ())
535-
536- exitCode , d = executeWithArgs (t , "compile" , "-b" , "arduino:avr:nano" , "-o" , "anothertest/test" , test1 )
537- require .Zero (t , exitCode , "exit code" )
538- require .Contains (t , string (d ), "Sketch uses" )
539- require .True (t , paths .New ("anothertest" , "test.hex" ).Exist ())
540-
541- exitCode , d = executeWithArgs (t , "compile" , "-b" , "arduino:avr:nano" , "-o" , tmp + "/anothertest/test2" , test1 )
542- require .Zero (t , exitCode , "exit code" )
543- require .Contains (t , string (d ), "Sketch uses" )
544- require .True (t , paths .New ("anothertest" , "test2.hex" ).Exist ())
524+ {
525+ pwd , err := os .Getwd ()
526+ require .NoError (t , err )
527+ defer func () { require .NoError (t , os .Chdir (pwd )) }()
528+ require .NoError (t , os .Chdir (tmp ))
529+
530+ exitCode , d = executeWithArgs (t , "compile" , "-b" , "arduino:avr:nano" , "-o" , "test" , test1 )
531+ require .Zero (t , exitCode , "exit code" )
532+ require .Contains (t , string (d ), "Sketch uses" )
533+ require .True (t , paths .New ("test.hex" ).Exist ())
534+
535+ exitCode , d = executeWithArgs (t , "compile" , "-b" , "arduino:avr:nano" , "-o" , "test2.hex" , test1 )
536+ require .Zero (t , exitCode , "exit code" )
537+ require .Contains (t , string (d ), "Sketch uses" )
538+ require .True (t , paths .New ("test2.hex" ).Exist ())
539+ require .NoError (t , paths .New (tmp , "anothertest" ).MkdirAll ())
540+
541+ exitCode , d = executeWithArgs (t , "compile" , "-b" , "arduino:avr:nano" , "-o" , "anothertest/test" , test1 )
542+ require .Zero (t , exitCode , "exit code" )
543+ require .Contains (t , string (d ), "Sketch uses" )
544+ require .True (t , paths .New ("anothertest" , "test.hex" ).Exist ())
545+
546+ exitCode , d = executeWithArgs (t , "compile" , "-b" , "arduino:avr:nano" , "-o" , tmp + "/anothertest/test2" , test1 )
547+ require .Zero (t , exitCode , "exit code" )
548+ require .Contains (t , string (d ), "Sketch uses" )
549+ require .True (t , paths .New ("anothertest" , "test2.hex" ).Exist ())
550+ }
545551}
546552
547553func TestInvalidCoreURL (t * testing.T ) {
0 commit comments