Commit 9a9763bc authored by Addshore's avatar Addshore 🏄
Browse files

dev mw: Remove phpunit command

parent 4b6a8227
...@@ -438,43 +438,33 @@ var mwddMediawikiResumeCmd = &cobra.Command{ ...@@ -438,43 +438,33 @@ var mwddMediawikiResumeCmd = &cobra.Command{
}, },
} }
var mwddMediawikiPhpunitCmd = &cobra.Command{
Use: "phpunit",
Short: "Runs MediaWiki phpunit in the MediaWiki container",
Run: func(cmd *cobra.Command, args []string) {
mwdd.DefaultForUser().EnsureReady()
mwdd.DefaultForUser().DockerExec(applyRelevantWorkingDirectory(mwdd.DockerExecCommand{
DockerComposeService: "mediawiki",
Command: append([]string{"php", "/var/www/html/w/tests/phpunit/phpunit.php"}, args...),
User: User,
}))
},
}
var mwddMediawikiExecCmd = &cobra.Command{ var mwddMediawikiExecCmd = &cobra.Command{
Use: "exec [flags] [command...]", Use: "exec [flags] [command...]",
Example: " exec bash\n exec -- bash --help\n exec --user root bash\n exec --user root -- bash --help", Example: ` exec bash # Run bash as your system user
exec --user root -- bash # Run bash as root
exec -- composer phpunit:unit # Run a composer command (php unit tests)
exec -- composer composer phpunit tests/phpunit/unit/includes/XmlTest.php # Run a single test
exec -- php maintenance/update.php --quick # Run a MediaWiki maintenance script`,
Short: "Executes a command in the MediaWiki container", Short: "Executes a command in the MediaWiki container",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
mwdd.DefaultForUser().EnsureReady() mwdd.DefaultForUser().EnsureReady()
mwdd.DefaultForUser().DockerExec(mwdd.DockerExecCommand{ mwdd.DefaultForUser().DockerExec(applyRelevantWorkingDirectory(mwdd.DockerExecCommand{
DockerComposeService: "mediawiki", DockerComposeService: "mediawiki",
Command: args, Command: args,
User: User, User: User,
}) }))
}, },
} }
var applyRelevantWorkingDirectory = func(dockerExecCommand mwdd.DockerExecCommand) mwdd.DockerExecCommand { var applyRelevantWorkingDirectory = func(dockerExecCommand mwdd.DockerExecCommand) mwdd.DockerExecCommand {
currentWorkingDirectory, _ := os.Getwd() currentWorkingDirectory, _ := os.Getwd()
mountedMwDirectory := mwdd.DefaultForUser().Env().Get("MEDIAWIKI_VOLUMES_CODE") mountedMwDirectory := mwdd.DefaultForUser().Env().Get("MEDIAWIKI_VOLUMES_CODE")
// For paths inside the mediawiki path // For paths inside the mediawiki path, rewrite things
if strings.HasPrefix(currentWorkingDirectory, mountedMwDirectory) { if strings.HasPrefix(currentWorkingDirectory, mountedMwDirectory) {
dockerExecCommand.WorkingDir = strings.Replace(currentWorkingDirectory, mountedMwDirectory, "/var/www/html/w", 1) dockerExecCommand.WorkingDir = strings.Replace(currentWorkingDirectory, mountedMwDirectory, "/var/www/html/w", 1)
} else {
fmt.Println("This command is not supported outside of the MediaWiki core directory: " + mountedMwDirectory)
os.Exit(1)
} }
// Otherwise just use the root of mediawiki
return dockerExecCommand return dockerExecCommand
} }
...@@ -489,8 +479,6 @@ func init() { ...@@ -489,8 +479,6 @@ func init() {
mwddMediawikiInstallCmd.Flags().StringVarP(&DbType, "dbtype", "", "", "Type of database to install (mysql, postgres, sqlite)") mwddMediawikiInstallCmd.Flags().StringVarP(&DbType, "dbtype", "", "", "Type of database to install (mysql, postgres, sqlite)")
mwddMediawikiCmd.AddCommand(mwddMediawikiComposerCmd) mwddMediawikiCmd.AddCommand(mwddMediawikiComposerCmd)
mwddMediawikiComposerCmd.Flags().StringVarP(&User, "user", "u", mwdd.UserAndGroupForDockerExecution(), "User to run as, defaults to current OS user uid:gid") mwddMediawikiComposerCmd.Flags().StringVarP(&User, "user", "u", mwdd.UserAndGroupForDockerExecution(), "User to run as, defaults to current OS user uid:gid")
mwddMediawikiCmd.AddCommand(mwddMediawikiPhpunitCmd)
mwddMediawikiPhpunitCmd.Flags().StringVarP(&User, "user", "u", mwdd.UserAndGroupForDockerExecution(), "User to run as, defaults to current OS user uid:gid")
mwddMediawikiCmd.AddCommand(mwddMediawikiExecCmd) mwddMediawikiCmd.AddCommand(mwddMediawikiExecCmd)
mwddMediawikiExecCmd.Flags().StringVarP(&User, "user", "u", mwdd.UserAndGroupForDockerExecution(), "User to run as, defaults to current OS user uid:gid") mwddMediawikiExecCmd.Flags().StringVarP(&User, "user", "u", mwdd.UserAndGroupForDockerExecution(), "User to run as, defaults to current OS user uid:gid")
......
...@@ -28,9 +28,9 @@ cd mediawiki ...@@ -28,9 +28,9 @@ cd mediawiki
# composer: Make sure a command works in root of the repo # composer: Make sure a command works in root of the repo
./../bin/mw docker mediawiki composer home | grep -q "https://www.mediawiki.org/" ./../bin/mw docker mediawiki composer home | grep -q "https://www.mediawiki.org/"
# phpunit: Make sure a command works in the root of the repo # exec phpunit: Make sure using exec to run phpunit things works
./../bin/mw docker mediawiki phpunit ./tests/phpunit/unit/includes/PingbackTest.php ./../bin/mw docker mediawiki exec -- composer phpunit tests/phpunit/unit/includes/PingbackTest.php
./../bin/mw docker mediawiki phpunit ./tests/phpunit/unit/includes/PingbackTest.php | grep -q "OK " ./../bin/mw docker mediawiki exec -- composer phpunit tests/phpunit/unit/includes/PingbackTest.php | grep -q "OK "
# exec: Make sure a command works in the root of the repo # exec: Make sure a command works in the root of the repo
./../bin/mw docker mediawiki exec ls | grep -q "api.php" ./../bin/mw docker mediawiki exec ls | grep -q "api.php"
...@@ -39,11 +39,8 @@ cd skins/Vector ...@@ -39,11 +39,8 @@ cd skins/Vector
# composer: Make sure a command works from the Vector directory # composer: Make sure a command works from the Vector directory
./../../../bin/mw docker mediawiki composer home | grep -q "http://gerrit.wikimedia.org/g/mediawiki/skins/Vector" ./../../../bin/mw docker mediawiki composer home | grep -q "http://gerrit.wikimedia.org/g/mediawiki/skins/Vector"
# phpunit: Make sure a command works from the Vector directory
./../../../bin/mw docker mediawiki phpunit ./../../tests/phpunit/unit/includes/PingbackTest.php | grep -q "OK "
# exec: Make sure a command works from the Vector directory # exec: Make sure a command works from the Vector directory
# Right now this just executes in the MediaWiki directory ./../../../bin/mw docker mediawiki exec ls | grep -q "skin.json"
./../../../bin/mw docker mediawiki exec ls | grep -q "api.php"
# cd back again # cd back again
cd ./../../../ cd ./../../../
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment