File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3030import com .semmle .js .extractor .FileExtractor .FileType ;
3131import com .semmle .js .extractor .VirtualSourceRoot ;
3232import com .semmle .util .data .StringUtil ;
33+ import com .semmle .util .exception .Exceptions ;
3334import com .semmle .util .exception .UserError ;
3435import com .semmle .util .files .FileUtil ;
3536import com .semmle .util .files .FileUtil8 ;
@@ -443,8 +444,12 @@ public void excludeByClassificationBadPath() throws IOException {
443444
444445 /** Hide {@code p} on using {@link DosFileAttributeView} if available; otherwise do nothing. */
445446 private void hide (Path p ) throws IOException {
447+ try {
446448 DosFileAttributeView attrs = Files .getFileAttributeView (p , DosFileAttributeView .class );
447449 if (attrs != null ) attrs .setHidden (true );
450+ } catch (IOException e ) {
451+ Exceptions .ignore (e , "On Linux within the bazel sandbox, we get a DosFileAttributeView that then throws an exception upon use" );
452+ }
448453 }
449454
450455 @ Test
Original file line number Diff line number Diff line change 1+ java_test (
2+ name = "test_jar" ,
3+ srcs = glob (["**/*.java" ]),
4+ test_class = "com.semmle.js.extractor.test.AllTests" ,
5+ deps = [
6+ "//javascript/extractor" ,
7+ "//javascript/extractor:deps" ,
8+ "@//resources/lib/java/DO_NOT_DISTRIBUTE:junit" ,
9+ ],
10+ )
11+
12+ # We need to unzip the typescript wrapper, and provide node on the path.
13+ # Therefore, we're wrapping the java_test inside a sh_test.
14+ sh_test (
15+ name = "test" ,
16+ size = "small" ,
17+ srcs = ["run_tests.sh" ],
18+ args = [
19+ "$(execpath @nodejs//:node_bin)" ,
20+ "$(JAVABASE)/bin/java" ,
21+ "$(rootpath //javascript/extractor/lib/typescript)" ,
22+ "$(rootpath test_jar_deploy.jar)" ,
23+ ],
24+ data = [
25+ ":test_jar_deploy.jar" ,
26+ "//javascript/extractor/lib/typescript" ,
27+ "//javascript/extractor/parser-tests" ,
28+ "//javascript/extractor/tests" ,
29+ "@bazel_tools//tools/jdk:current_java_runtime" ,
30+ "@nodejs//:node_bin" ,
31+ ],
32+ toolchains = ["@bazel_tools//tools/jdk:current_java_runtime" ],
33+ )
Original file line number Diff line number Diff line change 1+ NODE=$1
2+ JAVA=$2
3+ PARSER_WRAPPER=$3
4+ TEST_JAR=$4
5+
6+ TEMP=$( mktemp -d)
7+
8+ UNAME=$( uname -s)
9+ echo $UNAME
10+ # On Windows, the symlink set up by bazel that points at the test jar is a msys2/linux-style path
11+ # The JVM can't resolve that, therefore copy the jar to the temp directory, and then set the
12+ # windows path to it
13+ if [[ " $UNAME " =~ _NT ]]; then
14+ cp $TEST_JAR $TEMP /test.jar
15+ TEST_JAR=$( cygpath -w $TEMP /test.jar)
16+ echo " On Windows, new test jar: $TEST_JAR "
17+ fi
18+
19+ # unpack parser wrapper
20+ unzip -q $PARSER_WRAPPER -d $TEMP /parser_wrapper
21+ export SEMMLE_TYPESCRIPT_PARSER_WRAPPER=$TEMP /parser_wrapper/javascript/tools/typescript-parser-wrapper/main.js
22+
23+ # setup node on path
24+ NODE=$( realpath $NODE )
25+ export PATH=" $PATH :$( dirname $NODE ) "
26+
27+ $JAVA -Dbazel.test_suite=com.semmle.js.extractor.test.AllTests -jar $TEST_JAR
28+ EXIT_CODE=$?
29+
30+ rm -rf $TEMP
31+ exit $EXIT_CODE
You can’t perform that action at this time.
0 commit comments