I'm trying to do WordPress Plugin Testing on Ubuntu 14.04 and I'm going through the setup of WP-CLI but I'm not able to download the necessary files (includes/functions.php).
This is the command I'm using:
bash bin/install-wp-tests.sh wordpress_test root '' localhost latest
This is the output:
+ install_wp
+ '[' -d /tmp/wordpress/ ']'
+ return
+ install_test_suite
++ uname -s
+ [[ Linux == \D\a\r\w\i\n ]]
+ local ioption=-i
+ '[' '!' -d /tmp/wordpress-tests-lib ']'
+ cd /tmp/wordpress-tests-lib
+ '[' '!' -f wp-tests-config.php ']'
+ download https://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php /tmp/wordpress-tests-lib/wp-tests-config.php
++ which curl
+ '[' /opt/lampp/bin/curl ']'
+ curl -s https://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php
+ sed -i 's:dirname( __FILE__ ) . '\''/src/'\'':'\''/tmp/wordpress/'\'':' /tmp/wordpress-tests-lib/wp-tests-config.php
+ sed -i s/youremptytestdbnamehere/wordpress_test/ /tmp/wordpress-tests-lib/wp-tests-config.php
+ sed -i s/yourusernamehere/root/ /tmp/wordpress-tests-lib/wp-tests-config.php
+ sed -i s/yourpasswordhere// /tmp/wordpress-tests-lib/wp-tests-config.php
+ sed -i 's|localhost|localhost|' /tmp/wordpress-tests-lib/wp-tests-config.php
+ install_db
+ PARTS=(${DB_HOST//\:/ })
+ local PARTS
+ local DB_HOSTNAME=localhost
+ local DB_SOCK_OR_PORT=
+ local EXTRA=
+ '[' -z localhost ']'
++ echo
++ grep -e '^[0-9]\{1,\}$'
+ '[' ']'
+ '[' -z ']'
+ '[' -z localhost ']'
+ EXTRA=' --host=localhost --protocol=tcp'
+ mysqladmin create wordpress_test --user=root --password= --host=localhost --protocol=tcp
Warning: Using a password on the command line interface can be insecure.
On using the phpunit command it throws an error:
Fatal error: require_once(): Failed opening required '/tmp/wordpress-tests-lib/includes/functions.php' (include_path='.:/opt/lampp/lib/php')
I'm at the office so I think the firewall could be blocking this command, though I have set a proxy in /etc/environment.
Help is appreciated.
I had this problem and here is what you might try:
Confirm that /tmp/wordpress-tests-lib is missing the includes directory.
Confirm that you have svn installed on the machine. If not run sudo apt-get install subversion
Delete the /tmp/wordpress-tests-lib folder
Inside your plugin directory open up the bin/install-wp-tests.sh file and remove the quiet flag on the Subversion call. Change this line:
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
to
svn co https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
Run the install shell script command again.
You should now be able to run PHPUnit and see the one default test passes.
I was having the same issue; resolved it by following the instructions here: https://github.com/wp-cli/wp-cli/wiki/Plugin-Unit-Tests . Specifically, I needed to initialize the testing environment.
bash bin/install-wp-tests.sh wordpress_test root '' localhost latest
where wordpress_test is test database, root is DB user and '' contains password.
Further Resources:
http://dlh01.info/wcto2014/#/
https://pippinsplugins.com/series/unit-tests-wordpress-plugins/
http://code.tutsplus.com/tutorials/the-beginners-guide-to-unit-testing-what-is-unit-testing--wp-25728
Related
I'm trying to deploy OpenStack using DevStack on Ubuntu 22.04, I'am facing issues on running stack.sh.
I'm not sure if it's related to the git repo code or related to the system configuration or som missing packages, please advise.
Here below the error log:
fatal: your current branch 'master' does not have any commits yet
+functions-common:git_clone:680 cd /opt/stack/devstack
+lib/neutron-legacy:install_mutnauq:469 setup_develop /opt/stack/neutron
+inc/python:setup_develop:334 local bindep
+inc/python:setup_develop:335 [[ /opt/stack/neutron == -bindep* ]]
+inc/python:setup_develop:339 local project_dir=/opt/stack/neutron
+inc/python:setup_develop:340 local extras=
+inc/python:setup_develop:341 _setup_package_with_constraints_edit /opt/stack/neutron -e
+inc/python:_setup_package_with_constraints_edit:360 local bindep
+inc/python:_setup_package_with_constraints_edit:361 [[ /opt/stack/neutron == -bindep* ]]
+inc/python:_setup_package_with_constraints_edit:365 local project_dir=/opt/stack/neutron
+inc/python:_setup_package_with_constraints_edit:366 local flags=-e
+inc/python:_setup_package_with_constraints_edit:367 local extras=
++inc/python:_setup_package_with_constraints_edit:374 cd /opt/stack/neutron
++inc/python:_setup_package_with_constraints_edit:374 pwd
+inc/python:_setup_package_with_constraints_edit:374 project_dir=/opt/stack/neutron
+inc/python:_setup_package_with_constraints_edit:376 '[' -n /opt/stack/requirements ']'
+inc/python:_setup_package_with_constraints_edit:380 local name
++inc/python:_setup_package_with_constraints_edit:381 awk '/^name.*=/ {print $3}' /opt/stack/neutron/setup.cfg
awk: fatal: cannot open file `/opt/stack/neutron/setup.cfg' for reading: No such file or directory
+inc/python:_setup_package_with_constraints_edit:381 name=
+inc/python:_setup_package_with_constraints_edit:1 exit_trap
+./stack.sh:exit_trap:516 local r=2
++./stack.sh:exit_trap:517 jobs -p
+./stack.sh:exit_trap:517 jobs=
+./stack.sh:exit_trap:520 [[ -n '' ]]
+./stack.sh:exit_trap:526 '[' -f '' ']'
+./stack.sh:exit_trap:531 kill_spinner
+./stack.sh:kill_spinner:426 '[' '!' -z '' ']'
+./stack.sh:exit_trap:533 [[ 2 -ne 0 ]]
+./stack.sh:exit_trap:534 echo 'Error on exit'
Error on exit
+./stack.sh:exit_trap:536 type -p generate-subunit
+./stack.sh:exit_trap:537 generate-subunit 1656624514 146 fail
+./stack.sh:exit_trap:539 [[ -z /opt/stack/logs ]]
+./stack.sh:exit_trap:542 /usr/bin/python3.10 /opt/stack/devstack/tools/worlddump.py -d /opt/stack/logs
/opt/stack/devstack/tools/worlddump.py:22: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
from distutils import spawn
Any clue ?
I have two servers, one with Nexus Repository and one with JFrog Artifactory OSS.
I would like to migrate to JFrog Artifactory but because it is open source there is no tool to migrate. If it were the pro version I could migrate easily.
I need some idea how to migrate from Nexus Repository to JFrog Artifactory OSS.
The way that I accomplished this task was to:
manually download the repos from Nexus. For nexus2 you can directly copy the repos from the filesystem. For nexus3 you will need to use the API. For nexus3 I used a script that I will put below.
Zip the repos into a folder
Upload the zipped file to artifactory with their import tool. Go to admin panel, artifactory, import, repositories.
You should be good to go from there more or less. I had to manually set some permissions and snapshot settings.
WARNING! This script doesn't work 100% you may/will have to modify it. WARNING!
sourceServer=
sourceRepo=
sourceUser=
sourcePassword=
logfile=$sourceRepo-backup.log
outputFile=$sourceRepo-artifacts.txt
# ======== GET DOWNLOAD URLs =========
url=$sourceServer"/service/rest/v1/assets?repository="$sourceRepo
contToken="initial"
while [ ! -z "$contToken" ]; do
if [ "$contToken" != "initial" ]; then
url=$sourceServer"/service/rest/v1/assets?continuationToken="$contToken"&repository="$sourceRepo
fi
echo Processing repository token: $contToken | tee -a $logfile
response=`curl -ksSL -u "$sourceUser:$sourcePassword" -X GET --header 'Accept: application/json' "$url"`
readarray -t artifacts < <( jq '[.items[].downloadUrl]' <<< "$response" )
printf "%s\n" "${artifacts[#]}" > artifacts.temp
sed 's/\"//g' artifacts.temp > artifacts1.temp
sed 's/,//g' artifacts1.temp > artifacts.temp
sed 's/[][]//g' artifacts.temp > artifacts1.temp
cat artifacts1.temp >> $outputFile
#for filter in "${filters[#]}"; do
# cat artifacts.temp | grep "$filter" >> $outputFile
#done
#cat maven-public-artifacts.txt
contToken=( $(echo $response | sed -n 's|.*"continuationToken" : "\([^"]*\)".*|\1|p') )
done
# ======== DOWNLOAD EVERYTHING =========
echo Downloading artifacts...
urls=($(cat $outputFile)) > /dev/null 2>&1
for url in "${urls[#]}"; do
path=${url#http://*:*/*/*/}
dir=$sourceRepo"/"${path%/*}
mkdir -p $dir
cd $dir
pwd
curl -vks -u "$sourceUser:$sourcePassword" -D response.header -X GET "$url" -O >> /dev/null 2>&1
responseCode=`cat response.header | sed -n '1p' | cut -d' ' -f2`
if [ "$responseCode" == "200" ]; then
echo Successfully downloaded artifact: $url
else
echo ERROR: Failed to download artifact: $url with error code: $responseCode
fi
rm response.header > /dev/null 2>&1
cd $curFolder
done
I have a windows system and wanted to test a wordpress plugin that is already existing.
i follwed this link and installed cygwin to run the bash command.
https://www.smashingmagazine.com/2017/12/automated-testing-wordpress-plugins-phpunit/
qa-test is the plugin name
when I ran the bash command in cmd prompt like below
C:\xampp\htdocs\mywebsite-wordpress\wordpress\wp-content\plugins\qa-test>bash bin/install-wp-tests.sh wordpress_test root '' localhost latest
+ install_wp
+ '[' -d /tmp/wordpress/ ']'
+ mkdir -p /tmp/wordpress/
+ [[ latest == \n\i\g\h\t\l\y ]]
+ [[ latest == \t\r\u\n\k ]]
+ '[' latest == latest ']'
+ local ARCHIVE_NAME=latest
+ download https://wordpress.org/latest.tar.gz /tmp/wordpress.tar.gz
++ which curl
+ '[' /cygdrive/c/Windows/system32/curl ']'
+ curl -s https://wordpress.org/latest.tar.gz
+ tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C /tmp/wordpress/
tar.exe: Error opening archive: Failed to open '/tmp/wordpress.tar.gz'
it says the above error message. don't know if it is a permission error or something. please direct me on how to fix this error. thanks!
Maybe I didn't specific with my question, hence didn't get any reply from experts.
I have a wordpress plugin that name is qa-test. I am trying to do automated testing on that plugin.
I ran the command
wp scaffold plugin-tests qa-test
that generated test files successfully.
Now, I need to run the below command
bin/install-wp-tests.sh wordpress_test root '' localhost latest
inorder to stat the phpunit. Since I have that windows system and not ubuntu
I have installed cygwin software and started running the
bin/install-wp-tests.sh wordpress_test root '' localhost latest
in command prompt. it says "Error opening archive: Failed to open '/tmp/wordpress.tar.gz'"
wh is that. if you need some additional info , please let me know what details are you looking for. thanks for your time helping on this :)
After I have installed wget.exe, which resolved the problem and ran the
bin/install-wp-tests.sh wordpress_test root '' localhost latest
without any error.
so right now at this point the bin/install-wp-tests.sh got created.
in the command prompt, when I run
phpunit it says
Could not find C:\Users\pri\AppData\Local\Temp/wordpress-tests-lib/includes/functions.php, have you run bin/install-wp-tests.sh?
I am not sure why is the slashes half of them with / and other half with . where can I go and correct this issue to rectify this error, please
I am creating a new rpm for a rails app. However the default behavior of the %install section removes the BUILDROOT directory. I assumed that the %install section would install the files from buildroot. I must be doing something wrong because the buildroot is getting removed in the %install section. What is the proper way to do this?
This is the spec file
Summary: Rails APP API (replaces railsapp rpm)
Name: railsapp-api
Version: 6.0.0
Release: 1
License: GPL
URL: http://www.both.org
Group: System
Packager: Tommie Jones
Requires: bash
BuildRoot: ~/rpmbuild/
%description
A rewrite of railsapp from the HTML version to a Http API version
%prep
echo "BUILDROOT = $RPM_BUILD_ROOT"
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/usr/local/veex/railsapp
unzip /home/realworx/rpmbuild/SOURCES/rwx-master.zip -d $RPM_BUILD_ROOT/usr/local/veex/
pushd $RPM_BUILD_ROOT/usr/local/veex/
rm -rf railsapp
mv rwx-master railsapp
pushd $RPM_BUILD_ROOT/usr/local/veex/railsapp
rm Gemfile.lock
bundle install
PWD=`pwd`
cat > gemrc <<EOGEMRC
gemhome: $PWD/vendor/bundle/ruby/1.8
gempath:
- $PWD/vendor/bundle/ruby/1.8
EOGEMRC
gem --config-file ./gemrc install bundler
# Don't need the gemrc any more...
rm ./gemrc
%files
%attr(0744, root, root) /usr/local/veex/railsapp/*
%install
echo %{buildroot}
echo "HELLO"
%clean
echo NOOP
Below is the log where the %install removes the buildroot.
(%install): /bin/sh -e /var/tmp/rpm-tmp.aX3U0b
+ umask 022
+ cd /home/railsapp-api/rpmbuild/BUILD
+ '[' /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch '!=' / ']'
+ rm -rf /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch
++ dirname /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch
+ mkdir -p /home/railsapp-api/rpmbuild/BUILDROOT
+ mkdir /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch
+ echo /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch
/home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch
+ echo HELLO
HELLO
+ /usr/lib/rpm/check-buildroot
+ /usr/lib/rpm/redhat/brp-ldconfig
/sbin/ldconfig: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf: No such file or directory
+ /usr/lib/rpm/brp-compress
+ /usr/lib/rpm/brp-strip /usr/bin/strip
+ /usr/lib/rpm/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
+ /usr/lib/rpm/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/brp-python-bytecompile 1
+ /usr/lib/rpm/brp-python-hardlink
+ PYTHON3=/usr/libexec/platform-python
+ /usr/lib/rpm/redhat/brp-mangle-shebangs
Processing files: railsapp-api-6.0.0-1.noarch
error: File not found: /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch/usr/local/veex/railsapp/*
How do I keep %install from removing my buildroot?
you are misusing the %prep section. In very short how you should use those sections:
%prep: to extract your sources, apply patches etc.
%build: to compile or build your application (if you need to)
%install: to copy the files into $RPM_BUILD_ROOT
So it is logical that $RPM_BUILD_ROOT is emptied at the start of the %isntall section.
Change your code to extract your zip file in %prep, and use the %install section to put the files inside $RPM_BUILD_ROOT.
I want to create the binary rpm files from generated binary packages in centos 6.4 and noticed in one of my build system the ${buildroot} is created automatically, I want to know how it can be achieved.
The sample wget.spec looks like below. detail spec is in my gist https://gist.github.com/larrycai/1ffe134bce1860f1cf87
%install
tar xf ~/wget.tar.gz -C %{buildroot}/
%files
%defattr(-,root,root)
/usr/bin/wget
The wget.tar.gz can be created tar -zcvf ~/wget.tar.gz /usr/bin/wget
When I build it using rpmbuild -bb wget.spec, I got the
+ rpmbuild -bb wget.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.VNDZg4
+ umask 022
+ cd /home/larry/rpmbuild/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ exit 0
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.S8koPW
+ umask 022
+ cd /home/larry/rpmbuild/BUILD
+ '[' /home/larry/rpmbuild/BUILDROOT/wget-1.12-1.x86_64 '!=' / ']'
+ rm -rf /home/larry/rpmbuild/BUILDROOT/wget-1.12-1.x86_64
++ dirname /home/larry/rpmbuild/BUILDROOT/wget-1.12-1.x86_64
+ mkdir -p /home/larry/rpmbuild/BUILDROOT
+ mkdir /home/larry/rpmbuild/BUILDROOT/wget-1.12-1.x86_64
+ LANG=C
+ export LANG
+ unset DISPLAY
+ tar xf /home/larry/wget.tar.gz -C /home/larry/rpmbuild/BUILDROOT/wget-1.12-1.x86_64/
+ /usr/lib/rpm/check-buildroot
... (it is successful)
I wonder why line mkdir /home/larry/rpmbuild/BUILDROOT/wget-1.12-1.x86_64 is executed automatically.
Are there any script or rpmmacros is enabled for this ?
The main reason is that build machines installed redhat-rpm-config package, the detail list below
This macro setting is in /usr/lib/rpm/redhat/macros
%__spec_install_pre %{___build_pre}\
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "${RPM_BUILD_ROOT}"\
mkdir -p `dirname "$RPM_BUILD_ROOT"`\
mkdir "$RPM_BUILD_ROOT"\
%{nil}
We can either install this package or put this macros into ~/.rpmmacros
I find it by running command rpmbuild --showrc can see that mkdir code segment is there, so I start to check whether there is special package is installed.