Skip to content

Commit

Permalink
Update stub_finds_runfiles_test to be a real sh_test.
Browse files Browse the repository at this point in the history
Fixes #4563.

Change-Id: I12868569feb1ec700062006307cda15c24946797
PiperOrigin-RevId: 184490058
  • Loading branch information
katre authored and philwo committed Mar 6, 2018
1 parent 00d781a commit 64cd25a
Showing 1 changed file with 72 additions and 47 deletions.
119 changes: 72 additions & 47 deletions src/test/shell/integration/stub_finds_runfiles_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ if [ $# -ge 1 ]; then
shift
fi

#### TESTS #############################################################
#### HELPER FUNCTIONS ##################################################

mkdir pkg pkg/java
cat > pkg/BUILD << 'EOF'
function set_up() {
mkdir -p pkg pkg/java
cat > pkg/BUILD << 'EOF'
java_binary(name = "javabin",
main_class = "ExitZero",
srcs = [ "java/ExitZero.java", ])
Expand Down Expand Up @@ -68,75 +69,99 @@ genrule(name = "genrule_runs_pybin",
outs = [ "dummy2", ],
cmd = "$(location :pybin) && $(location :sh_runs_pybin) && >$@")
EOF
cat > pkg/java/ExitZero.java << 'EOF'
cat > pkg/java/ExitZero.java << 'EOF'
public class ExitZero {
public static void main(String[] args) { }
}
EOF
touch pkg/pybin.py
touch pkg/pytest.py
cat > pkg/sh_runs_javabin.sh << 'EOF'
touch pkg/pybin.py
touch pkg/pytest.py
cat > pkg/sh_runs_javabin.sh << 'EOF'
#!/bin/sh
exec $0.runfiles/*/pkg/javabin
EOF
cat > pkg/sh_runs_javatest.sh << 'EOF'
cat > pkg/sh_runs_javatest.sh << 'EOF'
#!/bin/sh
exec $TEST_SRCDIR/*/pkg/javatest
EOF
cat > pkg/sh_runs_pybin.sh << 'EOF'
cat > pkg/sh_runs_pybin.sh << 'EOF'
#!/bin/sh
exec $0.runfiles/*/pkg/pybin
EOF
cat > pkg/sh_runs_pytest.sh << 'EOF'
cat > pkg/sh_runs_pytest.sh << 'EOF'
#!/bin/sh
exec $TEST_SRCDIR/*/pkg/pytest
EOF
chmod +x pkg/*.sh
chmod +x pkg/*.sh
}

function tear_down() {
rm -rf pkg pkg/java
}

# Drop environment variable (set by the test runner for this test)
# which will interfere with directly invoking the tests we have just built.
unset TEST_SRCDIR
#### TESTS #############################################################

function test_javabin() {
bazel build //pkg:javabin > $TEST_log
${PRODUCT_NAME}-bin/pkg/javabin
bazel run //pkg:javabin
${PRODUCT_NAME}-bin/pkg/javabin.runfiles/*/pkg/javabin
}

bazel build //pkg:javabin
${PRODUCT_NAME}-bin/pkg/javabin
bazel run //pkg:javabin
${PRODUCT_NAME}-bin/pkg/javabin.runfiles/*/pkg/javabin
function test_javatest() {
bazel build //pkg:javatest
${PRODUCT_NAME}-bin/pkg/javatest
bazel run //pkg:javatest
${PRODUCT_NAME}-bin/pkg/javatest.runfiles/*/pkg/javatest
bazel test --test_strategy="$test_strategy" //pkg:javatest
}

bazel build //pkg:javatest
${PRODUCT_NAME}-bin/pkg/javatest
bazel run //pkg:javatest
${PRODUCT_NAME}-bin/pkg/javatest.runfiles/*/pkg/javatest
bazel test --test_strategy="$test_strategy" //pkg:javatest
function test_pybin() {
bazel build //pkg:pybin
${PRODUCT_NAME}-bin/pkg/pybin
bazel run //pkg:pybin
${PRODUCT_NAME}-bin/pkg/pybin.runfiles/*/pkg/pybin
}

bazel build //pkg:pybin
${PRODUCT_NAME}-bin/pkg/pybin
bazel run //pkg:pybin
${PRODUCT_NAME}-bin/pkg/pybin.runfiles/*/pkg/pybin
function test_pytest() {
bazel build //pkg:pytest
${PRODUCT_NAME}-bin/pkg/pytest
bazel run //pkg:pytest
${PRODUCT_NAME}-bin/pkg/pytest.runfiles/*/pkg/pytest
bazel test --test_strategy="$test_strategy" //pkg:pytest
}

bazel build //pkg:pytest
${PRODUCT_NAME}-bin/pkg/pytest
bazel run //pkg:pytest
${PRODUCT_NAME}-bin/pkg/pytest.runfiles/*/pkg/pytest
bazel test --test_strategy="$test_strategy" //pkg:pytest
function test_sh_runs_javabin() {
bazel build //pkg:sh_runs_javabin
${PRODUCT_NAME}-bin/pkg/sh_runs_javabin
bazel run //pkg:sh_runs_javabin
}

bazel build //pkg:sh_runs_javabin
${PRODUCT_NAME}-bin/pkg/sh_runs_javabin
bazel run //pkg:sh_runs_javabin
function test_sh_runs_javatest() {
bazel build //pkg:sh_runs_javatest
bazel test --test_strategy="$test_strategy" //pkg:sh_runs_javatest
}

bazel build //pkg:sh_runs_javatest
bazel test --test_strategy="$test_strategy" //pkg:sh_runs_javatest
function test_sh_runs_pybin() {
bazel build //pkg:sh_runs_pybin
${PRODUCT_NAME}-bin/pkg/sh_runs_pybin
bazel run //pkg:sh_runs_pybin
}

bazel build //pkg:sh_runs_pybin
${PRODUCT_NAME}-bin/pkg/sh_runs_pybin
bazel run //pkg:sh_runs_pybin
function test_sh_runs_pytest() {
bazel build //pkg:sh_runs_pytest
bazel test --test_strategy="$test_strategy" //pkg:sh_runs_pytest
}

bazel build //pkg:sh_runs_pytest
bazel test --test_strategy="$test_strategy" //pkg:sh_runs_pytest
function test_genrule_runs_pybin() {
bazel clean
bazel build --genrule_strategy="$genrule_strategy" //pkg:genrule_runs_pybin
}

bazel clean
bazel build --genrule_strategy="$genrule_strategy" //pkg:genrule_runs_pybin
function test_genrule_runs_javabin() {
bazel clean
bazel build --genrule_strategy="$genrule_strategy" //pkg:genrule_runs_javabin
}

bazel clean
bazel build --genrule_strategy="$genrule_strategy" //pkg:genrule_runs_javabin
run_suite "stub_finds_runfiles_test"

echo PASS

0 comments on commit 64cd25a

Please sign in to comment.