Skip to content

Commit

Permalink
more robust way of setting IFS to newline (sylabs#1708)
Browse files Browse the repository at this point in the history
* more robust way of setting IFS to newline

* e2e test for issue 1704

* added bugfix info to changelog
  • Loading branch information
preminger authored May 30, 2023
1 parent 1d07c58 commit a245574
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
### Bug Fixes

- Fix interaction between `--workdir` when given relative path and `--scratch`.
- Fix dropped "n" characters on some platforms in definition file stored as part
of SIF metadata.

## 3.11.3 \[2023-05-04\]

Expand Down
3 changes: 2 additions & 1 deletion cmd/internal/cli/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ func newCommand(allData bool, appName string, img *image.Image) *command {
cat_file() {
echo "%[3]s $1:$2"
local IFS=$'\n'
local IFS="
"
while read -r content; do
printf "%%s\n" "$content"
done < "$2"
Expand Down
3 changes: 2 additions & 1 deletion e2e/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,7 @@ func E2ETests(env e2e.TestEnv) testhelper.Tests {
// Regressions
"issue 4943": c.issue4943,
"issue 5172": c.issue5172,
"issue 274": c.issue274, // https://github.com/sylabs/singularity/issues/274
"issue 274": c.issue274, // https://github.com/sylabs/singularity/issues/274
"issue 1704": c.issue1704, // https://github.com/sylabs/singularity/issues/1704
}
}
43 changes: 43 additions & 0 deletions e2e/docker/regressions.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os"
"path"
"path/filepath"
"strings"
"testing"

"github.com/sylabs/singularity/e2e/internal/e2e"
Expand Down Expand Up @@ -182,6 +183,48 @@ From: continuumio/miniconda3:latest
)
}

// https://github.com/sylabs/singularity/issues/1704 Ensure that trailing "n"s
// aren't lopped off by the internal sandbox inspect call that is part of the
// SIF-building process.
func (c ctx) issue1704(t *testing.T) {
tmpDir, cleanup := e2e.MakeTempDir(t, c.env.TestDir, "issue1704-", "")
t.Cleanup(func() {
if !t.Failed() {
cleanup(t)
}
})

defPath := filepath.Join("..", "test", "defs", "issue1704.def")
sifPath := filepath.Join(tmpDir, "issue1704.sif")
bytes, err := os.ReadFile(defPath)
if err != nil {
t.Fatalf("could not read contents of def file %q: %s", defPath, err)
}
defFileContents := string(bytes)

c.env.RunSingularity(
t,
e2e.AsSubtest("Build"),
e2e.WithProfile(e2e.RootProfile),
e2e.WithCommand("build"),
e2e.WithArgs(sifPath, defPath),
e2e.ExpectExit(0),
)

if t.Failed() {
return
}

c.env.RunSingularity(
t,
e2e.AsSubtest("Inspect"),
e2e.WithProfile(e2e.UserProfile),
e2e.WithCommand("inspect"),
e2e.WithArgs("-d", sifPath),
e2e.ExpectExit(0, e2e.ExpectOutput(e2e.ContainMatch, strings.TrimSpace(defFileContents))),
)
}

// https://github.com/sylabs/singularity/issues/1286
// Ensure the bare docker://hello-world image runs in all modes
func (c ctx) issue1286(t *testing.T) {
Expand Down
10 changes: 10 additions & 0 deletions test/defs/issue1704.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
BootStrap: docker
From: ubuntu:22.04

%setup
#an
#abn
#nn
#ann
#nan
#anan

0 comments on commit a245574

Please sign in to comment.