mirror of
				https://github.com/tmux-plugins/tpm.git
				synced 2025-11-04 08:36:05 +00:00 
			
		
		
		
	Improve tests
This commit is contained in:
		
							
								
								
									
										46
									
								
								tests/expect_successful_multiple_plugins_download
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										46
									
								
								tests/expect_successful_multiple_plugins_download
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,46 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env expect
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# disables script output
 | 
				
			||||||
 | 
					log_user 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					spawn tmux
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Waiting for tmux to attach. If this is not done, next command, `send` will
 | 
				
			||||||
 | 
					# not work properly.
 | 
				
			||||||
 | 
					sleep 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# this is tmux prefix + I
 | 
				
			||||||
 | 
					send "I"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# cloning might take a while
 | 
				
			||||||
 | 
					set timeout 15
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					expect { "Installing \"tmux-example-plugin\"" {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  expect { "\"tmux-example-plugin\" download success" {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    expect { "Installing \"tmux-copycat\"" {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      expect { "\"tmux-copycat\" download success" {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        expect { "Done, press ENTER to continue" {
 | 
				
			||||||
 | 
					            send "
 | 
				
			||||||
 | 
					"
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        } # Done, press ENTER to continue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      } # "tmux-copycat" download success
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    } # Installing "tmux-copycat"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  } # "tmux-example-plugin" download success
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  timeout {
 | 
				
			||||||
 | 
					    puts "Multiple plugins installation timeout";
 | 
				
			||||||
 | 
					    exit 1
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
@@ -6,12 +6,12 @@ source $CURRENT_DIR/helpers.sh
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
test_plugin_installation() {
 | 
					test_plugin_installation() {
 | 
				
			||||||
	set_tmux_conf_helper <<- HERE
 | 
						set_tmux_conf_helper <<- HERE
 | 
				
			||||||
	set -g @tpm_plugins "tmux-plugins/tmux-example-plugin"
 | 
						set @plugin "tmux-plugins/tmux-example-plugin"
 | 
				
			||||||
	run-shell "$PWD/tpm"
 | 
						run-shell "$PWD/tpm"
 | 
				
			||||||
	HERE
 | 
						HERE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	# opens tmux and test it with `expect`
 | 
						# opens tmux and test it with `expect`
 | 
				
			||||||
	$CURRENT_DIR/expect_successful_plugin_download ||
 | 
						"$CURRENT_DIR"/expect_successful_plugin_download ||
 | 
				
			||||||
		fail_helper "Tmux plugin installation fails"
 | 
							fail_helper "Tmux plugin installation fails"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	# check plugin dir exists after download
 | 
						# check plugin dir exists after download
 | 
				
			||||||
@@ -21,8 +21,30 @@ test_plugin_installation() {
 | 
				
			|||||||
	teardown_helper
 | 
						teardown_helper
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test_multiple_plugins_installation() {
 | 
				
			||||||
 | 
						set_tmux_conf_helper <<- HERE
 | 
				
			||||||
 | 
						set @plugin "tmux-plugins/tmux-example-plugin"
 | 
				
			||||||
 | 
						set   @plugin 'tmux-plugins/tmux-copycat'
 | 
				
			||||||
 | 
						run-shell "$PWD/tpm"
 | 
				
			||||||
 | 
						HERE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						# opens tmux and test it with `expect`
 | 
				
			||||||
 | 
						"$CURRENT_DIR"/expect_successful_multiple_plugins_download ||
 | 
				
			||||||
 | 
							fail_helper "Tmux multiple plugins installation fails"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						# check plugin dir exists after download
 | 
				
			||||||
 | 
						check_dir_exists_helper "$HOME/.tmux/plugins/tmux-example-plugin/" ||
 | 
				
			||||||
 | 
							fail_helper "Plugin download fails (tmux-example-plugin)"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						check_dir_exists_helper "$HOME/.tmux/plugins/tmux-copycat/" ||
 | 
				
			||||||
 | 
							fail_helper "Plugin download fails (tmux-copycat)"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						teardown_helper
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
main() {
 | 
					main() {
 | 
				
			||||||
	test_plugin_installation
 | 
						test_plugin_installation
 | 
				
			||||||
 | 
						test_multiple_plugins_installation
 | 
				
			||||||
	exit_value_helper
 | 
						exit_value_helper
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
main
 | 
					main
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,12 +6,12 @@ source $CURRENT_DIR/helpers.sh
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
test_plugin_installation() {
 | 
					test_plugin_installation() {
 | 
				
			||||||
	set_tmux_conf_helper <<- HERE
 | 
						set_tmux_conf_helper <<- HERE
 | 
				
			||||||
	set @plugin "tmux-plugins/tmux-example-plugin"
 | 
						set -g @tpm_plugins "tmux-plugins/tmux-example-plugin"
 | 
				
			||||||
	run-shell "$PWD/tpm"
 | 
						run-shell "$PWD/tpm"
 | 
				
			||||||
	HERE
 | 
						HERE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	# opens tmux and test it with `expect`
 | 
						# opens tmux and test it with `expect`
 | 
				
			||||||
	"$CURRENT_DIR"/expect_successful_plugin_download ||
 | 
						$CURRENT_DIR/expect_successful_plugin_download ||
 | 
				
			||||||
		fail_helper "Tmux plugin installation fails"
 | 
							fail_helper "Tmux plugin installation fails"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	# check plugin dir exists after download
 | 
						# check plugin dir exists after download
 | 
				
			||||||
		Reference in New Issue
	
	Block a user