mirror of
				https://github.com/tmux-plugins/tpm.git
				synced 2025-11-04 00:16:05 +00:00 
			
		
		
		
	Refactor test 'expect' scripts
Make test 'expect' scripts simpler and ensure expectations are properly asserted. Closes #46
This commit is contained in:
		@@ -8,6 +8,8 @@
 | 
				
			|||||||
- switch to using [tmux-test](https://github.com/tmux-plugins/tmux-test)
 | 
					- switch to using [tmux-test](https://github.com/tmux-plugins/tmux-test)
 | 
				
			||||||
  framework
 | 
					  framework
 | 
				
			||||||
- add `bin/update_plugins` cli executable script
 | 
					- add `bin/update_plugins` cli executable script
 | 
				
			||||||
 | 
					- refactor test `expect` scripts, make them simpler and ensure they properly
 | 
				
			||||||
 | 
					  assert expectations
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### v2.0.0, 2015-07-07
 | 
					### v2.0.0, 2015-07-07
 | 
				
			||||||
- enable overriding default key bindings
 | 
					- enable overriding default key bindings
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,26 +16,21 @@ send "I"
 | 
				
			|||||||
set timeout 20
 | 
					set timeout 20
 | 
				
			||||||
 | 
					
 | 
				
			||||||
expect_after {
 | 
					expect_after {
 | 
				
			||||||
  timeout {
 | 
					  timeout { exit 1 }
 | 
				
			||||||
    puts "Plugin installation timeout"
 | 
					 | 
				
			||||||
    exit 1
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
expect {
 | 
					expect {
 | 
				
			||||||
  "Installing \"non-existing-plugin\"" {
 | 
					  "Installing \"non-existing-plugin\""
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
expect {
 | 
					expect {
 | 
				
			||||||
      "\"non-existing-plugin\" download fail" {
 | 
					  "\"non-existing-plugin\" download fail"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
expect {
 | 
					expect {
 | 
				
			||||||
  "Done, press ENTER to continue" {
 | 
					  "Done, press ENTER to continue" {
 | 
				
			||||||
            exit
 | 
					    exit 0
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      }
 | 
					exit 1
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,17 +14,22 @@ send "u"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
set timeout 5
 | 
					set timeout 5
 | 
				
			||||||
 | 
					
 | 
				
			||||||
expect {
 | 
					expect_after {
 | 
				
			||||||
  "Removing \"tmux-example-plugin\"" {
 | 
					  timeout { exit 1 }
 | 
				
			||||||
    expect {
 | 
					 | 
				
			||||||
      "\"tmux-example-plugin\" clean success" {
 | 
					 | 
				
			||||||
        expect { "Done, press ENTER to continue." { exit 0 } }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					expect {
 | 
				
			||||||
 | 
					  "Removing \"tmux-example-plugin\""
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					expect {
 | 
				
			||||||
 | 
					  "\"tmux-example-plugin\" clean success"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					expect {
 | 
				
			||||||
 | 
					  "Done, press ENTER to continue." {
 | 
				
			||||||
 | 
					    exit 0
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  timeout {
 | 
					 | 
				
			||||||
    puts "Plugin update prompt timeout";
 | 
					 | 
				
			||||||
exit 1
 | 
					exit 1
 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,32 +15,30 @@ send "I"
 | 
				
			|||||||
# cloning might take a while
 | 
					# cloning might take a while
 | 
				
			||||||
set timeout 15
 | 
					set timeout 15
 | 
				
			||||||
 | 
					
 | 
				
			||||||
expect { "Installing \"tmux-example-plugin\"" {
 | 
					expect_after {
 | 
				
			||||||
 | 
					  timeout { exit 1 }
 | 
				
			||||||
  expect { "\"tmux-example-plugin\" download success" {
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    expect { "Installing \"tmux-copycat\"" {
 | 
					expect {
 | 
				
			||||||
 | 
					  "Installing \"tmux-example-plugin\""
 | 
				
			||||||
      expect { "\"tmux-copycat\" download success" {
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        expect { "Done, press ENTER to continue" {
 | 
					expect {
 | 
				
			||||||
            send "
 | 
					  "\"tmux-example-plugin\" download success"
 | 
				
			||||||
"
 | 
					}
 | 
				
			||||||
          }
 | 
					
 | 
				
			||||||
        } # Done, press ENTER to continue
 | 
					expect {
 | 
				
			||||||
 | 
					  "Installing \"tmux-copycat\""
 | 
				
			||||||
        }
 | 
					}
 | 
				
			||||||
      } # "tmux-copycat" download success
 | 
					
 | 
				
			||||||
 | 
					expect {
 | 
				
			||||||
      }
 | 
					  "\"tmux-copycat\" download success"
 | 
				
			||||||
    } # Installing "tmux-copycat"
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					expect {
 | 
				
			||||||
  } # "tmux-example-plugin" download success
 | 
					  "Done, press ENTER to continue." {
 | 
				
			||||||
 | 
					    exit 0
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
  timeout {
 | 
					 | 
				
			||||||
exit 1
 | 
					exit 1
 | 
				
			||||||
    exit 1
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,40 +15,36 @@ send "I"
 | 
				
			|||||||
# cloning might take a while
 | 
					# cloning might take a while
 | 
				
			||||||
set timeout 15
 | 
					set timeout 15
 | 
				
			||||||
 | 
					
 | 
				
			||||||
expect {
 | 
					expect_after {
 | 
				
			||||||
  "Installing \"tmux-example-plugin\"" {
 | 
					  timeout { exit 1 }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
expect {
 | 
					expect {
 | 
				
			||||||
      "\"tmux-example-plugin\" download success" {
 | 
					  "Installing \"tmux-example-plugin\""
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        expect { "Done, press ENTER to continue" {
 | 
					expect {
 | 
				
			||||||
 | 
					  "\"tmux-example-plugin\" download success"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					expect {
 | 
				
			||||||
 | 
					  "Done, press ENTER to continue" {
 | 
				
			||||||
    send "
 | 
					    send "
 | 
				
			||||||
"
 | 
					"
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  timeout {
 | 
					 | 
				
			||||||
    puts "Plugin installation timeout (1)";
 | 
					 | 
				
			||||||
    exit 1
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
sleep 1
 | 
					sleep 1
 | 
				
			||||||
# this is tmux prefix + I
 | 
					# this is tmux prefix + I
 | 
				
			||||||
send "I"
 | 
					send "I"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
expect {
 | 
					expect {
 | 
				
			||||||
  "Already installed \"tmux-example-plugin\"" {
 | 
					  "Already installed \"tmux-example-plugin\""
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
    expect { "Done, press ENTER to continue" { exit 0 } }
 | 
					
 | 
				
			||||||
 | 
					expect {
 | 
				
			||||||
 | 
					  "Done, press ENTER to continue" {
 | 
				
			||||||
 | 
					    exit 0
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
  timeout {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    exit 1
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,50 +12,44 @@ sleep 1
 | 
				
			|||||||
# this is tmux prefix + U
 | 
					# this is tmux prefix + U
 | 
				
			||||||
send "U"
 | 
					send "U"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set timeout 5
 | 
					set timeout 15
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					expect_after {
 | 
				
			||||||
 | 
					  timeout { exit 1 }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
expect {
 | 
					expect {
 | 
				
			||||||
  "Installed plugins" {
 | 
					  "Installed plugins"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
expect {
 | 
					expect {
 | 
				
			||||||
      "\"tmux-example-plugin\"" {
 | 
					  "tmux-example-plugin"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
expect {
 | 
					expect {
 | 
				
			||||||
          "\"all\" - updates all plugins" {
 | 
					  "\"all\" - updates all plugins"
 | 
				
			||||||
 | 
					 | 
				
			||||||
            expect { "ENTER - cancels" }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      }
 | 
					expect {
 | 
				
			||||||
    }
 | 
					  "ENTER - cancels"
 | 
				
			||||||
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  timeout {
 | 
					 | 
				
			||||||
    puts "Plugin update prompt timeout";
 | 
					 | 
				
			||||||
    exit 1
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# wait for tmux to display prompt before sending characters
 | 
				
			||||||
 | 
					sleep 1
 | 
				
			||||||
send "tmux-example-plugin\r"
 | 
					send "tmux-example-plugin\r"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
expect {
 | 
					expect {
 | 
				
			||||||
  "Updating \"tmux-example-plugin\"" {
 | 
					  "Updating \"tmux-example-plugin\""
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
expect {
 | 
					expect {
 | 
				
			||||||
      "\"tmux-example-plugin\" update success" {
 | 
					  "\"tmux-example-plugin\" update success"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
        expect { "Done, press ENTER to continue." { exit 0 } }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					expect {
 | 
				
			||||||
 | 
					  "Done, press ENTER to continue." {
 | 
				
			||||||
 | 
					    exit 0
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  timeout {
 | 
					 | 
				
			||||||
    puts "Update all plugins timeout";
 | 
					 | 
				
			||||||
exit 1
 | 
					exit 1
 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,54 +14,46 @@ send "U"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
set timeout 5
 | 
					set timeout 5
 | 
				
			||||||
 | 
					
 | 
				
			||||||
expect {
 | 
					expect_after {
 | 
				
			||||||
  "Installed plugins" {
 | 
					  timeout { exit 1 }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
expect {
 | 
					expect {
 | 
				
			||||||
      "\"tmux-example-plugin\"" {
 | 
					  "Installed plugins"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
expect {
 | 
					expect {
 | 
				
			||||||
          "\"all\" - updates all plugins" {
 | 
					  "tmux-example-plugin"
 | 
				
			||||||
 | 
					 | 
				
			||||||
            expect { "ENTER - cancels" }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      }
 | 
					expect {
 | 
				
			||||||
 | 
					  "\"all\" - updates all plugins"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					expect {
 | 
				
			||||||
 | 
					  "ENTER - cancels"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  timeout {
 | 
					# wait for tmux to display prompt before sending characters
 | 
				
			||||||
    puts "Plugin update prompt timeout";
 | 
					sleep 1
 | 
				
			||||||
    exit 1
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
send "all\r"
 | 
					send "all\r"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
expect {
 | 
					expect {
 | 
				
			||||||
  "Updating all plugins!" {
 | 
					  "Updating all plugins!"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
expect {
 | 
					expect {
 | 
				
			||||||
      "Updating \"tmux-example-plugin\"" {
 | 
					  "Updating \"tmux-example-plugin\""
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
expect {
 | 
					expect {
 | 
				
			||||||
          "\"tmux-example-plugin\" update success" {
 | 
					  "\"tmux-example-plugin\" update success"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
            expect { "Done, press ENTER to continue." { exit 0 } }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					expect {
 | 
				
			||||||
 | 
					  "Done, press ENTER to continue." {
 | 
				
			||||||
 | 
					    exit 0
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  timeout {
 | 
					 | 
				
			||||||
    puts "Update all plugins timeout";
 | 
					 | 
				
			||||||
exit 1
 | 
					exit 1
 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user