Changes

Jump to navigation Jump to search

Sed replace to systemtest

1,861 bytes added, 17:35, 8 May 2014
Created page with "== Script to take any text file, and convert to be out in a systemtest == <source lang="Bash"> #!/bin/tcsh -f # To replace start end ending of line for relax. set s='$' set t..."
== Script to take any text file, and convert to be out in a systemtest ==
<source lang="Bash">
#!/bin/tcsh -f

# To replace start end ending of line for relax.
set s='$'
set t='"'
sed -e "s/^/ '/g" -e "s/$s/'+$t\\n$t\,/g" $1
</source>

=== Input ===
Example
<source lang="Text">
file = CR72_point_1_N
points = 2
format = ascii
interleaving = field
field = locations, field0
structure = 3-vector, scalar
type = float, float

end
</source>

=== Output ===
<source lang="Text">
'file = CR72_point_1_N'+"\n",
'points = 2'+"\n",
'format = ascii'+"\n",
'interleaving = field'+"\n",
'field = locations, field0'+"\n",
'structure = 3-vector, scalar'+"\n",
'type = float, float'+"\n",
''+"\n",
'end'+"\n",
</source>

== To be used in systemtest ==
<source lang="Text">
# Set filepaths.
map_general = ds.tmpdir+sep+file_name_map+".general"

# Test the files exists.
self.assert_(access(map_general, F_OK))

print("\nChecking the dx map .general file.")
res_file = [
'file = CR72_map_1_N'+"\n",
'grid = 5 x 5 x 5'+"\n",
'format = ascii'+"\n",
'interleaving = field'+"\n",
'majority = row'+"\n",
'field = data'+"\n",
'structure = scalar'+"\n",
'type = float'+"\n",
'dependency = positions'+"\n",
'positions = regular, regular, regular, 0, 1, 0, 1, 0, 1'+"\n",
''+"\n",
'end'+"\n",
]
file = open(map_general, 'r')
lines = file.readlines()
file.close()
for i in range(len(res_file)):
# Skip time point
#if i == 2:
# continue
self.assertEqual(res_file[i], lines[i])
</source>

Navigation menu