#!/bin/sh # info: test -argfile and @ variants # syntax: $0 (define JDKDIR and AJBASE) # @process-test ajc argfiles.sh # test -argfile and @ variants [ -n "$DEBUG" ] && set -vx errMssg() { [ -n "$1" ] && echo "## $0 $1" [ -n "$2" ] && exit "$2" } ## @testcase (support) NPE with -argfile foo.lst with "*.java" testcaseDesign() { cat<{lst} ]... fileRef: [[local | relative | absolute] X [DOS|Unix|Mac]] file line: [ option | [@{lst} | {java|aj}] ] option: ajc options refLocality: [cwd | argfile] ## white box - @, -argfile delegate to same file-creation method - direct locality matters: null used for for locals and.. - indirect locality matters: referent varies ## design -- structure - invocation - could set up as unit tests of ConfigParser.java - if so, have also to test delivery to ajc? e.g., do package names get calculated correctly under different path variants? Probably not an issue now, but perhaps later when source-path searching is enabled. - could invoke ajc.Main programmatically - can ajc be run repeatedly? -> might be easier/safer to script, uncover [bash, DOS,...] shell quirks? -- test case variants - command-line - test options - ajc - esp. multi-flag (-source 1.4) - separate lines? - VM/Javac? - @, -argfile is independent - test 0, 1, 3 on same line, interspersed - error: @java file, unflagged arg file - fileRef depends on locality: - parm file: CWD, relative-up, relative down-up, absolute, wrong \/: - relative and absolute traversing through directories with spaces in them (not in package-named directories) - file line: same, with * variants - * variants: [*.java | *.aj] [ empty | 1 | n>1 ] - fileRef also depends on indirection path: - add traversal cases - 1-2 levels of indirection - need to think about whether indirection depends on locality reference i.e., whether 1-2 levels of indirection need to be through all locality types (CWD, relative...) - basic argfile - options - files - @ref - comments - empty lines - *.java, *.aj references - re ## implementation - Source tree - minimal, star, maximal: all need each other to compile - some in default package, others in named packages - some do not share the same source base (or file system?) - files: Minimal: src/ Main.java pack/Main.java Star: star/ Main.java empty/ many/One.java many/Two.java Maximal: src1/ Src1DefaultMain.java pack1/Src1Pack1Main.java pack2/Src1Pack2Main.java src2/ Src2DefaultMain.java pack1/Src2Pack1Main.java pack2/Src2Pack2Main.java - EOF } generateCurrentSource() { genSource "" Main "Main SomeClass" > Main.java genSource "" SomeClass "Main SomeClass" > SomeClass.java cat > current_Main_0.lst < current_SomeClass_0.lst < src/Main.java genSource pack Main "pack.Main" > src/pack/Main.java cat > src/minimal_pack.Main_0.lst < src/minimal_Main_1.lst < src/pack/minimal_Main_2.lst < src/pack/minimal_Main_3.lst < minimal_Main_4.lst < src/minimal_Main_5.lst < src/minimal_Main_6.lst < src/minimal_Main_7.lst < src/minimal_Main_8.lst < star/Main.java genSource "many" Main "many.One many.Two" > star/many/One.java genSource "many" Main "many.One many.Two" > star/many/Two.java cat > star/star_Main_1.lst < src1/Src1Main.java genSource "" Main "Src2Main $refs" > src2/Src2Main.java genSource "pack1" Main "$refs" > src1/pack1/Src1Pack1Main.java genSource "pack2" Main "$refs" > src1/pack2/Src1Pack2Main.java genSource "pack1" Main "$refs" > src2/pack1/Src2Pack1Main.java genSource "pack2" Main "$refs" > src2/pack2/Src2Pack2Main.java } genSource() { package="$1" class="$2" refs="$3" if [ -z "$package" ] ; then name="$class" else echo "package $package;" name="$package.$class" fi cat< util/Util.java < 0) sb.append(", "); sb.append(names[i]); } sb.append("]"); System.out.println(sb.toString()); } } } EOF compile util/Util.java "$JDKDIR/bin/jar" cf "$utiljar" -C classes . rm -rf util } getArgFiles() { name="$1" find . -name "$1"\*.lst | sed 's|./||' } echoSetup() { cat<