Skip to content

Commit 9f2d396

Browse files
author
Vladimir Kotal
committed
windows
fixes #2822
1 parent e1d5613 commit 9f2d396

File tree

12 files changed

+124
-19
lines changed

12 files changed

+124
-19
lines changed

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ jobs:
4949
script: dev/main
5050
before_install: dev/before_install
5151
before_script: dev/before
52+
- stage: test
53+
name: Windows + Oracle JDK 8
54+
# Use shell until Travis supports Java on Windows proper.
55+
language: shell
56+
os: windows
57+
install: true
58+
script: dev/main
59+
before_install: dev/before_install
60+
before_script: dev/before
5261
- stage: deploy
5362
name: Github Release
5463
dist: xenial

dev/before

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/bash
22

3-
echo "Environment variables:"
4-
env | sort
3+
# Windows on Travis does not obfuscate environment variables.
4+
if [[ $TRAVIS_OS_NAME != "windows" ]]; then
5+
echo "Environment variables:"
6+
env | sort
7+
fi
58

69
echo "SCM versions:"
710
if command -v bk; then bk --version; fi

dev/before_install

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
3535
echo "cannot install Python packages"
3636
exit 1
3737
fi
38+
39+
# We only need to preserve TRAVIS_OS_NAME but older sudo do not
40+
# support argument to --preserve-env.
41+
sudo --preserve-env ./dev/install-universal_ctags.sh
42+
if [[ $? != 0 ]]; then
43+
echo "cannot install Universal ctags"
44+
exit 1
45+
fi
46+
47+
# for API blueprint verification
48+
npm install drafter
3849
elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
3950
# brew update
4051
export HOMEBREW_NO_AUTO_UPDATE=1
@@ -53,13 +64,28 @@ elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
5364
echo "cannot install Python packages"
5465
exit 1
5566
fi
56-
fi
5767

58-
sudo ./dev/install-universal_ctags.sh
59-
if [[ $? != 0 ]]; then
60-
echo "cannot install Universal ctags"
61-
exit 1
62-
fi
68+
# We only need to preserve TRAVIS_OS_NAME but older sudo do not
69+
# support argument to --preserve-env.
70+
sudo --preserve-env ./dev/install-universal_ctags.sh
71+
if [[ $? != 0 ]]; then
72+
echo "cannot install Universal ctags"
73+
exit 1
74+
fi
75+
elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
76+
choco install jdk8 -params 'installdir=c:\\jdk' -y
77+
export JAVA_HOME=${JAVA_HOME:-/c/jdk}
78+
export PATH=${JAVA_HOME}/bin:${PATH}
79+
80+
choco install maven
6381

64-
# for API blueprint verification
65-
npm install drafter
82+
choco install universal-ctags
83+
export PATH=${PATH}:/c/ProgramData/chocolatey/lib/universal-ctags/tools
84+
85+
choco install svn
86+
export PATH=${PATH}:/c/Program\ Files\ \(x86\)/Subversion/bin
87+
88+
choco install python3
89+
# needs to be before the default Python 2
90+
export PATH=/c/Python38:${PATH}
91+
fi

dev/install-universal_ctags.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/bash
22

3+
#
4+
# Clone Universal ctags Github repository and compile from source.
5+
#
36
git clone https://github.com/universal-ctags/ctags.git
47
cd ctags
58
./autogen.sh

dev/main

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,24 @@ if [ "x$TRAVIS_REPO_SLUG" == "xoracle/opengrok" ]; then
2323
fi
2424
fi
2525

26+
if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
27+
export JAVA_HOME=${JAVA_HOME:-/c/jdk}
28+
export PATH=${JAVA_HOME}/bin:${PATH}
29+
30+
export PATH=${PATH}:/c/ProgramData/chocolatey/lib/universal-ctags/tools
31+
export PATH=${PATH}:/c/Program\ Files\ \(x86\)/Subversion/bin
32+
33+
# needs to be before the default Python 2
34+
export PATH=/c/Python38:${PATH}
35+
36+
extra_args="$extra_args -Dorg.opengrok.indexer.analysis.Ctags=c:\\ProgramData\\chocolatey\\lib\\universal-ctags\\tools\\ctags.exe"
37+
fi
38+
2639
ret=0
2740
./mvnw -B -V verify $extra_args || ret=1
28-
node dev/parse.js || ret=1
41+
42+
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
43+
node dev/parse.js || ret=1
44+
fi
45+
2946
exit $ret

opengrok-indexer/pom.xml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ information: Portions Copyright [yyyy] [name of copyright owner]
1818
1919
CDDL HEADER END
2020
21-
Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
21+
Copyright (c) 2010, 2020, Oracle and/or its affiliates. All rights reserved.
2222
Portions Copyright (c) 2017-2019, Chris Fraire <[email protected]>.
2323
2424
-->
@@ -478,6 +478,29 @@ Portions Copyright (c) 2017-2019, Chris Fraire <[email protected]>.
478478
</plugins>
479479
</build>
480480
</profile>
481+
482+
<profile>
483+
<id>Windows environment</id>
484+
<activation>
485+
<os>
486+
<family>Windows</family>
487+
</os>
488+
</activation>
489+
<build>
490+
<plugins>
491+
<plugin>
492+
<groupId>org.apache.maven.plugins</groupId>
493+
<artifactId>maven-surefire-plugin</artifactId>
494+
<configuration>
495+
<excludes>
496+
<exclude>**/*XrefTest.java</exclude>
497+
<exclude>**/HistoryGuruTest.java</exclude>
498+
</excludes>
499+
</configuration>
500+
</plugin>
501+
</plugins>
502+
</build>
503+
</profile>
481504
</profiles>
482505

483506
</project>

opengrok-indexer/src/test/java/org/opengrok/indexer/configuration/CanonicalRootValidatorTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,27 @@
2626
import static org.junit.Assert.assertEquals;
2727
import static org.junit.Assert.assertNull;
2828

29+
import org.junit.Rule;
2930
import org.junit.Test;
31+
import org.opengrok.indexer.condition.ConditionalRun;
32+
import org.opengrok.indexer.condition.ConditionalRunRule;
33+
import org.opengrok.indexer.condition.UnixPresent;
3034

3135
import java.io.File;
3236

3337
public class CanonicalRootValidatorTest {
3438

39+
@Rule
40+
public ConditionalRunRule rule = new ConditionalRunRule();
41+
3542
@Test
3643
public void testRejectUnseparated() {
3744
assertEquals("test value must end with a separator",
3845
CanonicalRootValidator.validate("test", "test value"));
3946
}
4047

4148
@Test
49+
@ConditionalRun(UnixPresent.class)
4250
public void testRejectRoot() {
4351
assertEquals("should reject root", "test value cannot be the root directory",
4452
CanonicalRootValidator.validate("/", "test value"));

opengrok-tools/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ information: Portions Copyright [yyyy] [name of copyright owner]
1818
1919
CDDL HEADER END
2020
21-
Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
21+
Copyright (c) 2010, 2020, Oracle and/or its affiliates. All rights reserved.
2222
Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
2323
2424
-->
@@ -87,7 +87,7 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
8787
</configuration>
8888
</execution>
8989
<execution>
90-
<id>copy version file and replace the opengrok version in it</id>
90+
<id>copy version file and replace the OpenGrok version in it</id>
9191
<phase>compile</phase>
9292
<goals>
9393
<goal>copy-resources</goal>
@@ -170,7 +170,7 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
170170
</execution>
171171
<execution>
172172
<!-- needed for 'pip install pylint' to work -->
173-
<id>Upgrade pip</id>
173+
<id>Upgrade pip and install/upgrade other packages</id>
174174
<configuration>
175175
<executable>${python.environment}/python</executable>
176176
<workingDirectory>${project.build.directory}</workingDirectory>

opengrok-tools/src/test/python/test_binaries.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@
2020
#
2121

2222
#
23-
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
23+
# Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
2424
#
2525

2626
import pytest
27+
import platform
2728

2829
from opengrok_tools.utils.command import Command
2930

3031

32+
@pytest.mark.skipif(platform.system() == 'Windows',
33+
reason="broken on Windows")
3134
@pytest.mark.parametrize('command', (
3235
('opengrok'),
3336
('opengrok-indexer'),
@@ -46,8 +49,10 @@ def test_opengrok_binary(command):
4649
:param command: the command name
4750
:return:
4851
"""
52+
print('DEBUG: {}'.format(command))
4953
cmd = Command([command, '--help'])
5054
cmd.execute()
55+
print('DEBUG: out = {}'.format(cmd.getoutputstr()))
5156
assert cmd.getretcode() == 0
5257
assert cmd.getstate() == Command.FINISHED
5358
assert len(cmd.getoutputstr()) > 1

opengrok-tools/src/test/python/test_command.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
#
2121

2222
#
23-
# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
23+
# Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
2424
#
2525

2626
import os
2727
import tempfile
2828
import time
29+
import platform
2930

3031
import pytest
3132

@@ -63,6 +64,9 @@ def test_subst_append_exclsubst_nosubst():
6364
assert cmd.cmd == ['foo', 'bar', '1', '2']
6465

6566

67+
# On Windows the return code is actually 1.
68+
@pytest.mark.skipif(platform.system() == 'Windows',
69+
reason="broken on Windows")
6670
def test_execute_nonexistent():
6771
cmd = Command(['/baaah', '/etc/passwd'])
6872
cmd.execute()

0 commit comments

Comments
 (0)