func TestSimple(t *testing.T) {
	solution, err := parser.ParseSolution(`D:\Projects\Sungero\Main\Kernel\src\SungeroKernel.sln`)
	if err != nil {
		assert.Fail(t, err.Error())
		return
	}
	assert.Equal(t, "SungeroKernel", solution.Name)
	assert.Equal(t, 38, len(solution.Projects))
	project := solution.FindProjectByName("DomainAPI.Server")
	assert.NotNil(t, project)
	assert.Exactly(t, solution, project.Solution)
	assert.Equal(t, `Kernel\DomainAPI\DomainAPI.Server\`, project.RelativeDirectory)
	assert.Equal(t, `bin\Debug\`, project.DebugOutputDirectory)
	assert.Equal(t, `bin\Release\`, project.GetOutputDirectory("release"))
	assert.Equal(t, `Library`, project.OutputType)
	assert.Nil(t, parser.ParseProject(project))
	//	for _, project = range solution.Projects {
	//		fmt.Println("****************************")
	//		fmt.Println(project.AssemblyName)
	//		for _, ref := range project.GlobalReferences {
	//			fmt.Println(ref.Name)
	//		}
	//		for _, ref := range project.LibReferences {
	//			fmt.Println(ref.Name, ref.Path)
	//		}
	//	}
}
func TestCompare(t *testing.T) {
	kernel_solution, _ := parser.ParseSolution(`D:\Projects\Sungero\Main\Kernel\src\SungeroKernel.sln`)
	common_solution, _ := parser.ParseSolution(`D:\Projects\Sungero\Main\Common\src\CommonLibrary.sln`)
	content_solution, _ := parser.ParseSolution(`D:\Projects\Sungero\Main\Content\src\SungeroLibrary.sln`)
	workflow_solution, _ := parser.ParseSolution(`D:\Projects\Sungero\Main\Workflow\src\SungeroWorkflow.sln`)
	report_solution, _ := parser.ParseSolution(`D:\Projects\Sungero\Main\Report\src\SungeroReport.sln`)

	assert.True(t, kernel_solution.DependsOn(common_solution))
	assert.False(t, common_solution.DependsOn(kernel_solution))

	assert.True(t, workflow_solution.DependsOn(kernel_solution))
	assert.True(t, content_solution.DependsOn(kernel_solution))
	assert.False(t, common_solution.DependsOn(workflow_solution))

	assert.False(t, content_solution.DependsOn(workflow_solution))
	assert.False(t, workflow_solution.DependsOn(content_solution))

	assert.False(t, report_solution.DependsOn(workflow_solution))
	assert.False(t, workflow_solution.DependsOn(report_solution, "Sungero.Domain.Interfaces"))
}
Example #3
0
func main() {
	log.Println("START...")
	parseCommandLine()
	fillSolutionPaths()
	defer func() {
		if originalSolutionsAliasesPath != "" {
			copyFileContents(originalSolutionsAliasesPath, solutionsAliasesPath)
		}
	}()
	log.Println(solutionsPaths)
	solutions := make([]*parser.Solution, len(solutionsPaths))
	buildSolutions := make([]*parser.Solution, 0, len(solutionsPaths))
	for i, solutionPath := range solutionsPaths {
		solution, _ := parser.ParseSolution(solutionPath)
		solutions[i] = solution
		if _, ok := buildSolutionPaths[solutionPath]; ok {
			buildSolutions = append(buildSolutions, solution)
		}
	}
	dependsOn := make(map[*parser.Solution]chan bool)
	dependsOnCounter := make(map[*parser.Solution]int)
	affectsOn := make(map[*parser.Solution][]chan bool)
	for _, solution := range solutions {
		dependsOn[solution] = make(chan bool, len(solutions))
		dependsOnCounter[solution] = 0
		affectsOn[solution] = make([]chan bool, 0, len(solutions))
	}
	for _, solution := range solutions {
		for _, other := range buildSolutions {
			if solution == other {
				continue
			}
			if solution.DependsOn(other) {
				dep, _ := dependsOn[solution]
				dependsOnCounter[solution] += 1

				deps, _ := affectsOn[other]
				deps = append(deps, dep)
				affectsOn[other] = deps
			}
		}
	}

	doneChan := make(chan bool, len(buildSolutions))
	for _, solution := range buildSolutions {
		go build(solution, doneChan, dependsOn[solution], dependsOnCounter[solution], affectsOn[solution], solutions)
	}
	for i := 0; i < len(buildSolutions); i++ {
		<-doneChan
	}
}