Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Commit 61b949c

Browse files
authored
devel: simplify ngx_pagespeed development flow (#1363)
* provide scripts/rebuild.sh so you don't have to run make commands in two directories * make test/run_tests.sh able to run with no arguments by setting good defaults.
1 parent 5b30774 commit 61b949c

File tree

3 files changed

+54
-21
lines changed

3 files changed

+54
-21
lines changed

scripts/build_ngx_pagespeed.sh

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -767,25 +767,13 @@ Not deleting $directory; name is suspiciously short. Something is wrong."
767767
if "$DEVEL"; then
768768
run make install
769769

770-
status "Nginx installed with ngx_pagespeed, and set up for testing."
771-
# TODO(jefftk): pull these out into separate scripts.
772-
echo "To run tests, pick a pair of ports like 8050 and 8051 and run:"
770+
status "Nginx installed with ngx_pagespeed, and set up for development."
771+
echo "To run tests:"
773772
echo " cd $nps_module_dir"
774-
echo " RUN_TESTS=true \\"
775-
echo " USE_VALGRIND=false \\"
776-
echo " TEST_NATIVE_FETCHER=false \\"
777-
echo " TEST_SERF_FETCHER=true \\"
778-
echo " test/run_tests.sh \\"
779-
echo " $MOD_PAGESPEED_DIR \\"
780-
echo " $install_dir/nginx/sbin/nginx"
773+
echo " test/run_tests.sh"
781774
echo
782775
echo "To rebuild after changes:"
783-
echo " First, if you change things in PSOL or update it:"
784-
echo " cd $MOD_PAGESPEED_DIR/devel"
785-
echo " make apache_debug_psol"
786-
echo " Then, whether or not you updated PSOL, rebuild nginx:"
787-
echo " cd $install_dir/nginx"
788-
echo " make && make install"
776+
echo " scripts/rebuild.sh"
789777
else
790778
continue_or_exit "Install nginx?"
791779
run sudo make install

scripts/rebuild.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2016 Google Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Usage: scripts/rebuild.sh
18+
#
19+
# After building with "scripts/build_ngx_pagespeed.sh --devel", if you make
20+
# changes to ngx_pagespeed you'll need to rebuild it. The underlying commands
21+
# aren't complicated, but it's faster to work if it's automated.
22+
23+
set -e # exit script if any command returns an error
24+
set -u # exit the script if any variable is uninitialized
25+
26+
this_dir="$(dirname $0)"
27+
cd "$this_dir/.."
28+
nps_dir="$PWD"
29+
30+
cd "$nps_dir/testing-dependencies/mod_pagespeed/devel"
31+
make apache_debug_psol
32+
33+
cd "$nps_dir/testing-dependencies/nginx/"
34+
make
35+
make install

test/run_tests.sh

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,15 @@
2323
# Exits with status 2 if command line args are wrong.
2424
#
2525
# Usage:
26+
# ./run_tests.sh
27+
# Or:
2628
# ./run_tests.sh /path/to/mod_pagespeed /path/to/nginx/binary
2729
#
30+
# If you built ngx_pagespeed with "scripts/build_ngx_pagespeed.sh --devel" then
31+
# you don't need to pass any arguments to run_tests.sh. Otherwise, you'll need
32+
# to tell it where to find a mod_pagespeed checkout (for example html files etc)
33+
# and the nginx binary to test.
34+
#
2835
# By default the test script uses several ports. If you have a port conflict
2936
# and need to override one you can do that by setting the relevant environment
3037
# variable. For example:
@@ -45,14 +52,17 @@ RUN_TESTS=${RUN_TESTS:-true}
4552
# true.
4653
USE_VALGRIND=${USE_VALGRIND:-false}
4754

48-
if [ "$#" -ne 2 ] ; then
49-
echo "Usage: $0 mod_pagespeed_dir nginx_executable"
55+
if [ "$#" -eq 0 ]; then
56+
MOD_PAGESPEED_DIR="testing-dependencies/mod_pagespeed/"
57+
NGINX_EXECUTABLE="nginx/sbin/nginx"
58+
elif [ "$#" -eq 2 ]; then
59+
MOD_PAGESPEED_DIR="$1"
60+
NGINX_EXECUTABLE="$2"
61+
else
62+
echo "Usage: $0 [mod_pagespeed_dir nginx_executable]"
5063
exit 2
5164
fi
5265

53-
MOD_PAGESPEED_DIR="$1"
54-
NGINX_EXECUTABLE="$2"
55-
5666
: ${PRIMARY_PORT:=8050}
5767
: ${SECONDARY_PORT:=8051}
5868
: ${CONTROLLER_PORT:=8053}

0 commit comments

Comments
 (0)