File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,19 @@ func Commands(t *testing.T, exp ...*Expectation) {
6666
6767		// Create the command using the next level of middleware. (Which is 
6868		// probably eventually os/exec.CommandContext().) 
69- 		cmd  :=  previous (ctx , name , arg ... )
69+ 		// 
70+ 		// The prepending of ./ to the command name looks completely insane, but 
71+ 		// there's a reason for it: if the name is a bare string like `docker`, 
72+ 		// then Go will attempt to resolve it using $PATH. If the command 
73+ 		// doesn't exist (because, say, we're running it in CI), then an error 
74+ 		// is embedded within the *Cmd that will be returned when it is run, 
75+ 		// even if we've subsequently rewritten the Path and Args fields to be 
76+ 		// valid. 
77+ 		// 
78+ 		// Prepending ./ means that Go doesn't need to look the command up in 
79+ 		// the $PATH and no error can be generated that way. Since we're going 
80+ 		// to overwrite the Path momentarily anyway, that's fine. 
81+ 		cmd  :=  previous (ctx , "./" + name , arg ... )
7082		if  cmd  ==  nil  {
7183			t .Fatalf ("unexpected nil *Cmd for %q with arguments %v" , name , arg )
7284		}
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments