Skip to content

Commit

Permalink
Merge pull request #38 from jaseg/master
Browse files Browse the repository at this point in the history
Various compatibility fixes, test system cleanup
  • Loading branch information
sustrik committed Jul 27, 2015
2 parents f556213 + 9df9e3b commit 300c79d
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 120 deletions.
14 changes: 0 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
.*.sw?
*.rna
Makefile
Makefile.in
aclocal.m4
autom4te.cache/
config.log
config.status
configure
install-sh
missing
*~

examples/blue.txt
examples/green.txt
Expand All @@ -20,7 +9,4 @@ examples/mycompiler
examples/errno.h
examples/strerror.c

tests/*.sh
tests/*.out
tests/*.log
tests/*.trs
12 changes: 0 additions & 12 deletions Makefile.am

This file was deleted.

3 changes: 0 additions & 3 deletions autogen.sh

This file was deleted.

22 changes: 0 additions & 22 deletions configure.ac

This file was deleted.

6 changes: 3 additions & 3 deletions ribosome.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env nodejs
#!/usr/bin/env node

/*
Expand All @@ -24,7 +24,7 @@
*/

var PROLOGUE = "#!/usr/bin/env nodejs\n\
var PROLOGUE = "#!/usr/bin/env node\n\
\n\
/*\n\
\n\
Expand Down Expand Up @@ -630,7 +630,7 @@ if (rnaopt) {
}

if (!rnaopt) {
exec("nodejs " + rnafile + " " + process.argv.slice(3).join(' '), function(error, stdout, stderr) {
exec("node" + rnafile + " " + process.argv.slice(3).join(' '), function(error, stdout, stderr) {
if(stderr != "") {
exec("node " + rnafile + " " + process.argv.slice(3).join(' '), function(error, stdout, stderr) {
process.stdout.write(stdout);
Expand Down
17 changes: 10 additions & 7 deletions ribosome.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python

from __future__ import print_function

#
# Copyright (c) 2015 Ali Zaidi All rights reserved.
#
Expand Down Expand Up @@ -65,6 +67,8 @@ def __line__():
# IN THE SOFTWARE.
#
from __future__ import print_function, division
import sys
import re
Expand Down Expand Up @@ -121,7 +125,7 @@ def write(self, out, tabsize):
# If required, replace the initial whitespace by tabs.
if tabsize > 0:
ws = len(l) - len(l.lstrip())
l = '\t' * (ws / tabsize) + ' ' * (ws % tabsize) + l.lstrip()
l = '\t' * (ws // tabsize) + ' ' * (ws % tabsize) + l.lstrip()
# Write an individual line to the output file.
out.write(l + '\\n')
Expand Down Expand Up @@ -283,7 +287,7 @@ def rethrow(e, rnafile, linemap):
l = ', '.join(['File "<%s>"' % linemap[j][1],
'line %d' % num,
ts[-1]])
print l
print(l)
sys.exit(1)
Expand All @@ -305,9 +309,8 @@ def rethrow(e, rnafile, linemap):
import re

# Set up the arguments parser.
parser = argparse.ArgumentParser(
version = "ribosome code generator, version 1.15")
parser.add_argument('dna', type=file)
parser = argparse.ArgumentParser(prog="ribosome code generator, version 1.15")
parser.add_argument('dna', type=argparse.FileType('r'))
parser.add_argument('--rna', action='store_true')

# Pwd
Expand All @@ -330,7 +333,7 @@ def rethrow(e, rnafile, linemap):

# DNA helper functions
def dnaerror(s):
print >> sys.stderr, "%s:%s - %s" %(dnastack[-1][1], dnastack[-1][2], s)
print("%s:%s - %s" %(dnastack[-1][1], dnastack[-1][2], s), file=sys.stderr)

# Generate new line(s) into the RNA file.
def rnawrite(s):
Expand Down Expand Up @@ -501,7 +504,7 @@ def rnawrite(s):
if not args.rna:
import subprocess
# Execute the RNA file. Pass it any arguments not used by ribosome.
subprocess.call(['python', rnafile] + sys.argv[2:])
subprocess.call([sys.executable, rnafile] + sys.argv[2:])
# Delete the RNA file.
os.remove(rnafile)

29 changes: 29 additions & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

CHECKS := $(wildcard *.check)
PORTS := python2 python3 ruby node

all: $(PORTS)

$(PORTS): %: %-premsg $(CHECKS:%.check=%-%) %-postmsg


%-premsg:
@echo "Running $* tests."

%-postmsg:
@echo

%-python2:
@./runtest.sh python2 py $*

%-python3:
@./runtest.sh python3 py $*

%-ruby:
@./runtest.sh ruby rb $*

%-node:
@./runtest.sh node js $*

clean:
rm -f *.out *.log
20 changes: 0 additions & 20 deletions tests/Makefile.am

This file was deleted.

38 changes: 0 additions & 38 deletions tests/runtest.dna

This file was deleted.

18 changes: 18 additions & 0 deletions tests/runtest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
set -e

TOOL=$1
EXT=$2
TEST=$3

LOGFILE=$TEST.$TOOL.log
OUTFILE=$TEST.$TOOL.out

$TOOL ../ribosome.$EXT $TEST.$EXT.dna >$OUTFILE

if diff $OUTFILE $TEST.check >$LOGFILE; then
env echo -en "[\033[92mOK\033[0m] "
rm $LOGFILE $OUTFILE
else
env echo -en "[\033[91mFAIL\033[0m ($LOGFILE)] "
fi
2 changes: 1 addition & 1 deletion tests/separate.py.dna
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ for i in [1, 2, 3, 4, 5]:
.
./!separate ","
for i in [1, 2, 3, 4, 5]:
pass
pass

.
./!separate ","
Expand Down

0 comments on commit 300c79d

Please sign in to comment.