github.com/quickfeed/quickfeed@v0.0.0-20240507093252-ed8ca812a09c/doc/scripts/javabuild/testjava.sh (about)

     1  #!/bin/sh
     2  # This is a bootstrap file that will clone and
     3  # run all tests found the the merged folder.
     4  # It will also create a default build.gradle file
     5  # if it does not exist, but use the existing one,
     6  # if it does.
     7  
     8  # usage: testjava [username] [baserepo]
     9  
    10  if [ -z "$1" ]; then
    11      NAME=""
    12  else
    13      NAME=$1-
    14  fi
    15  if [ -z "$2" ]; then
    16      LINK="https://github.com/AutograderTestOrg1"
    17  else
    18      LINK=$2
    19  fi
    20  
    21  MERGE="merged"
    22  # Buildfile
    23  BF="build.gradle"
    24  AD="$NAME"assignments
    25  echo $PWD
    26  mkdir -p pull; cd pull
    27  mkdir -p $MERGE
    28  
    29  git clone $LINK/$AD
    30  git clone $LINK/tests
    31  
    32  cp -af $AD/. $MERGE/
    33  cp -af tests/. $MERGE/
    34  basePath=$PWD
    35  
    36  # Check if all folders have the $BF file
    37  for folder in $(ls $MERGE)
    38  do
    39      curPath=$PWD/$MERGE/$folder
    40      if [ -d $curPath ]; then
    41          if [ -f $curPath/$BF ]; then
    42              echo "Found $BF in $curPath/$BF"
    43          else
    44              echo "Missing $BF in $curPath creating file"
    45              echo "apply plugin: 'java'
    46  
    47  repositories {
    48      mavenCentral()
    49  }
    50  
    51  test { 
    52      testLogging.showStandardStreams = true
    53  }
    54  
    55  sourceCompatibility = 1.8
    56  targetCompatibility = 1.8
    57  
    58  sourceSets{
    59      main{ 
    60          java {
    61              srcDir 'src'
    62          }
    63      }
    64      test {
    65          java {
    66              srcDir 'test'
    67          }
    68      }
    69  }
    70  
    71  dependencies {
    72      testCompile 'junit:junit:4.12'
    73  }
    74   
    75  jar {
    76      baseName = 'ovigner' 
    77      version =  '0.1.0'
    78  }" > $curPath/$BF
    79          fi
    80      fi
    81  done
    82  
    83  # Run the $BF file in all the folders
    84  for folder in $(ls $MERGE)
    85  do
    86      if [ -d $basePath/$MERGE/$folder ]; then
    87          curPath=$basePath/$MERGE/$folder
    88          cd $curPath
    89          echo "====Running tests for $folder===="
    90          gradle clean test
    91      fi
    92  done