Use the hashicorp/go-getter to download files
* removed packer.Cache and references since packer.Cache is never used except in the download step. The download step now uses the new func packer.CachePath(targetPath) for this, the behavior is the same.
* removed download code from packer that was reimplemented into the go-getter library: progress bar, http download restart, checksuming from file, skip already downloaded files, symlinking, make a download cancellable by context.
* on windows if packer is running without symlinking rights and we are getting a local file, the file will be copied instead to avoid errors.
* added unit tests for step_download that are now CI tested on windows, mac & linux.
* files are now downloaded under cache dir `sha1(filename + "?checksum=" + checksum) + file_extension`
* since the output dir is based on the source url and the checksum, when the checksum fails, the file is auto deleted.
* a download file is protected and locked by a file lock,
* updated docs
* updated go modules and vendors
2019-03-13 07:11:58 -04:00
|
|
|
// +build !go1.9
|
|
|
|
|
|
|
|
package testing
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
)
|
|
|
|
|
|
|
|
// T is the interface that mimics the standard library *testing.T.
|
|
|
|
//
|
|
|
|
// In unit tests you can just pass a *testing.T struct. At runtime, outside
|
|
|
|
// of tests, you can pass in a RuntimeT struct from this package.
|
|
|
|
type T interface {
|
|
|
|
Error(args ...interface{})
|
|
|
|
Errorf(format string, args ...interface{})
|
|
|
|
Fail()
|
|
|
|
FailNow()
|
|
|
|
Failed() bool
|
|
|
|
Fatal(args ...interface{})
|
|
|
|
Fatalf(format string, args ...interface{})
|
|
|
|
Log(args ...interface{})
|
|
|
|
Logf(format string, args ...interface{})
|
|
|
|
Name() string
|
2020-05-11 15:26:01 -04:00
|
|
|
Parallel()
|
Use the hashicorp/go-getter to download files
* removed packer.Cache and references since packer.Cache is never used except in the download step. The download step now uses the new func packer.CachePath(targetPath) for this, the behavior is the same.
* removed download code from packer that was reimplemented into the go-getter library: progress bar, http download restart, checksuming from file, skip already downloaded files, symlinking, make a download cancellable by context.
* on windows if packer is running without symlinking rights and we are getting a local file, the file will be copied instead to avoid errors.
* added unit tests for step_download that are now CI tested on windows, mac & linux.
* files are now downloaded under cache dir `sha1(filename + "?checksum=" + checksum) + file_extension`
* since the output dir is based on the source url and the checksum, when the checksum fails, the file is auto deleted.
* a download file is protected and locked by a file lock,
* updated docs
* updated go modules and vendors
2019-03-13 07:11:58 -04:00
|
|
|
Skip(args ...interface{})
|
|
|
|
SkipNow()
|
|
|
|
Skipf(format string, args ...interface{})
|
|
|
|
Skipped() bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// RuntimeT implements T and can be instantiated and run at runtime to
|
|
|
|
// mimic *testing.T behavior. Unlike *testing.T, this will simply panic
|
|
|
|
// for calls to Fatal. For calls to Error, you'll have to check the errors
|
2020-05-11 15:26:01 -04:00
|
|
|
// list to determine whether to exit yourself.
|
|
|
|
//
|
|
|
|
// Parallel does not do anything.
|
Use the hashicorp/go-getter to download files
* removed packer.Cache and references since packer.Cache is never used except in the download step. The download step now uses the new func packer.CachePath(targetPath) for this, the behavior is the same.
* removed download code from packer that was reimplemented into the go-getter library: progress bar, http download restart, checksuming from file, skip already downloaded files, symlinking, make a download cancellable by context.
* on windows if packer is running without symlinking rights and we are getting a local file, the file will be copied instead to avoid errors.
* added unit tests for step_download that are now CI tested on windows, mac & linux.
* files are now downloaded under cache dir `sha1(filename + "?checksum=" + checksum) + file_extension`
* since the output dir is based on the source url and the checksum, when the checksum fails, the file is auto deleted.
* a download file is protected and locked by a file lock,
* updated docs
* updated go modules and vendors
2019-03-13 07:11:58 -04:00
|
|
|
type RuntimeT struct {
|
2020-05-11 15:26:01 -04:00
|
|
|
failed bool
|
|
|
|
skipped bool
|
Use the hashicorp/go-getter to download files
* removed packer.Cache and references since packer.Cache is never used except in the download step. The download step now uses the new func packer.CachePath(targetPath) for this, the behavior is the same.
* removed download code from packer that was reimplemented into the go-getter library: progress bar, http download restart, checksuming from file, skip already downloaded files, symlinking, make a download cancellable by context.
* on windows if packer is running without symlinking rights and we are getting a local file, the file will be copied instead to avoid errors.
* added unit tests for step_download that are now CI tested on windows, mac & linux.
* files are now downloaded under cache dir `sha1(filename + "?checksum=" + checksum) + file_extension`
* since the output dir is based on the source url and the checksum, when the checksum fails, the file is auto deleted.
* a download file is protected and locked by a file lock,
* updated docs
* updated go modules and vendors
2019-03-13 07:11:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *RuntimeT) Error(args ...interface{}) {
|
|
|
|
log.Println(fmt.Sprintln(args...))
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *RuntimeT) Errorf(format string, args ...interface{}) {
|
|
|
|
log.Println(fmt.Sprintf(format, args...))
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *RuntimeT) Fatal(args ...interface{}) {
|
|
|
|
log.Println(fmt.Sprintln(args...))
|
|
|
|
t.FailNow()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *RuntimeT) Fatalf(format string, args ...interface{}) {
|
|
|
|
log.Println(fmt.Sprintf(format, args...))
|
|
|
|
t.FailNow()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *RuntimeT) Fail() {
|
|
|
|
t.failed = true
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *RuntimeT) FailNow() {
|
|
|
|
panic("testing.T failed, see logs for output (if any)")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *RuntimeT) Failed() bool {
|
|
|
|
return t.failed
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *RuntimeT) Log(args ...interface{}) {
|
|
|
|
log.Println(fmt.Sprintln(args...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *RuntimeT) Logf(format string, args ...interface{}) {
|
|
|
|
log.Println(fmt.Sprintf(format, args...))
|
|
|
|
}
|
|
|
|
|
2020-05-11 15:26:01 -04:00
|
|
|
func (t *RuntimeT) Name() string {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *RuntimeT) Parallel() {}
|
|
|
|
|
|
|
|
func (t *RuntimeT) Skip(args ...interface{}) {
|
|
|
|
log.Print(args...)
|
|
|
|
t.SkipNow()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *RuntimeT) SkipNow() {
|
|
|
|
t.skipped = true
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *RuntimeT) Skipf(format string, args ...interface{}) {
|
|
|
|
log.Printf(format, args...)
|
|
|
|
t.SkipNow()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *RuntimeT) Skipped() bool {
|
|
|
|
return t.skipped
|
|
|
|
}
|