GithubHelp home page GithubHelp logo

test-utilities's People

Contributors

leontastic avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

tristan-potter

test-utilities's Issues

tg.sh: Unnecessary newlines in the first generated test

When generating tests, the first generated test contains unnecessary newlines before the contents of each file. Given a testfile with the following first case:

0=

0

The test input t0.in is generated with a single newline before the specified input:


0=

And the test output t0.out is generated with two newlines before the specified output:



0

In most cases this will cause the test to fail due to whitespace discrepancy. I believe the issue has something to do with the generation of the array when reading the testfile expressed in this chunk of code:

i=0
s=1
declare -a tests

KEY=$RANDOM
sed '/^ *#/ d' < ${TESTFILE} > /tmp/tmp-$KEY.txt

while read -r line; do
  # If we find an empty line, then we increase the counter (i), 
  # set the flag (s) to one, and skip to the next line
  [[ $line == "" ]] && ((i++)) && s=1 && continue

  # If the flag (s) is zero, then we are not in a new line of the block
  # so we set the value of the array to be the previous value concatenated
  # with the current line
  [[ $s == 0 ]] && tests[$i]="${tests[$i]}"$'\n'"$line" || { 
    # Otherwise we are in the first line of the block, so we set the value
    # of the array to the current line, and then we reset the flag (s) to zero 
    tests[$i]="$line"
    s=0
  }
done < /tmp/tmp-$KEY.txt

rm /tmp/tmp-$KEY.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.