Skip to content

Commit

Permalink
Re-enable CheckoutFromArchive test.
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchell-as committed Oct 23, 2024
1 parent d57144d commit 1cabf0e
Show file tree
Hide file tree
Showing 21 changed files with 1,847 additions and 8 deletions.
4 changes: 4 additions & 0 deletions internal/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ const UpdateChannelEnvVarName = "ACTIVESTATE_CLI_UPDATE_CHANNEL"
// InstallBuildDependenciesEnvVarName is the env var that is used to override whether to install build dependencies
const InstallBuildDependenciesEnvVarName = "ACTIVESTATE_CLI_INSTALL_BUILD_DEPENDENCIES"

// InstallInternalDependenciesEnvVarName is the env var that is used to override whether to install internal dependencies.
// This is only used for test cases.
const InstallInternalDependenciesEnvVarName = "ACTIVESTATE_CLI_INSTALL_INTERNAL_DEPENDENCIES"

// InternalConfigFileNameLegacy is effectively the same as InternalConfigName, but includes our preferred extension
const InternalConfigFileNameLegacy = "config.yaml"

Expand Down
11 changes: 8 additions & 3 deletions pkg/buildplan/filters.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package buildplan

import (
"os"
"strings"

"github.com/ActiveState/cli/internal/constants"
"github.com/ActiveState/cli/internal/sliceutils"
"github.com/ActiveState/cli/pkg/buildplan/raw"
"github.com/ActiveState/cli/pkg/platform/api/buildplanner/types"
Expand Down Expand Up @@ -44,9 +46,12 @@ const NamespaceInternal = "internal"

func FilterStateArtifacts() FilterArtifact {
return func(a *Artifact) bool {
internalIngredients := sliceutils.Filter(a.Ingredients, func(i *Ingredient) bool {
return i.Namespace == NamespaceInternal
})
internalIngredients := []*Ingredient{}
if os.Getenv(constants.InstallInternalDependenciesEnvVarName) != "true" {
internalIngredients = sliceutils.Filter(a.Ingredients, func(i *Ingredient) bool {
return i.Namespace == NamespaceInternal
})
}
if len(a.Ingredients) > 0 && len(a.Ingredients) == len(internalIngredients) {
return false
}
Expand Down
19 changes: 14 additions & 5 deletions test/integration/checkout_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"strings"
"testing"

"github.com/mholt/archiver/v3"

"github.com/ActiveState/cli/internal/constants"
"github.com/ActiveState/cli/internal/environment"
"github.com/ActiveState/cli/internal/fileutils"
Expand Down Expand Up @@ -365,21 +367,28 @@ func (suite *CheckoutIntegrationTestSuite) TestCveReport() {
}

func (suite *CheckoutIntegrationTestSuite) TestCheckoutFromArchive() {
suite.T().Skip("Skipping until https://activestatef.atlassian.net/browse/DX-3057 is fixed")
suite.OnlyRunForTags(tagsuite.Checkout)
ts := e2e.New(suite.T(), false)
defer ts.Close()

root := environment.GetRootPathUnsafe()
archive := filepath.Join(root, "test", "integration", "testdata", "checkout-from-archive", runtime.GOOS+".tar.gz")
dir := filepath.Join(root, "test", "integration", "testdata", "checkout-from-archive", runtime.GOOS)
tgz := fileutils.TempFilePath("", runtime.GOOS+".tar.gz")
files, err := fileutils.ListDirSimple(dir, false)
suite.Require().NoError(err)
gz := archiver.TarGz{Tar: &archiver.Tar{StripComponents: 1000}} // use a big number to strip all leading dirs
suite.Require().NoError(gz.Archive(files, tgz))
defer os.Remove(tgz)

cp := ts.SpawnWithOpts(
e2e.OptArgs("checkout", archive),
e2e.OptAppendEnv("HTTPS_PROXY=none://"), // simulate lack of network connection
e2e.OptArgs("checkout", tgz),
e2e.OptAppendEnv(
"HTTPS_PROXY=none://", // simulate lack of network connection
constants.InstallInternalDependenciesEnvVarName+"=true",
),
)
cp.Expect("Checking out project: ActiveState-CLI/AlmostEmpty")
cp.Expect("Setting up the following dependencies:")
cp.Expect("└─ [email protected]")
cp.Expect("Sourcing Runtime")
cp.Expect("Unpacking")
cp.Expect("Installing")
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"let": {
"in": "$runtime",
"runtime": {
"state_tool_artifacts_v1": {
"build_flags": [],
"src": "$sources"
}
},
"sources": {
"solve": {
"at_time": "$at_time",
"platforms": [
"46a5b48f-226a-4696-9746-ba4d50d661c2",
"78977bc8-0f32-519d-80f3-9043f059398c",
"7c998ec2-7491-4e75-be4d-8885800ef5f2"
],
"requirements": [
{
"name": "alternative-build-selector",
"namespace": "internal"
},
{
"name": "mingw-build-selector",
"namespace": "internal"
},
{
"name": "zlib",
"namespace": "shared"
}
],
"solver_version": null
}
}
}
}
Loading

0 comments on commit 1cabf0e

Please sign in to comment.